org.chromium.chrome.browser.tabmodel.TabModelSelector Java Examples

The following examples show how to use org.chromium.chrome.browser.tabmodel.TabModelSelector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChromeHomeNewTabPage.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a ChromeHomeNewTabPage.
 * @param context The context used to inflate the view.
 * @param tab The {@link Tab} that is showing this new tab page.
 * @param tabModelSelector The {@link TabModelSelector} used to open tabs.
 * @param layoutManager The {@link LayoutManagerChrome} used to observe overview mode changes.
 *                      This may be null if the NTP is created on startup due to
 *                      PartnerBrowserCustomizations.
 */
public ChromeHomeNewTabPage(final Context context, final Tab tab,
        final TabModelSelector tabModelSelector,
        @Nullable final LayoutManagerChrome layoutManager) {
    super(context, tab, tabModelSelector, layoutManager);

    mView = LayoutInflater.from(context).inflate(R.layout.chrome_home_new_tab_page, null);
    mLogoView = (LogoView) mView.findViewById(R.id.search_provider_logo);
    initializeCloseButton(mView.findViewById(R.id.close_button));

    Resources res = context.getResources();
    mBackgroundColor = ApiCompatibilityUtils.getColor(res, R.color.ntp_bg);
    mThemeColor = ApiCompatibilityUtils.getColor(res, R.color.default_primary_color);

    mLogoDelegate = initializeLogoView();

}
 
Example #2
Source File: LayoutManagerDocumentTabSwitcher.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void init(TabModelSelector selector, TabCreatorManager creator,
        TabContentManager content, ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchDelegate,
        ReaderModeManagerDelegate readerModeManagerDelegate,
        DynamicResourceLoader dynamicResourceLoader) {
    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate,
            readerModeManagerDelegate, dynamicResourceLoader);

    mTitleCache = mHost.getTitleCache();
    TabModelSelector documentTabSelector = ChromeApplication.getDocumentTabModelSelector();
    mOverviewListLayout.setTabModelSelector(documentTabSelector, content);
    mOverviewLayout.setTabModelSelector(documentTabSelector, content);

    // TODO(changwan): do we really need this?
    startShowing(getDefaultLayout(), false);
}
 
Example #3
Source File: LayoutManagerDocumentTabSwitcher.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = ChromeApplication.getDocumentTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = getExistingLayoutTab(tabId);
    if (layoutTab == null) return;

    if (mTitleCache != null && layoutTab.isTitleNeeded()) {
        mTitleCache.getUpdatedTitle(tab, "");
    }
    super.initLayoutTabFromHost(tabId);
}
 
Example #4
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    super.initLayoutTabFromHost(tabId);

    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = getExistingLayoutTab(tabId);
    if (layoutTab == null) return;

    if (mTitleCache != null && layoutTab.isTitleNeeded()) {
        mTitleCache.getUpdatedTitle(tab, "");
    }
}
 
Example #5
Source File: NativePageFactory.java    From 365browser with Apache License 2.0 6 votes vote down vote up
protected NativePage buildNewTabPage(ChromeActivity activity, Tab tab,
        TabModelSelector tabModelSelector) {
    if (FeatureUtilities.isChromeHomeEnabled()) {
        if (tab.isIncognito()) {
            return new ChromeHomeIncognitoNewTabPage(activity, tab, tabModelSelector,
                    ((ChromeTabbedActivity) activity).getLayoutManager());
        } else {
            return new ChromeHomeNewTabPage(activity, tab, tabModelSelector,
                    ((ChromeTabbedActivity) activity).getLayoutManager());
        }
    } else if (tab.isIncognito()) {
        return new IncognitoNewTabPage(activity);
    } else {
        return new NewTabPage(activity, new TabShim(tab), tabModelSelector);
    }
}
 
Example #6
Source File: OfflinePageUtils.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a snackbar controller that we can use to show our snackbar.
 * @param tabModelSelector used to retrieve a tab by ID
 */
private static SnackbarController createReloadSnackbarController(
        final TabModelSelector tabModelSelector) {
    Log.d(TAG, "building snackbar controller");

    return new SnackbarController() {
        @Override
        public void onAction(Object actionData) {
            assert actionData != null;
            int tabId = (int) actionData;
            RecordUserAction.record("OfflinePages.ReloadButtonClicked");
            Tab foundTab = tabModelSelector.getTabById(tabId);
            if (foundTab == null) return;

            LoadUrlParams params = new LoadUrlParams(
                    foundTab.getOfflinePageOriginalUrl(), PageTransition.RELOAD);
            foundTab.loadUrl(params);
        }

        @Override
        public void onDismissNoAction(Object actionData) {
            RecordUserAction.record("OfflinePages.ReloadButtonNotClicked");
        }
    };
}
 
