use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class ToolbarManager method onNativeLibraryReady.
private void onNativeLibraryReady() {
mNativeLibraryReady = true;
mToolbar.onNativeLibraryReady();
final TemplateUrlService templateUrlService = TemplateUrlService.getInstance();
TemplateUrlService.LoadListener mTemplateServiceLoadListener = new TemplateUrlService.LoadListener() {
@Override
public void onTemplateUrlServiceLoaded() {
registerTemplateUrlObserver();
templateUrlService.unregisterLoadListener(this);
}
};
templateUrlService.registerLoadListener(mTemplateServiceLoadListener);
if (templateUrlService.isLoaded()) {
mTemplateServiceLoadListener.onTemplateUrlServiceLoaded();
} else {
templateUrlService.load();
}
mTabModelSelector.addObserver(mTabModelSelectorObserver);
for (TabModel model : mTabModelSelector.getModels()) model.addObserver(mTabModelObserver);
refreshSelectedTab();
if (mTabModelSelector.isTabStateInitialized())
mTabRestoreCompleted = true;
handleTabRestoreCompleted();
}
use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class ActivityTabTaskDescriptionHelper method destroy.
/**
* Destroys all dependent components of the task description helper.
*/
public void destroy() {
mFaviconHelper.destroy();
if (mCurrentTab != null) {
mCurrentTab.removeObserver(mTabObserver);
}
mTabModelSelector.removeObserver(mTabModelSelectorObserver);
for (TabModel model : mTabModelSelector.getModels()) {
model.removeObserver(mTabModelObserver);
}
}
use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class ChromeTabbedActivity method onDestroyInternal.
@Override
public void onDestroyInternal() {
if (mLayoutManager != null)
mLayoutManager.removeOverviewModeObserver(this);
if (mTabModelSelectorTabObserver != null) {
mTabModelSelectorTabObserver.destroy();
mTabModelSelectorTabObserver = null;
}
if (mTabModelObserver != null) {
for (TabModel model : mTabModelSelectorImpl.getModels()) {
model.removeObserver(mTabModelObserver);
}
}
if (mUndoBarPopupController != null) {
mUndoBarPopupController.destroy();
mUndoBarPopupController = null;
}
if (mVrShellDelegate != null) {
mVrShellDelegate.destroyVrShell();
}
super.onDestroyInternal();
}
use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class LayoutManagerChrome method init.
@Override
public void init(TabModelSelector selector, TabCreatorManager creator, TabContentManager content, ViewGroup androidContentContainer, ContextualSearchManagementDelegate contextualSearchDelegate, ReaderModeManagerDelegate readerModeDelegate, DynamicResourceLoader dynamicResourceLoader) {
// TODO: TitleCache should be a part of the ResourceManager.
mTitleCache = mHost.getTitleCache();
// Initialize Layouts
mToolbarSwipeLayout.setTabModelSelector(selector, content);
mOverviewListLayout.setTabModelSelector(selector, content);
if (mOverviewLayout != null)
mOverviewLayout.setTabModelSelector(selector, content);
super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate, readerModeDelegate, dynamicResourceLoader);
mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {
@Override
public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
tabModelSwitched(newModel.isIncognito());
}
};
selector.addObserver(mTabModelSelectorObserver);
selector.setCloseAllTabsDelegate(this);
mTabModelObserver = createTabModelObserver();
for (TabModel model : selector.getModels()) model.addObserver(mTabModelObserver);
mTabSelectorTabObserver = new TabModelSelectorTabObserver(selector) {
@Override
public void onLoadStarted(Tab tab, boolean toDifferentDocument) {
tabLoadStarted(tab.getId(), tab.isIncognito());
}
@Override
public void onLoadStopped(Tab tab, boolean toDifferentDocument) {
tabLoadFinished(tab.getId(), tab.isIncognito());
}
@Override
public void onPageLoadStarted(Tab tab, String url) {
tabPageLoadStarted(tab.getId(), tab.isIncognito());
}
@Override
public void onPageLoadFinished(Tab tab) {
tabPageLoadFinished(tab.getId(), tab.isIncognito());
}
@Override
public void onPageLoadFailed(Tab tab, int errorCode) {
tabPageLoadFinished(tab.getId(), tab.isIncognito());
}
@Override
public void onCrash(Tab tab, boolean sadTabShown) {
tabPageLoadFinished(tab.getId(), tab.isIncognito());
}
};
}
use of org.chromium.chrome.browser.tabmodel.TabModel in project AndroidChromium by JackyAndroid.
the class LayoutManagerChromeTablet method init.
@Override
public void init(TabModelSelector selector, TabCreatorManager creator, TabContentManager content, ViewGroup androidContentContainer, ContextualSearchManagementDelegate contextualSearchDelegate, ReaderModeManagerDelegate readerModeDelegate, DynamicResourceLoader dynamicResourceLoader) {
if (mTabStripLayoutHelperManager != null) {
mTabStripLayoutHelperManager.setTabModelSelector(selector, creator);
}
super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate, readerModeDelegate, dynamicResourceLoader);
mTabObserver = new TabModelSelectorTabObserver(selector) {
@Override
public void onFaviconUpdated(Tab tab, Bitmap icon) {
updateTitle(tab);
}
@Override
public void onTitleUpdated(Tab tab) {
updateTitle(tab);
}
};
// Make sure any tabs already restored get loaded into the title cache.
List<TabModel> models = selector.getModels();
for (int i = 0; i < models.size(); i++) {
TabModel model = models.get(i);
for (int j = 0; j < model.getCount(); j++) {
Tab tab = model.getTabAt(j);
if (tab != null && mTitleCache != null) {
mTitleCache.getUpdatedTitle(tab, mDefaultTitle);
}
}
}
}
Aggregations