Search in sources :

Example 1 with ChromeActivity

use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.

the class LocationBarLayout method updateOmniboxResultsContainerVisibility.

private void updateOmniboxResultsContainerVisibility(boolean visible) {
    boolean currentlyVisible = mOmniboxResultsContainer.getVisibility() == VISIBLE;
    if (currentlyVisible == visible)
        return;
    ChromeActivity activity = (ChromeActivity) mWindowAndroid.getActivity().get();
    if (visible) {
        mOmniboxResultsContainer.setVisibility(VISIBLE);
        if (activity != null)
            activity.addViewObscuringAllTabs(mOmniboxResultsContainer);
    } else {
        mOmniboxResultsContainer.setVisibility(INVISIBLE);
        if (activity != null)
            activity.removeViewObscuringAllTabs(mOmniboxResultsContainer);
    }
}
Also used : ChromeActivity(org.chromium.chrome.browser.ChromeActivity)

Example 2 with ChromeActivity

use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.

the class ChromeDownloadDelegate method closeBlankTab.

/**
     * Close a blank tab just opened for the download purpose.
     * @return true iff the tab was (already) closed.
     */
private boolean closeBlankTab() {
    if (mTab == null) {
        // We do not want caller to dismiss infobar.
        return true;
    }
    WebContents contents = mTab.getWebContents();
    boolean isInitialNavigation = contents == null || contents.getNavigationController().isInitialNavigation();
    if (isInitialNavigation) {
        // Tab is created just for download, close it.
        Activity activity = mTab.getWindowAndroid().getActivity().get();
        if (!(activity instanceof ChromeActivity))
            return true;
        TabModelSelector selector = ((ChromeActivity) activity).getTabModelSelector();
        return selector == null ? true : selector.closeTab(mTab);
    }
    return false;
}
Also used : WebContents(org.chromium.content_public.browser.WebContents) TabModelSelector(org.chromium.chrome.browser.tabmodel.TabModelSelector) ChromeActivity(org.chromium.chrome.browser.ChromeActivity) Activity(android.app.Activity) ChromeActivity(org.chromium.chrome.browser.ChromeActivity)

Example 3 with ChromeActivity

use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.

the class Tab method detachAndStartReparenting.

/**
     * Begins the tab reparenting process. Detaches the tab from its current activity and fires
     * an Intent to reparent the tab into its new host activity.
     *
     * @param intent An optional intent with the desired component, flags, or extras to use when
     *               launching the new host activity. This intent's URI and action will be
     *               overriden. This may be null if no intent customization is needed.
     * @param startActivityOptions Options to pass to {@link Activity#startActivity(Intent, Bundle)}
     * @param finalizeCallback A callback that will be called after the tab is attached to the new
     *                         host activity in {@link #attachAndFinishReparenting}.
     * @return Whether reparenting succeeded. If false, the tab was not removed and the intent was
     *         not fired.
     */
public boolean detachAndStartReparenting(Intent intent, Bundle startActivityOptions, Runnable finalizeCallback) {
    ChromeActivity activity = getActivity();
    if (activity == null)
        return false;
    if (intent == null)
        intent = new Intent();
    if (intent.getComponent() == null) {
        intent.setClass(mThemedApplicationContext, ChromeLauncherActivity.class);
    }
    intent.setAction(Intent.ACTION_VIEW);
    if (TextUtils.isEmpty(intent.getDataString()))
        intent.setData(Uri.parse(getUrl()));
    if (isIncognito()) {
        intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, true);
    }
    IntentHandler.addTrustedIntentExtras(intent, activity);
    if (ChromeFeatureList.isEnabled(ChromeFeatureList.TAB_REPARENTING)) {
        TabModelSelector tabModelSelector = getTabModelSelector();
        if (tabModelSelector == null)
            return false;
        mIsDetachedForReparenting = true;
        // Add the tab to AsyncTabParamsManager before removing it from the current model to
        // ensure the global count of tabs is correct. See crbug.com/611806.
        intent.putExtra(IntentHandler.EXTRA_TAB_ID, mId);
        AsyncTabParamsManager.add(mId, new TabReparentingParams(this, intent, finalizeCallback));
        tabModelSelector.getModel(mIncognito).removeTab(this);
        // TODO(mthiesse): File a bug when crbug isn't down.
        if (mContentViewCore != null)
            mContentViewCore.updateWindowAndroid(null);
        attachTabContentManager(null);
    }
    activity.startActivity(intent, startActivityOptions);
    return true;
}
Also used : SingleTabModelSelector(org.chromium.chrome.browser.tabmodel.SingleTabModelSelector) TabModelSelector(org.chromium.chrome.browser.tabmodel.TabModelSelector) TabReparentingParams(org.chromium.chrome.browser.tabmodel.TabReparentingParams) Intent(android.content.Intent) ChromeActivity(org.chromium.chrome.browser.ChromeActivity)