Example #7
Source File: LayoutManagerDocument.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = mTabCache.get(tabId);
    if (layoutTab == null) return;

    String url = tab.getUrl();
    boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);
    int themeColor = tab.getThemeColor();
    boolean canUseLiveTexture =
            tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;
    layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(), canUseLiveTexture,
            themeColor, ColorUtils.getTextBoxColorForToolbarBackground(
                                mContext.getResources(), tab, themeColor),
            ColorUtils.getTextBoxAlphaForToolbarBackground(tab));

    mHost.requestRender();
}
 
Example #8
Source File: ChromeActivitySessionTracker.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Called when last of Chrome activities is stopped, ending the foreground session. This will
 * not be called when a Chrome activity is stopped because another Chrome activity takes over.
 * This is ensured by ActivityStatus, which switches to track new activity when its started and
 * will not report the old one being stopped (see createStateListener() below).
 */
private void onForegroundSessionEnd() {
    if (!mIsStarted) return;
    UmaUtils.recordBackgroundTime();
    ChromeApplication.flushPersistentData();
    mIsStarted = false;
    mPowerBroadcastReceiver.onForegroundSessionEnd();

    ChildProcessLauncher.onSentToBackground();
    IntentHandler.clearPendingReferrer();
    IntentHandler.clearPendingIncognitoUrl();

    int totalTabCount = 0;
    for (WeakReference<Activity> reference : ApplicationStatus.getRunningActivities()) {
        Activity activity = reference.get();
        if (activity instanceof ChromeActivity) {
            TabModelSelector tabModelSelector =
                    ((ChromeActivity) activity).getTabModelSelector();
            if (tabModelSelector != null) {
                totalTabCount += tabModelSelector.getTotalTabCount();
            }
        }
    }
    RecordHistogram.recordCountHistogram(
            "Tab.TotalTabCount.BeforeLeavingApp", totalTabCount);
}
 
Example #9
Source File: ChromeFullscreenManager.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an instance of the fullscreen mode manager.
 * @param activity The activity that supports fullscreen.
 * @param controlContainer Container holding the controls (Toolbar).
 * @param modelSelector The model selector providing access to the current tab.
 * @param resControlContainerHeight The dimension resource ID for the control container height.
 * @param supportsBrowserOverride Whether we want to disable the token system used by the
                                  browser.
 */
public ChromeFullscreenManager(Activity activity, ControlContainer controlContainer,
        TabModelSelector modelSelector, int resControlContainerHeight,
        boolean supportsBrowserOverride) {
    super(activity.getWindow(), modelSelector);

    mActivity = activity;
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    ((BaseChromiumApplication) activity.getApplication())
            .registerWindowFocusChangedListener(this);

    mWindow = activity.getWindow();
    mHandler = new FullscreenHandler(this);
    assert controlContainer != null;
    mControlContainer = controlContainer;
    Resources resources = mWindow.getContext().getResources();
    mControlContainerHeight = resources.getDimensionPixelSize(resControlContainerHeight);
    mRendererContentOffset = mControlContainerHeight;
    mSupportsBrowserOverride = supportsBrowserOverride;
    updateControlOffset();
}
 
Example #10
Source File: OfflinePageUtils.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a snackbar controller that we can use to show our snackbar.
 * @param tabModelSelector used to retrieve a tab by ID
 */
private static SnackbarController createReloadSnackbarController(
        final TabModelSelector tabModelSelector) {
    Log.d(TAG, "building snackbar controller");

    return new SnackbarController() {
        @Override
        public void onAction(Object actionData) {
            assert actionData != null;
            int tabId = (int) actionData;
            RecordUserAction.record("OfflinePages.ReloadButtonClicked");
            Tab foundTab = tabModelSelector.getTabById(tabId);
            if (foundTab == null) return;
            // Delegates to Tab to reload the page. Tab will send the correct header in order to
            // load the right page.
            foundTab.reload();
        }

        @Override
        public void onDismissNoAction(Object actionData) {
            RecordUserAction.record("OfflinePages.ReloadButtonNotClicked");
        }
    };
}
 
