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);
82 * Called when the WebContents Instant support is disabled.
84 void onWebContentsInstantSupportDisabled();
86 // WebContentsDelegateAndroid methods ---------------------------------------------------------
89 * Called when the contents loading starts.
90 * @param tab The notifying {@link Tab}.
92 void onLoadStarted(Tab tab);
95 * Called when the contents loading stops.
96 * @param tab The notifying {@link Tab}.
98 void onLoadStopped(Tab tab);
101 * Called when the load progress of a {@link Tab} changes.
102 * @param tab The notifying {@link Tab}.
103 * @param progress The new progress from [0,100].
105 void onLoadProgressChanged(Tab tab, int progress);
108 * Called when the URL of a {@link Tab} changes.
109 * @param tab The notifying {@link Tab}.
110 * @param url The new URL.
112 void onUpdateUrl(Tab tab, String url);
115 * Called when the {@link Tab} should enter or leave fullscreen mode.
116 * @param tab The notifying {@link Tab}.
117 * @param enable Whether or not to enter fullscreen mode.
119 void onToggleFullscreenMode(Tab tab, boolean enable);
121 // WebContentsObserver methods ---------------------------------------------------------
124 * Called when an error occurs while loading a page and/or the page fails to load.
125 * @param tab The notifying {@link Tab}.
126 * @param isProvisionalLoad Whether the failed load occurred during the provisional load.
127 * @param isMainFrame Whether failed load happened for the main frame.
128 * @param errorCode Code for the occurring error.
129 * @param description The description for the error.
130 * @param failingUrl The url that was loading when the error occurred.
133 Tab tab, boolean isProvisionalLoad, boolean isMainFrame, int errorCode,
134 String description, String failingUrl);
137 * Called when load is started for a given frame.
138 * @param tab The notifying {@link Tab}.
139 * @param frameId A positive, non-zero integer identifying the navigating frame.
140 * @param parentFrameId The frame identifier of the frame containing the navigating frame,
141 * or -1 if the frame is not contained in another frame.
142 * @param isMainFrame Whether the load is happening for the main frame.
143 * @param validatedUrl The validated URL that is being navigated to.
144 * @param isErrorPage Whether this is navigating to an error page.
145 * @param isIframeSrcdoc Whether this is navigating to about:srcdoc.
147 public void onDidStartProvisionalLoadForFrame(
148 Tab tab, long frameId, long parentFrameId, boolean isMainFrame, String validatedUrl,
149 boolean isErrorPage, boolean isIframeSrcdoc);
152 * Notifies that the provisional load was successfully committed. The RenderViewHost is now
153 * the current RenderViewHost of the WebContents.
155 * @param tab The notifying {@link Tab}.
156 * @param frameId A positive, non-zero integer identifying the navigating frame.
157 * @param isMainFrame Whether the load is happening for the main frame.
158 * @param url The committed URL being navigated to.
159 * @param transitionType The transition type as defined in
160 * {@link org.chromium.ui.base.PageTransitionTypes} for the load.
162 public void onDidCommitProvisionalLoadForFrame(
163 Tab tab, long frameId, boolean isMainFrame, String url, int transitionType);
166 * Called when the main frame of the page has committed.
168 * @param tab The notifying {@link Tab}.
169 * @param url The validated url for the page.
170 * @param baseUrl The validated base url for the page.
171 * @param isNavigationToDifferentPage Whether the main frame navigated to a different page.
172 * @param isFragmentNavigation Whether the main frame navigation did not cause changes
173 * to the document (for example scrolling to a named anchor
175 * @param statusCode The HTTP status code of the navigation.
177 public void onDidNavigateMainFrame(Tab tab, String url, String baseUrl,
178 boolean isNavigationToDifferentPage, boolean isFragmentNavigation, int statusCode);
181 * Called when the theme color is changed
182 * @param color the new color in ARGB format.
184 public void onDidChangeThemeColor(int color);