use of org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType 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);
}
}
Aggregations