Example #11
Source File: ChromeActivitySessionTracker.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Called when last of Chrome activities is stopped, ending the foreground session. This will
 * not be called when a Chrome activity is stopped because another Chrome activity takes over.
 * This is ensured by ActivityStatus, which switches to track new activity when its started and
 * will not report the old one being stopped (see createStateListener() below).
 */
private void onForegroundSessionEnd() {
    if (!mIsStarted) return;
    ChromeApplication.flushPersistentData();
    mIsStarted = false;
    mPowerBroadcastReceiver.onForegroundSessionEnd();

    ChildProcessLauncher.onSentToBackground();
    IntentHandler.clearPendingReferrer();
    IntentHandler.clearPendingIncognitoUrl();

    int totalTabCount = 0;
    for (WeakReference<Activity> reference : ApplicationStatus.getRunningActivities()) {
        Activity activity = reference.get();
        if (activity instanceof ChromeActivity) {
            TabModelSelector tabModelSelector =
                    ((ChromeActivity) activity).getTabModelSelector();
            if (tabModelSelector != null) {
                totalTabCount += tabModelSelector.getTotalTabCount();
            }
        }
    }
    RecordHistogram.recordCountHistogram(
            "Tab.TotalTabCount.BeforeLeavingApp", totalTabCount);
}
 
Example #12
Source File: OfflinePageTabObserver.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a snackbar controller that we can use to show our snackbar.
 * @param tabModelSelector used to retrieve a tab by ID
 */
private static SnackbarController createReloadSnackbarController(
        final TabModelSelector tabModelSelector) {
    Log.d(TAG, "building snackbar controller");

    return new SnackbarController() {
        @Override
        public void onAction(Object actionData) {
            assert actionData != null;
            int tabId = (int) actionData;
            RecordUserAction.record("OfflinePages.ReloadButtonClicked");
            Tab foundTab = tabModelSelector.getTabById(tabId);
            if (foundTab == null) return;
            // Delegates to Tab to reload the page. Tab will send the correct header in order to
            // load the right page.
            foundTab.reload();
        }

        @Override
        public void onDismissNoAction(Object actionData) {
            RecordUserAction.record("OfflinePages.ReloadButtonNotClicked");
        }
    };
}
 
Example #13
Source File: BottomSheet.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @param tabModelSelector A TabModelSelector for getting the current tab and activity.
 */
public void setTabModelSelector(TabModelSelector tabModelSelector) {
    mTabModelSelector = tabModelSelector;

    if (mHasRootLayoutOccurred && mTabModelSelector.isTabStateInitialized()) {
        showHelpBubbleIfNecessary();
    } else if (!mTabModelSelector.isTabStateInitialized()) {
        mTabModelSelector.addObserver(new EmptyTabModelSelectorObserver() {
            @Override
            public void onTabStateInitialized() {
                if (mHasRootLayoutOccurred) showHelpBubbleIfNecessary();
                mTabModelSelector.removeObserver(this);
            }
        });
    }

    mNtpController.setTabModelSelector(tabModelSelector);
}
 
Example #14
Source File: FullScreenActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected TabModelSelector createTabModelSelector() {
    return new SingleTabModelSelector(this, false, false) {
        @Override
        public Tab openNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent,
                boolean incognito) {
            getTabCreator(incognito).createNewTab(loadUrlParams, type, parent);
            return null;
        }
    };
}
 
Example #15
Source File: UmaSessionStats.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Starts a new session for logging.
 * @param tabModelSelector A TabModelSelector instance for recording tab counts on page loads.
 * If null, UmaSessionStats does not record page loads and tab counts.
 */
public void startNewSession(TabModelSelector tabModelSelector) {
    ensureNativeInitialized();

    mTabModelSelector = tabModelSelector;
    if (mTabModelSelector != null) {
        mComponentCallbacks = new ComponentCallbacks() {
            @Override
            public void onLowMemory() {
                // Not required
            }

            @Override
            public void onConfigurationChanged(Configuration newConfig) {
                mKeyboardConnected = newConfig.keyboard != Configuration.KEYBOARD_NOKEYS;
            }
        };
        mContext.registerComponentCallbacks(mComponentCallbacks);
        mKeyboardConnected = mContext.getResources().getConfiguration()
                .keyboard != Configuration.KEYBOARD_NOKEYS;
        mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(mTabModelSelector) {
            @Override
            public void onPageLoadFinished(Tab tab) {
                recordPageLoadStats(tab);
            }
        };
    }

    nativeUmaResumeSession(sNativeUmaSessionStats);
    updatePreferences();
    updateMetricsServiceState();
    DefaultBrowserInfo.logDefaultBrowserStats();
}
 
