use of org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver 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);
}
}
}
}
use of org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver in project AndroidChromium by JackyAndroid.
the class ContextReporter method enable.
/**
* Starts reporting context.
*/
public void enable() {
Tab currentTab = mActivity.getActivityTab();
reportUsageOfCurrentContextIfPossible(currentTab, false, null);
TabModelSelector selector = mActivity.getTabModelSelector();
assert selector != null;
if (mSelectorTabObserver == null) {
mSelectorTabObserver = new TabModelSelectorTabObserver(selector) {
@Override
public void onTitleUpdated(Tab tab) {
// Report usage declaring this as a title change.
reportUsageOfCurrentContextIfPossible(tab, true, null);
}
@Override
public void onUrlUpdated(Tab tab) {
reportUsageOfCurrentContextIfPossible(tab, false, null);
}
};
}
if (mModelObserver == null) {
assert !selector.getModels().isEmpty();
mModelObserver = new EmptyTabModelObserver() {
@Override
public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
reportUsageOfCurrentContextIfPossible(tab, false, null);
}
};
for (TabModel model : selector.getModels()) {
model.addObserver(mModelObserver);
}
}
if (mContextualSearchObserver == null && mActivity.getContextualSearchManager() != null) {
mContextualSearchObserver = new ContextualSearchObserver() {
@Override
public void onShowContextualSearch(GSAContextDisplaySelection contextSelection) {
if (contextSelection != null)
reportDisplaySelection(contextSelection);
}
@Override
public void onHideContextualSearch() {
reportDisplaySelection(null);
}
};
mActivity.getContextualSearchManager().addObserver(mContextualSearchObserver);
}
}
use of org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver in project AndroidChromium by JackyAndroid.
the class UmaSessionStats method startNewSession.
/**
* 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();
}
Aggregations