Java Code Examples for org.chromium.base.ObserverList.RewindableIterator#hasNext()

The following examples show how to use org.chromium.base.ObserverList.RewindableIterator#hasNext() . 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: TabWebContentsObserver.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void didDetachInterstitialPage() {
    mTab.getInfoBarContainer().setVisibility(View.VISIBLE);
    mTab.updateThemeColorIfNeeded(false);

    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidDetachInterstitialPage(mTab);
    }
    mTab.notifyLoadProgress(mTab.getProgress());

    mTab.updateFullscreenEnabledState();

    if (!mTab.maybeShowNativePage(mTab.getUrl(), false)) {
        mTab.showRenderedPage();
    }
}
 
Example 2
Source File: TabWebContentsObserver.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void didFailLoad(boolean isProvisionalLoad, boolean isMainFrame, int errorCode,
        String description, String failingUrl, boolean wasIgnoredByHandler) {
    mTab.updateThemeColorIfNeeded(true);
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidFailLoad(mTab, isProvisionalLoad, isMainFrame, errorCode,
                description, failingUrl);
    }

    if (isMainFrame) mTab.didFailPageLoad(errorCode);

    PolicyAuditor auditor =
            ((ChromeApplication) mTab.getApplicationContext()).getPolicyAuditor();
    auditor.notifyAuditEvent(mTab.getApplicationContext(), AuditEvent.OPEN_URL_FAILURE,
            failingUrl, description);
    if (errorCode == BLOCKED_BY_ADMINISTRATOR) {
        auditor.notifyAuditEvent(
                mTab.getApplicationContext(), AuditEvent.OPEN_URL_BLOCKED, failingUrl, "");
    }
}
 
Example 3
Source File: TabWebContentsDelegateAndroid.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void navigationStateChanged(int flags) {
    if ((flags & InvalidateTypes.TAB) != 0) {
        int mediaType = MediaCaptureNotificationService.getMediaType(
                isCapturingAudio(), isCapturingVideo(), isCapturingScreen());
        MediaCaptureNotificationService.updateMediaNotificationForTab(
                mTab.getApplicationContext(), mTab.getId(), mediaType, mTab.getUrl());
    }
    if ((flags & InvalidateTypes.TITLE) != 0) {
        // Update cached title then notify observers.
        mTab.updateTitle();
    }
    if ((flags & InvalidateTypes.URL) != 0) {
        RewindableIterator<TabObserver> observers = mTab.getTabObservers();
        while (observers.hasNext()) {
            observers.next().onUrlUpdated(mTab);
        }
    }
}
 
Example 4
Source File: TabWebContentsDelegateAndroid.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void navigationStateChanged(int flags) {
    if ((flags & InvalidateTypes.TAB) != 0) {
        MediaCaptureNotificationService.updateMediaNotificationForTab(
                mTab.getApplicationContext(), mTab.getId(), isCapturingAudio(),
                isCapturingVideo(), mTab.getUrl());
    }
    if ((flags & InvalidateTypes.TITLE) != 0) {
        // Update cached title then notify observers.
        mTab.updateTitle();
    }
    if ((flags & InvalidateTypes.URL) != 0) {
        RewindableIterator<TabObserver> observers = mTab.getTabObservers();
        while (observers.hasNext()) {
            observers.next().onUrlUpdated(mTab);
        }
    }
}
 
Example 5
Source File: TabWebContentsObserver.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void didNavigateMainFrame(String url, String baseUrl,
        boolean isNavigationToDifferentPage, boolean isFragmentNavigation, int statusCode) {
    FullscreenManager fullscreenManager = mTab.getFullscreenManager();
    if (isNavigationToDifferentPage && fullscreenManager != null) {
        fullscreenManager.setPersistentFullscreenMode(false);
    }

    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidNavigateMainFrame(
                mTab, url, baseUrl, isNavigationToDifferentPage,
                isFragmentNavigation, statusCode);
    }

    mTab.stopSwipeRefreshHandler();
}
 
Example 6
Source File: TabWebContentsObserver.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void didNavigateMainFrame(String url, String baseUrl,
        boolean isNavigationToDifferentPage, boolean isFragmentNavigation, int statusCode) {
    FullscreenManager fullscreenManager = mTab.getFullscreenManager();
    if (isNavigationToDifferentPage && fullscreenManager != null) {
        fullscreenManager.setPersistentFullscreenMode(false);
    }

    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidNavigateMainFrame(
                mTab, url, baseUrl, isNavigationToDifferentPage,
                isFragmentNavigation, statusCode);
    }

    mTab.stopSwipeRefreshHandler();
}
 
