1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.chrome.browser;
7 import android.view.ContextMenu;
9 import org.chromium.content.browser.ContentViewCore;
12 * An observer that is notified of changes to a {@link Tab} object.
14 public interface TabObserver {
17 * Called when a {@link Tab} is being destroyed.
18 * @param tab The notifying {@link Tab}.
20 void onDestroyed(Tab tab);
23 * Called when the tab content changes (to/from native pages or swapping native WebContents).
24 * @param tab The notifying {@link Tab}.
26 void onContentChanged(Tab tab);
29 * Called when loadUrl is triggered on a a {@link Tab}.
30 * @param tab The notifying {@link Tab}.
31 * @param url The url that is being loaded.
32 * @param loadType The type of load that was performed.
34 * @see TabLoadStatus#PAGE_LOAD_FAILED
35 * @see TabLoadStatus#DEFAULT_PAGE_LOAD
36 * @see TabLoadStatus#PARTIAL_PRERENDERED_PAGE_LOAD
37 * @see TabLoadStatus#FULL_PRERENDERED_PAGE_LOAD
39 void onLoadUrl(Tab tab, String url, int loadType);
42 * Called when the favicon of a {@link Tab} has been updated.
43 * @param tab The notifying {@link Tab}.
45 void onFaviconUpdated(Tab tab);
48 * Called when the title of a {@link Tab} changes.
49 * @param tab The notifying {@link Tab}.
51 void onTitleUpdated(Tab tab);
54 * Called when the URL of a {@link Tab} changes.
55 * @param tab The notifying {@link Tab}.
57 void onUrlUpdated(Tab tab);
60 * Called when the SSL state of a {@link Tab} changes.
61 * @param tab The notifying {@link Tab}.
63 void onSSLStateUpdated(Tab tab);
66 * Called when the WebContents of a {@link Tab} have been swapped.
67 * @param tab The notifying {@link Tab}.
68 * @param didStartLoad Whether WebContentsObserver::DidStartProvisionalLoadForFrame() has
69 * already been called.
70 * @param didFinishLoad Whether WebContentsObserver::DidFinishLoad() has already been called.
72 void onWebContentsSwapped(Tab tab, boolean didStartLoad, boolean didFinishLoad);
75 * Called when a context menu is shown for a {@link ContentViewCore} owned by a {@link Tab}.
76 * @param tab The notifying {@link Tab}.
77 * @param menu The {@link ContextMenu} that is being shown.
79 void onContextMenuShown(Tab tab, ContextMenu menu);
81 // WebContentsDelegateAndroid methods ---------------------------------------------------------
84 * Called when the contents loading starts.
85 * @param tab The notifying {@link Tab}.
87 void onLoadStarted(Tab tab);
90 * Called when the contents loading stops.
91 * @param tab The notifying {@link Tab}.
93 void onLoadStopped(Tab tab);
96 * Called when the load progress of a {@link Tab} changes.
97 * @param tab The notifying {@link Tab}.
98 * @param progress The new progress from [0,100].
100 void onLoadProgressChanged(Tab tab, int progress);
103 * Called when the URL of a {@link Tab} changes.
104 * @param tab The notifying {@link Tab}.
105 * @param url The new URL.
107 void onUpdateUrl(Tab tab, String url);
110 * Called when the {@link Tab} should enter or leave fullscreen mode.
111 * @param tab The notifying {@link Tab}.
112 * @param enable Whether or not to enter fullscreen mode.
114 void onToggleFullscreenMode(Tab tab, boolean enable);
116 // WebContentsObserverAndroid methods ---------------------------------------------------------
119 * Called when an error occurs while loading a page and/or the page fails to load.
120 * @param tab The notifying {@link Tab}.
121 * @param isProvisionalLoad Whether the failed load occurred during the provisional load.
122 * @param isMainFrame Whether failed load happened for the main frame.
123 * @param errorCode Code for the occurring error.
124 * @param description The description for the error.
125 * @param failingUrl The url that was loading when the error occurred.
128 Tab tab, boolean isProvisionalLoad, boolean isMainFrame, int errorCode,
129 String description, String failingUrl);
132 * Called when load is started for a given frame.
133 * @param tab The notifying {@link Tab}.
134 * @param frameId A positive, non-zero integer identifying the navigating frame.
135 * @param parentFrameId The frame identifier of the frame containing the navigating frame,
136 * or -1 if the frame is not contained in another frame.
137 * @param isMainFrame Whether the load is happening for the main frame.
138 * @param validatedUrl The validated URL that is being navigated to.
139 * @param isErrorPage Whether this is navigating to an error page.
140 * @param isIframeSrcdoc Whether this is navigating to about:srcdoc.
142 public void onDidStartProvisionalLoadForFrame(
143 Tab tab, long frameId, long parentFrameId, boolean isMainFrame, String validatedUrl,
144 boolean isErrorPage, boolean isIframeSrcdoc);
147 * Called when the brand color is changed
148 * @param color the new color in ARGB format.
150 public void onDidChangeBrandColor(int color);