Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / android / java / src / org / chromium / chrome / browser / TabObserver.java
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.
4
5 package org.chromium.chrome.browser;
6
7 import android.view.ContextMenu;
8
9 import org.chromium.content.browser.ContentView;
10
11 /**
12  * An observer that is notified of changes to a {@link TabBase} object.
13  */
14 public interface TabObserver {
15
16     /**
17      * Called when a {@link TabBase} is being destroyed.
18      * @param tab The notifying {@link TabBase}.
19      */
20     void onDestroyed(TabBase tab);
21
22     /**
23      * Called when the tab content changes (to/from native pages or swapping native WebContents).
24      * @param tab The notifying {@link TabBase}.
25      */
26     void onContentChanged(TabBase tab);
27
28     /**
29      * Called when the favicon of a {@link TabBase} has been updated.
30      * @param tab The notifying {@link TabBase}.
31      */
32     void onFaviconUpdated(TabBase tab);
33
34     /**
35      * Called when the title of a {@link TabBase} changes.
36      * @param tab The notifying {@link TabBase}.
37      */
38     void onTitleUpdated(TabBase tab);
39
40     /**
41      * Called when the URL of a {@link TabBase} changes.
42      * @param tab The notifying {@link TabBase}.
43      */
44     void onUrlUpdated(TabBase tab);
45
46     /**
47      * Called when the WebContents of a {@link TabBase} have been swapped.
48      * @param tab The notifying {@link TabBase}.
49      * @param didStartLoad Whether WebContentsObserver::DidStartProvisionalLoadForFrame() has
50      *     already been called.
51      * @param didFinishLoad Whether WebContentsObserver::DidFinishLoad() has already been called.
52      */
53     void onWebContentsSwapped(TabBase tab, boolean didStartLoad, boolean didFinishLoad);
54
55     /**
56      * Called when a context menu is shown for a {@link ContentView} owned by a {@link TabBase}.
57      * @param tab  The notifying {@link TabBase}.
58      * @param menu The {@link ContextMenu} that is being shown.
59      */
60     void onContextMenuShown(TabBase tab, ContextMenu menu);
61
62     // WebContentsDelegateAndroid methods ---------------------------------------------------------
63
64     /**
65      * Called when the load progress of a {@link TabBase} changes.
66      * @param tab      The notifying {@link TabBase}.
67      * @param progress The new progress from [0,100].
68      */
69     void onLoadProgressChanged(TabBase tab, int progress);
70
71     /**
72      * Called when the URL of a {@link TabBase} changes.
73      * @param tab The notifying {@link TabBase}.
74      * @param url The new URL.
75      */
76     void onUpdateUrl(TabBase tab, String url);
77
78     /**
79      * Called when the {@link TabBase} should enter or leave fullscreen mode.
80      * @param tab    The notifying {@link TabBase}.
81      * @param enable Whether or not to enter fullscreen mode.
82      */
83     void onToggleFullscreenMode(TabBase tab, boolean enable);
84
85     // WebContentsObserverAndroid methods ---------------------------------------------------------
86
87     /**
88      * Called when an error occurs while loading a page and/or the page fails to load.
89      * @param tab               The notifying {@link TabBase}.
90      * @param isProvisionalLoad Whether the failed load occurred during the provisional load.
91      * @param isMainFrame       Whether failed load happened for the main frame.
92      * @param errorCode         Code for the occurring error.
93      * @param description       The description for the error.
94      * @param failingUrl        The url that was loading when the error occurred.
95      */
96     void onDidFailLoad(TabBase tab, boolean isProvisionalLoad, boolean isMainFrame, int errorCode,
97             String description, String failingUrl);
98
99 }