Example 7
Source File: TabWebContentsObserver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void didFirstVisuallyNonEmptyPaint() {
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().didFirstVisuallyNonEmptyPaint(mTab);
    }
}
 
Example 8
Source File: TabWebContentsDelegateAndroid.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void visibleSSLStateChanged() {
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onSSLStateUpdated(mTab);
    }
}
 
Example 9
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Notify observers when provisional load starts.
 * @param isMainFrame    Whether the load is happening for the main frame.
 * @param validatedUrl   The validated URL that is being navigated to.
 */
void handleDidStartProvisionalLoadForFrame(boolean isMainFrame, String validatedUrl) {
    RewindableIterator<TabObserver> observers = getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidStartProvisionalLoadForFrame(this, isMainFrame, validatedUrl);
    }
}
 
Example 10
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Determines if the theme color has changed and notifies the listeners if it has.
 * @param didWebContentsThemeColorChange If the theme color of the web contents is known to have
 *                                       changed.
 */
void updateThemeColorIfNeeded(boolean didWebContentsThemeColorChange) {
    int themeColor = calculateThemeColor(didWebContentsThemeColorChange);
    if (themeColor == mThemeColor) return;
    mThemeColor = themeColor;
    RewindableIterator<TabObserver> observers = getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidChangeThemeColor(this, themeColor);
    }
}
 
Example 11
Source File: TabWebContentsDelegateAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void visibleSSLStateChanged() {
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onSSLStateUpdated(mTab);
    }
}
 
Example 12
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Toggles fullscreen mode and notifies all observers.
 * @param enableFullscreen Whether fullscreen should be enabled.
 */
public void toggleFullscreenMode(boolean enableFullscreen) {
    if (mFullscreenManager != null) {
        mFullscreenManager.setPersistentFullscreenMode(enableFullscreen);
    }

    RewindableIterator<TabObserver> observers = getTabObservers();
    while (observers.hasNext()) {
        observers.next().onToggleFullscreenMode(this, enableFullscreen);
    }
}
 
Example 13
Source File: TabWebContentsDelegateAndroid.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void toggleFullscreenModeForTab(boolean enableFullscreen) {
    if (mTab.getFullscreenManager() != null) {
        mTab.getFullscreenManager().setPersistentFullscreenMode(enableFullscreen);
    }

    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onToggleFullscreenMode(mTab, enableFullscreen);
    }
}
 
Example 14
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/** Stop the current navigation. */
public void stopLoading() {
    if (isLoading()) {
        RewindableIterator<TabObserver> observers = getTabObservers();
        while (observers.hasNext()) observers.next().onPageLoadFinished(this);
    }
    if (getWebContents() != null) getWebContents().stop();
}
 
Example 15
Source File: TabContextMenuPopulator.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void buildContextMenu(ContextMenu menu, Context context, ContextMenuParams params) {
    mPopulator.buildContextMenu(menu, context, params);
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onContextMenuShown(mTab, menu);
    }
}
 
Example 16
Source File: Tab.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void notifyFaviconChanged() {
    RewindableIterator<TabObserver> observers = getTabObservers();
    while (observers.hasNext()) {
        observers.next().onFaviconUpdated(this, null);
    }
}
 
Example 17
Source File: Tab.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private void notifyPageTitleChanged() {
    RewindableIterator<TabObserver> observers = getTabObservers();
    while (observers.hasNext()) {
        observers.next().onTitleUpdated(this);
    }
}
 
Example 18
Source File: Tab.java    From delion with Apache License 2.0 4 votes vote down vote up
private void notifyPageTitleChanged() {
    RewindableIterator<TabObserver> observers = getTabObservers();
    while (observers.hasNext()) {
        observers.next().onTitleUpdated(this);
    }
}
 
