Java Code Examples for org.chromium.chrome.browser.tab.Tab#removeObserver()

The following examples show how to use org.chromium.chrome.browser.tab.Tab#removeObserver() . 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: ToolbarManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Call to tear down all of the toolbar dependencies.
 */
public void destroy() {
    Tab currentTab = mToolbarModel.getTab();
    if (currentTab != null) currentTab.removeObserver(mTabObserver);
    mFindToolbarObservers.clear();
    mToolbar.destroy();
}
 
Example 2
Source File: OfflinePageTabObserver.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Removes the observer for a tab with the specified tabId.
 * @param tab tab that was observed.
 */
void stopObservingTab(Tab tab) {
    // If we are observing the tab, stop.
    if (isObservingTab(tab)) {
        mObservedTabs.remove(tab.getId());
        tab.removeObserver(this);
    }

    // If there are not longer any tabs being observed, stop listening for network changes.
    if (mObservedTabs.isEmpty() && isObservingNetworkChanges()) {
        stopObservingNetworkChanges();
        mIsObservingNetworkChanges = false;
    }
}
 
Example 3
Source File: ToolbarManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Call to tear down all of the toolbar dependencies.
 */
public void destroy() {
    Tab currentTab = mToolbarModel.getTab();
    if (currentTab != null) currentTab.removeObserver(mTabObserver);
    mFindToolbarObservers.clear();
    mToolbar.destroy();
}
 
Example 4
Source File: OfflinePageTabObserver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Removes the observer for a tab with the specified tabId.
 * @param tab tab that was observed.
 */
void stopObservingTab(Tab tab) {
    // If we are observing the tab, stop.
    if (isObservingTab(tab)) {
        mObservedTabs.remove(tab.getId());
        tab.removeObserver(this);
    }

    // If there are not longer any tabs being observed, stop listening for network changes.
    if (mObservedTabs.isEmpty() && isObservingNetworkChanges()) {
        stopObservingNetworkChanges();
        mIsObservingNetworkChanges = false;
    }
}
 
Example 5
Source File: OfflinePageTabObserver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void destroy() {
    mTabModelObserver.destroy();
    if (!mObservedTabs.isEmpty()) {
        for (Integer tabId : mObservedTabs.keySet()) {
            Tab tab = mTabModelSelector.getTabById(tabId);
            if (tab == null) continue;
            tab.removeObserver(this);
        }
        mObservedTabs.clear();
    }
    if (isObservingNetworkChanges()) {
        stopObservingNetworkChanges();
        mIsObservingNetworkChanges = false;
    }
}
 
Example 6
Source File: ToolbarManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Call to tear down all of the toolbar dependencies.
 */
public void destroy() {
    Tab currentTab = mToolbarModel.getTab();
    if (currentTab != null) currentTab.removeObserver(mTabObserver);
    mFindToolbarObservers.clear();
    mToolbar.destroy();
}
 
Example 7
Source File: OfflinePageTabObserver.java    From delion with Apache License 2.0 4 votes vote down vote up
public void removeObserver(Tab tab, TabObserver observer) {
    if (tab != null && observer != null) {
        tab.removeObserver(observer);
    }
}
 
Example 8
Source File: NewTabPageUma.java    From delion with Apache License 2.0 4 votes vote down vote up
private void endRecording(Tab removeObserverFromTab) {
    if (removeObserverFromTab != null) removeObserverFromTab.removeObserver(this);
    RecordUserAction.record("MobileNTP.Snippets.VisitEnd");
    RecordHistogram.recordLongTimesHistogram("NewTabPage.Snippets.VisitDuration",
            SystemClock.elapsedRealtime() - mStartTimeNs, TimeUnit.MILLISECONDS);
}
 
Example 9
Source File: CustomTabActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void tabRemoved(Tab tab) {
    tab.removeObserver(mTabObserver);
    PageLoadMetrics.removeObserver(mMetricsObserver);
}
 
Example 10
Source File: NewTabPageUma.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void endRecording(Tab removeObserverFromTab) {
    if (removeObserverFromTab != null) removeObserverFromTab.removeObserver(this);
    RecordUserAction.record("MobileNTP.Snippets.VisitEnd");
    long visitTimeMs = SystemClock.elapsedRealtime() - mStartTimeMs;
    SnippetsBridge.onSuggestionTargetVisited(mCategory, visitTimeMs);
}
 
Example 11
Source File: CustomTabActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void tabRemoved(Tab tab) {
    tab.removeObserver(mTabObserver);
    PageLoadMetrics.removeObserver(mMetricsObserver);
}
 
Example 12
Source File: NewTabPageUma.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private void endRecording(Tab removeObserverFromTab) {
    if (removeObserverFromTab != null) removeObserverFromTab.removeObserver(this);
    RecordUserAction.record("MobileNTP.Snippets.VisitEnd");
    long visitTimeMs = SystemClock.elapsedRealtime() - mStartTimeMs;
    SuggestionsEventReporterBridge.onSuggestionTargetVisited(mCategory, visitTimeMs);
}