Search in sources :

Example 6 with Tab

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

the class LocationBarLayout method loadUrl.

private void loadUrl(String url, int transition) {
    Tab currentTab = getCurrentTab();
    // side is initialized
    assert mNativeInitialized : "Loading URL before native side initialized";
    if (currentTab != null && (currentTab.isNativePage() || NewTabPage.isNTPUrl(currentTab.getUrl()))) {
        NewTabPageUma.recordOmniboxNavigation(url, transition);
        // the page as it does when you click and press enter on any other site.
        if (url.isEmpty())
            url = currentTab.getUrl();
    }
    // Loads the |url| in the current ContentView and gives focus to the ContentView.
    if (currentTab != null && !url.isEmpty()) {
        LoadUrlParams loadUrlParams = new LoadUrlParams(url);
        loadUrlParams.setVerbatimHeaders(GeolocationHeader.getGeoHeader(getContext(), url, currentTab.isIncognito()));
        loadUrlParams.setTransitionType(transition | PageTransition.FROM_ADDRESS_BAR);
        currentTab.loadUrl(loadUrlParams);
        setUrlToPageUrl();
        RecordUserAction.record("MobileOmniboxUse");
        RecordUserAction.record("MobileTabClobbered");
    } else {
        setUrlToPageUrl();
    }
    if (currentTab != null)
        currentTab.requestFocus();
    // Prevent any upcoming omnibox suggestions from showing. We have to do this after we load
    // the URL as this will hide the suggestions and trigger a cancel of the prerendered page.
    stopAutocomplete(true);
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 7 with Tab

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

the class LocationBarLayout method startZeroSuggest.

/**
     * Make a zero suggest request if native is loaded, the URL bar has focus, and the
     * current tab is not incognito.
     */
private void startZeroSuggest() {
    // Reset "edited" state in the omnibox if zero suggest is triggered -- new edits
    // now count as a new session.
    mHasStartedNewOmniboxEditSession = false;
    mNewOmniboxEditSessionTimestamp = -1;
    Tab currentTab = getCurrentTab();
    if (mNativeInitialized && mUrlHasFocus && currentTab != null && !currentTab.isIncognito()) {
        mAutocomplete.startZeroSuggest(currentTab.getProfile(), mUrlBar.getQueryText(), currentTab.getUrl(), mUrlFocusedFromFakebox);
    }
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Example 8 with Tab

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

the class LocationBarLayout method updateUseDarkColors.

/**
     * Checks the current specs and updates {@link LocationBar#mUseDarkColors} if necessary.
     * @return Whether {@link LocationBar#mUseDarkColors} has been updated.
     */
private boolean updateUseDarkColors() {
    Tab tab = getCurrentTab();
    boolean brandColorNeedsLightText = false;
    if (getToolbarDataProvider().isUsingBrandColor() && !mUrlHasFocus) {
        int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
        brandColorNeedsLightText = ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor);
    }
    boolean useDarkColors = tab == null || !(tab.isIncognito() || brandColorNeedsLightText);
    boolean hasChanged = useDarkColors != mUseDarkColors;
    mUseDarkColors = useDarkColors;
    return hasChanged;
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Example 9 with Tab

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

the class ChromeActivity method onPauseWithNative.

@Override
public void onPauseWithNative() {
    RecordUserAction.record("MobileGoToBackground");
    Tab tab = getActivityTab();
    if (tab != null) {
        getTabContentManager().cacheTabThumbnail(tab);
    }
    markSessionEnd();
    super.onPauseWithNative();
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Example 10 with Tab

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

the class ChromeActivity method onWindowFocusChanged.

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    Tab tab = getActivityTab();
    if (tab == null)
        return;
    if (hasFocus) {
        tab.onActivityShown();
    } else {
        boolean stopped = ApplicationStatus.getStateForActivity(this) == ActivityState.STOPPED;
        if (stopped)
            tab.onActivityHidden();
    }
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Aggregations

Tab (org.chromium.chrome.browser.tab.Tab)116 LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)13 TabModel (org.chromium.chrome.browser.tabmodel.TabModel)10 LoadUrlParams (org.chromium.content_public.browser.LoadUrlParams)9 SuppressLint (android.annotation.SuppressLint)8 TabModelSelectorTabObserver (org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)8 Intent (android.content.Intent)5 FrameLayout (android.widget.FrameLayout)4 ContentViewCore (org.chromium.content.browser.ContentViewCore)4 WebContents (org.chromium.content_public.browser.WebContents)4 Activity (android.app.Activity)3 Bitmap (android.graphics.Bitmap)3 TabLaunchType (org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType)3 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 Bundle (android.os.Bundle)2 StrictMode (android.os.StrictMode)2 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2