Example 4 with ChromeActivity

use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.

the class LocationBarLayout method onUrlFocusChange.

/**
     * Triggered when the URL input field has gained or lost focus.
     * @param hasFocus Whether the URL field has gained focus.
     */
public void onUrlFocusChange(boolean hasFocus) {
    mUrlHasFocus = hasFocus;
    updateButtonVisibility();
    updateNavigationButton();
    Tab currentTab = getCurrentTab();
    if (hasFocus) {
        if (mNativeInitialized)
            RecordUserAction.record("FocusLocation");
        mUrlBar.deEmphasizeUrl();
    } else {
        mUrlFocusedFromFakebox = false;
        mUrlFocusedWithoutAnimations = false;
        hideSuggestions();
        // Focus change caused by a close-tab may result in an invalid current tab.
        if (currentTab != null) {
            setUrlToPageUrl();
            emphasizeUrl();
        }
    }
    if (getToolbarDataProvider().isUsingBrandColor()) {
        updateVisualsForState();
        if (mUrlHasFocus)
            mUrlBar.selectAll();
    }
    changeLocationBarIcon();
    updateVerboseStatusVisibility();
    updateLocationBarIconContainerVisibility();
    mUrlBar.setCursorVisible(hasFocus);
    if (!mUrlFocusedWithoutAnimations)
        handleUrlFocusAnimation(hasFocus);
    if (hasFocus && currentTab != null && !currentTab.isIncognito()) {
        if (mNativeInitialized && TemplateUrlService.getInstance().isDefaultSearchEngineGoogle()) {
            GeolocationHeader.primeLocationForGeoHeader(getContext());
        } else {
            mDeferredNativeRunnables.add(new Runnable() {

                @Override
                public void run() {
                    if (TemplateUrlService.getInstance().isDefaultSearchEngineGoogle()) {
                        GeolocationHeader.primeLocationForGeoHeader(getContext());
                    }
                }
            });
        }
    }
    if (mNativeInitialized) {
        startZeroSuggest();
    } else {
        mDeferredNativeRunnables.add(new Runnable() {

            @Override
            public void run() {
                if (TextUtils.isEmpty(mUrlBar.getQueryText())) {
                    startZeroSuggest();
                }
            }
        });
    }
    if (!hasFocus) {
        mHasStartedNewOmniboxEditSession = false;
        mNewOmniboxEditSessionTimestamp = -1;
    }
    if (hasFocus && currentTab != null) {
        ChromeActivity activity = (ChromeActivity) mWindowAndroid.getActivity().get();
        if (activity != null) {
            GeolocationSnackbarController.maybeShowSnackbar(activity.getSnackbarManager(), LocationBarLayout.this, currentTab.isIncognito(), GEOLOCATION_SNACKBAR_SHOW_DELAY_MS);
        }
    }
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) ChromeActivity(org.chromium.chrome.browser.ChromeActivity)

Example 5 with ChromeActivity

use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.

the class PrintShareActivity method handlePrintAction.

private void handlePrintAction() {
    int triggeringTaskId = IntentUtils.safeGetIntExtra(getIntent(), ShareHelper.EXTRA_TASK_ID, 0);
    List<WeakReference<Activity>> activities = ApplicationStatus.getRunningActivities();
    ChromeActivity triggeringActivity = null;
    for (int i = 0; i < activities.size(); i++) {
        Activity activity = activities.get(i).get();
        if (activity == null)
            continue;
        // of this activity will match that of the triggering activity.
        if (activity.getTaskId() == triggeringTaskId && activity instanceof ChromeActivity) {
            triggeringActivity = (ChromeActivity) activity;
            break;
        }
    }
    if (triggeringActivity == null)
        return;
    unregisterActivity(triggeringActivity);
    triggeringActivity.onMenuOrKeyboardAction(R.id.print_id, true);
}
Also used : WeakReference(java.lang.ref.WeakReference) ChromeActivity(org.chromium.chrome.browser.ChromeActivity) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(android.app.Activity) ChromeActivity(org.chromium.chrome.browser.ChromeActivity)

Aggregations

ChromeActivity (org.chromium.chrome.browser.ChromeActivity)6 Activity (android.app.Activity)2 TabModelSelector (org.chromium.chrome.browser.tabmodel.TabModelSelector)2 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Rect (android.graphics.Rect)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 WeakReference (java.lang.ref.WeakReference)1 Tab (org.chromium.chrome.browser.tab.Tab)1 SingleTabModelSelector (org.chromium.chrome.browser.tabmodel.SingleTabModelSelector)1 TabReparentingParams (org.chromium.chrome.browser.tabmodel.TabReparentingParams)1 WebContents (org.chromium.content_public.browser.WebContents)1