Example #16
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Detach and return the {@link TabModelSelector} in order to disconnect this
 * {@link CompositorViewHolder} so that VR can take ownership of Chrome's rendering.
 * @return The detached {@link TabModelSelector}.
 */
public TabModelSelector detachForVr() {
    if (mTabModelSelector != null) mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    TabModelSelector selector = mTabModelSelector;
    mTabModelSelector = null;
    mLayerTitleCache.setTabModelSelector(null);
    setTab(null);
    getCompositorView().setVisibility(View.INVISIBLE);
    return selector;
}
 
Example #17
Source File: NativePageFactory.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
protected NativePage buildNewTabPage(ChromeActivity activity, Tab tab,
        TabModelSelector tabModelSelector) {
    if (tab.isIncognito()) {
        return new IncognitoNewTabPage(activity);
    } else {
        return new NewTabPage(activity, tab, tabModelSelector);
    }
}
 
Example #18
Source File: AccessibilityTabModelWrapper.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param modelSelector A {@link TabModelSelector} to provide information
 *            about open tabs.
 */
public void setTabModelSelector(TabModelSelector modelSelector) {
    if (mIsAttachedToWindow) {
        mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    }
    mTabModelSelector = modelSelector;
    if (mIsAttachedToWindow) {
        modelSelector.addObserver(mTabModelSelectorObserver);
    }
    setStateBasedOnModel();
}
 
Example #19
Source File: OverviewListLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void setTabModelSelector(
        TabModelSelector tabModelSelector, TabContentManager tabContentManager) {
    super.setTabModelSelector(tabModelSelector, tabContentManager);

    if (mTabModelWrapper == null) return;
    mTabModelWrapper.setTabModelSelector(tabModelSelector);
}
 
Example #20
Source File: SuggestionsNavigationDelegateImpl.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public SuggestionsNavigationDelegateImpl(ChromeActivity activity, Profile profile,
        NativePageHost host, TabModelSelector tabModelSelector) {
    mActivity = activity;
    mProfile = profile;
    mHost = host;
    mTabModelSelector = tabModelSelector;
}
 
Example #21
Source File: EmptyBackgroundViewTablet.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the {@link TabModelSelector} that will be queried for information about the state of
 * the system.
 * @param tabModelSelector A {@link TabModelSelector} that represents the state of the system.
 */
public void setTabModelSelector(TabModelSelector tabModelSelector) {
    mTabModelSelector = tabModelSelector;

    mIncognitoToggleButton = (IncognitoToggleButtonTablet) findViewById(
            R.id.empty_incognito_toggle_button);

    mIncognitoToggleButton.setTabModelSelector(mTabModelSelector);
}
 
Example #22
Source File: CustomTabActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected TabModelSelector createTabModelSelector() {
    TabPersistencePolicy persistencePolicy = new CustomTabTabPersistencePolicy(
            getTaskId(), getSavedInstanceState() != null);

    return new TabModelSelectorImpl(this, this, persistencePolicy, false, false);
}
 
Example #23
Source File: ReaderModeManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
public ReaderModeManager(TabModelSelector selector, ChromeActivity activity) {
    super(selector);
    mTabId = Tab.INVALID_TAB_ID;
    mTabModelSelector = selector;
    mChromeActivity = activity;
    mTabStatusMap = new HashMap<>();
    mIsReaderHeuristicAlwaysTrue = isDistillerHeuristicAlwaysTrue();
}
 
Example #24
Source File: LayoutManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the {@link LayoutManager}.  Must be called before using this object.
 * @param selector                 A {@link TabModelSelector} instance.
 * @param creator                  A {@link TabCreatorManager} instance.
 * @param content                  A {@link TabContentManager} instance.
 * @param androidContentContainer  A {@link ViewGroup} for Android views to be bound to.
 * @param contextualSearchDelegate A {@link ContextualSearchDelegate} instance.
 * @param readerModeDelegate       A {@link ReaderModeManagerDelegate} instance.
 * @param dynamicResourceLoader    A {@link DynamicResourceLoader} instance.
 */
