use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class FindToolbar method deactivate.
/**
* Call this just before closing the find toolbar.
* @param clearSelection Whether the selection on the page should be cleared.
*/
public void deactivate(boolean clearSelection) {
if (!mActive)
return;
if (mObserver != null)
mObserver.onFindToolbarHidden();
setResultsBarVisibility(false);
mTabModelSelector.removeObserver(mTabModelSelectorObserver);
for (TabModel model : mTabModelSelector.getModels()) {
model.removeObserver(mTabModelObserver);
}
mCurrentTab.getTabWebContentsDelegateAndroid().setFindResultListener(null);
mCurrentTab.getTabWebContentsDelegateAndroid().setFindMatchRectsListener(null);
mCurrentTab.removeObserver(mTabObserver);
UiUtils.hideKeyboard(mFindQuery);
if (mFindQuery.getText().length() > 0) {
clearResults();
mFindInPageBridge.stopFinding(clearSelection);
}
mFindInPageBridge.destroy();
mFindInPageBridge = null;
mCurrentTab = null;
mActive = false;
}
use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class IncognitoToggleButtonTablet method setTabModelSelector.
/**
* Sets the {@link TabModelSelector} that will be queried for information about the state of
* the system.
* @param selector A {@link TabModelSelector} that represents the state of the system.
*/
public void setTabModelSelector(TabModelSelector selector) {
mTabModelSelector = selector;
if (selector != null) {
updateButtonResource();
updateButtonVisibility();
mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {
@Override
public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
updateButtonResource();
}
};
mTabModelSelector.addObserver(mTabModelSelectorObserver);
mTabModelObserver = new EmptyTabModelObserver() {
@Override
public void didAddTab(Tab tab, TabLaunchType type) {
updateButtonVisibility();
}
@Override
public void willCloseTab(Tab tab, boolean animate) {
updateButtonVisibility();
}
@Override
public void tabRemoved(Tab tab) {
updateButtonVisibility();
}
};
for (TabModel model : mTabModelSelector.getModels()) {
model.addObserver(mTabModelObserver);
}
}
}
use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class EmptyBackgroundViewWrapper method shouldShowEmptyContainer.
private boolean shouldShowEmptyContainer() {
TabModel model = mTabModelSelector.getModel(false);
if (model == null) {
return false;
}
boolean isIncognitoEmpty = mTabModelSelector.getModel(true).getCount() == 0;
boolean incognitoSelected = mTabModelSelector.isIncognitoSelected();
// 3. We're in the normal TabModel OR there are no tabs present in either model
return model.getCount() == 0 && !mOverviewModeBehavior.overviewVisible() && (!incognitoSelected || isIncognitoEmpty);
}
use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class TabWebContentsDelegateAndroid method activateContents.
@Override
public void activateContents() {
boolean activityIsDestroyed = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
activityIsDestroyed = mTab.getActivity().isDestroyed();
}
if (activityIsDestroyed || !mTab.isInitialized()) {
Log.e(TAG, "Activity destroyed before calling activateContents(). Bailing out.");
return;
}
TabModel model = getTabModel();
int index = model.indexOf(mTab);
if (index == TabModel.INVALID_TAB_INDEX)
return;
TabModelUtils.setIndex(model, index);
bringActivityToForeground();
}
use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class ToolbarManager method initializeWithNative.
/**
* Initialize the manager with the components that had native initialization dependencies.
* <p>
* Calling this must occur after the native library have completely loaded.
*
* @param tabModelSelector The selector that handles tab management.
* @param fullscreenManager The manager in charge of interacting with the fullscreen feature.
* @param findToolbarManager The manager for find in page.
* @param overviewModeBehavior The overview mode manager.
* @param layoutDriver A {@link LayoutManager} instance used to watch for scene changes.
*/
public void initializeWithNative(TabModelSelector tabModelSelector, ChromeFullscreenManager fullscreenManager, final FindToolbarManager findToolbarManager, final OverviewModeBehavior overviewModeBehavior, final LayoutManager layoutDriver, OnClickListener tabSwitcherClickHandler, OnClickListener newTabClickHandler, OnClickListener bookmarkClickHandler, OnClickListener customTabsBackClickHandler) {
assert !mInitializedWithNative;
mTabModelSelector = tabModelSelector;
mToolbar.getLocationBar().updateVisualsForState();
mToolbar.getLocationBar().setUrlToPageUrl();
mToolbar.setFullscreenManager(fullscreenManager);
mToolbar.setOnTabSwitcherClickHandler(tabSwitcherClickHandler);
mToolbar.setOnNewTabClickHandler(newTabClickHandler);
mToolbar.setBookmarkClickHandler(bookmarkClickHandler);
mToolbar.setCustomTabCloseClickHandler(customTabsBackClickHandler);
mToolbar.setLayoutUpdateHost(layoutDriver);
mToolbarModel.initializeWithNative();
mToolbar.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
@Override
public void onViewDetachedFromWindow(View v) {
Context context = mToolbar.getContext();
HomepageManager.getInstance(context).removeListener(mHomepageStateListener);
mTabModelSelector.removeObserver(mTabModelSelectorObserver);
for (TabModel model : mTabModelSelector.getModels()) {
model.removeObserver(mTabModelObserver);
}
if (mBookmarkBridge != null) {
mBookmarkBridge.destroy();
mBookmarkBridge = null;
}
if (mTemplateUrlObserver != null) {
TemplateUrlService.getInstance().removeObserver(mTemplateUrlObserver);
mTemplateUrlObserver = null;
}
// Remove all previously attached observers from the FindToolbarManager.
if (mFindToolbarManager != null) {
for (FindToolbarObserver observer : mFindToolbarObservers) {
mFindToolbarManager.removeObserver(observer);
}
}
if (overviewModeBehavior != null) {
overviewModeBehavior.removeOverviewModeObserver(mOverviewModeObserver);
}
if (layoutDriver != null) {
layoutDriver.removeSceneChangeObserver(mSceneChangeObserver);
}
}
@Override
public void onViewAttachedToWindow(View v) {
// As we have only just registered for notifications, any that were sent prior to
// this may have been missed.
// Calling refreshSelectedTab in case we missed the initial selection notification.
refreshSelectedTab();
}
});
mFindToolbarManager = findToolbarManager;
assert fullscreenManager != null;
mFullscreenManager = fullscreenManager;
mNativeLibraryReady = false;
// Add observers to the FindToolbarManager.
if (mFindToolbarManager != null) {
for (FindToolbarObserver observer : mFindToolbarObservers) {
mFindToolbarManager.addObserver(observer);
}
}
if (overviewModeBehavior != null) {
overviewModeBehavior.addOverviewModeObserver(mOverviewModeObserver);
}
if (layoutDriver != null)
layoutDriver.addSceneChangeObserver(mSceneChangeObserver);
onNativeLibraryReady();
mInitializedWithNative = true;
}
Aggregations