Example 19
Source File: TabWebContentsObserver.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void renderProcessGone(boolean processWasOomProtected) {
    Log.i(TAG, "renderProcessGone() for tab id: " + mTab.getId()
            + ", oom protected: " + Boolean.toString(processWasOomProtected)
            + ", already needs reload: " + Boolean.toString(mTab.needsReload()));
    // Do nothing for subsequent calls that happen while the tab remains crashed. This
    // can occur when the tab is in the background and it shares the renderer with other
    // tabs. After the renderer crashes, the WebContents of its tabs are still around
    // and they still share the RenderProcessHost. When one of the tabs reloads spawning
    // a new renderer for the shared RenderProcessHost and the new renderer crashes
    // again, all tabs sharing this renderer will be notified about the crash (including
    // potential background tabs that did not reload yet).
    if (mTab.needsReload() || mTab.isShowingSadTab()) return;

    // This will replace TabRendererCrashStatus if numbers line up.
    int appState = ApplicationStatus.getStateForApplication();
    boolean applicationRunning = (appState == ApplicationState.HAS_RUNNING_ACTIVITIES);
    boolean applicationPaused = (appState == ApplicationState.HAS_PAUSED_ACTIVITIES);
    @TabRendererExitStatus int rendererExitStatus = TAB_RENDERER_EXIT_STATUS_MAX;
    if (processWasOomProtected) {
        if (applicationRunning) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_RUNNING_APP;
        } else if (applicationPaused) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_PAUSED_APP;
        } else {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_BACKGROUND_APP;
        }
    } else {
        if (applicationRunning) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_RUNNING_APP;
        } else if (applicationPaused) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_PAUSED_APP;
        } else {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_BACKGROUND_APP;
        }
    }
    RecordHistogram.recordEnumeratedHistogram(
            "Tab.RendererExitStatus", rendererExitStatus, TAB_RENDERER_EXIT_STATUS_MAX);

    int activityState = ApplicationStatus.getStateForActivity(
            mTab.getWindowAndroid().getActivity().get());
    int rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_MAX;
    if (!processWasOomProtected
            || activityState == ActivityState.PAUSED
            || activityState == ActivityState.STOPPED
            || activityState == ActivityState.DESTROYED) {
        // The tab crashed in background or was killed by the OS out-of-memory killer.
        //setNeedsReload(true);
        mTab.setNeedsReload(true);
        if (applicationRunning) {
            rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGROUND_APP;
        } else {
            rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGROUND_APP;
        }
    } else {
        rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_APP;
        mTab.showSadTab();
        // This is necessary to correlate histogram data with stability counts.
        UmaSessionStats.logRendererCrash();
    }
    RecordHistogram.recordEnumeratedHistogram(
            "Tab.RendererCrashStatus", rendererCrashStatus, TAB_RENDERER_CRASH_STATUS_MAX);

    mTab.handleTabCrash();

    boolean sadTabShown = mTab.isShowingSadTab();
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onCrash(mTab, sadTabShown);
    }
}
 
Example 20
Source File: TabWebContentsObserver.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void didFinishNavigation(String url, boolean isInMainFrame, boolean isErrorPage,
        boolean hasCommitted, boolean isSameDocument, boolean isFragmentNavigation,
        Integer pageTransition, int errorCode, String errorDescription, int httpStatusCode) {
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidFinishNavigation(mTab, url, isInMainFrame, isErrorPage,
                hasCommitted, isSameDocument, isFragmentNavigation, pageTransition, errorCode,
                httpStatusCode);
    }

    if (errorCode != 0) {
        mTab.updateThemeColorIfNeeded(true);
        if (isInMainFrame) mTab.didFailPageLoad(errorCode);

        recordErrorInPolicyAuditor(url, errorDescription, errorCode);
    }

    if (!hasCommitted) return;
    if (isInMainFrame && UmaUtils.isRunningApplicationStart()) {
        // Current median is 550ms, and long tail is very long. ZoomedIn gives good view of the
        // median and ZoomedOut gives a good overview.
        RecordHistogram.recordCustomTimesHistogram(
                "Startup.FirstCommitNavigationTime2.ZoomedIn",
                SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
                200, 1000, TimeUnit.MILLISECONDS, 100);
        // For ZoomedOut very rarely is it under 50ms and this range matches
        // CustomTabs.IntentToFirstCommitNavigationTime2.ZoomedOut.
        RecordHistogram.recordCustomTimesHistogram(
                "Startup.FirstCommitNavigationTime2.ZoomedOut",
                SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
                50, TimeUnit.MINUTES.toMillis(10), TimeUnit.MILLISECONDS, 50);
        UmaUtils.setRunningApplicationStart(false);
    }

    if (isInMainFrame) {
        mTab.setIsTabStateDirty(true);
        mTab.updateTitle();
        mTab.handleDidFinishNavigation(url, pageTransition);
        mTab.setIsShowingErrorPage(isErrorPage);
    }

    observers.rewind();
    while (observers.hasNext()) {
        observers.next().onUrlUpdated(mTab);
    }

    FullscreenManager fullscreenManager = mTab.getFullscreenManager();
    if (isInMainFrame && !isSameDocument && fullscreenManager != null) {
        fullscreenManager.setPersistentFullscreenMode(false);
    }

    if (isInMainFrame) {
        mTab.stopSwipeRefreshHandler();
    }
}