public void init(TabModelSelector selector, TabCreatorManager creator,
        TabContentManager content, ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchDelegate,
        ReaderModeManagerDelegate readerModeDelegate,
        DynamicResourceLoader dynamicResourceLoader) {
    mTabModelSelector = selector;
    mContentContainer = androidContentContainer;

    if (mNextActiveLayout != null) startShowing(mNextActiveLayout, true);

    updateLayoutForTabModelSelector();
}
 
Example #25
Source File: ReaderModeManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public ReaderModeManager(TabModelSelector selector, ChromeActivity activity) {
    super(selector);
    mTabId = Tab.INVALID_TAB_ID;
    mTabModelSelector = selector;
    mChromeActivity = activity;
    mTabStatusMap = new HashMap<>();
    mIsReaderHeuristicAlwaysTrue = isDistillerHeuristicAlwaysTrue();
}
 
Example #26
Source File: LayoutManagerDocument.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = mTabCache.get(tabId);
    if (layoutTab == null) return;

    String url = tab.getUrl();
    boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);
    int themeColor = tab.getThemeColor();
    // TODO(xingliu): Remove this override themeColor for Blimp tabs. See crbug.com/644774.
    if (tab.isBlimpTab() && tab.getBlimpContents() != null) {
        themeColor = tab.getBlimpContents().getThemeColor();
    }

    boolean canUseLiveTexture = tab.isBlimpTab()
            || tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;

    boolean needsUpdate = layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(),
            canUseLiveTexture, themeColor, ColorUtils.getTextBoxColorForToolbarBackground(
                                mContext.getResources(), tab, themeColor),
            ColorUtils.getTextBoxAlphaForToolbarBackground(tab));
    if (needsUpdate) requestUpdate();

    mHost.requestRender();
}
 
Example #27
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the appropriate objects this class should represent.
 * @param tabModelSelector        The {@link TabModelSelector} this View should hold and
 *                                represent.
 * @param tabCreatorManager       The {@link TabCreatorManager} for this view.
 * @param tabContentManager       The {@link TabContentManager} for the tabs.
 * @param androidContentContainer The {@link ViewGroup} the {@link LayoutManager} should bind
 *                                Android content to.
 * @param contextualSearchManager A {@link ContextualSearchManagementDelegate} instance.
 * @param readerModeManager       A {@link ReaderModeManagerDelegate} instance.
 */
public void onFinishNativeInitialization(TabModelSelector tabModelSelector,
        TabCreatorManager tabCreatorManager, TabContentManager tabContentManager,
        ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchManager,
        ReaderModeManagerDelegate readerModeManager) {
    assert mLayoutManager != null;
    mLayoutManager.init(tabModelSelector, tabCreatorManager, tabContentManager,
            androidContentContainer, contextualSearchManager, readerModeManager,
            mCompositorView.getResourceManager().getDynamicResourceLoader());
    mTabModelSelector = tabModelSelector;
    tabModelSelector.addObserver(new EmptyTabModelSelectorObserver() {
        @Override
        public void onChange() {
            onContentChanged();
        }

        @Override
        public void onNewTabCreated(Tab tab) {
            initializeTab(tab);
        }
    });

    mLayerTitleCache.setTabModelSelector(mTabModelSelector);

    onContentChanged();
}
 
Example #28
Source File: AccessibilityTabModelWrapper.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @param modelSelector A {@link TabModelSelector} to provide information
 *            about open tabs.
 */
public void setTabModelSelector(TabModelSelector modelSelector) {
    if (mIsAttachedToWindow) {
        mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    }
    mTabModelSelector = modelSelector;
    if (mIsAttachedToWindow) {
        modelSelector.addObserver(mTabModelSelectorObserver);
    }
    setStateBasedOnModel();
}
 
Example #29
Source File: CustomTabLayoutManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void init(TabModelSelector selector, TabCreatorManager creator,
        TabContentManager content, ViewGroup androidContentContainer,
        ContextualSearchManagementDelegate contextualSearchDelegate,
        ReaderModeManagerDelegate readerModeDelegate,
        DynamicResourceLoader dynamicResourceLoader) {
    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate,
            readerModeDelegate, dynamicResourceLoader);
    for (TabModel model : selector.getModels()) model.addObserver(mTabModelObserver);
}
 
Example #30
Source File: OverviewListLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void setTabModelSelector(
        TabModelSelector tabModelSelector, TabContentManager tabContentManager) {
    super.setTabModelSelector(tabModelSelector, tabContentManager);

    if (mTabModelWrapper == null) return;
    mTabModelWrapper.setTabModelSelector(tabModelSelector);
}