Upstream version 5.34.92.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      */
50     void onWebContentsSwapped(TabBase tab);
51
52     /**
53      * Called when a context menu is shown for a {@link ContentView} owned by a {@link TabBase}.
54      * @param tab  The notifying {@link TabBase}.
55      * @param menu The {@link ContextMenu} that is being shown.
56      */
57     void onContextMenuShown(TabBase tab, ContextMenu menu);
58
59     // WebContentsDelegateAndroid methods ---------------------------------------------------------
60
61     /**
62      * Called when the load progress of a {@link TabBase} changes.
63      * @param tab      The notifying {@link TabBase}.
64      * @param progress The new progress from [0,100].
65      */
66     void onLoadProgressChanged(TabBase tab, int progress);
67
68     /**
69      * Called when the URL of a {@link TabBase} changes.
70      * @param tab The notifying {@link TabBase}.
71      * @param url The new URL.
72      */
73     void onUpdateUrl(TabBase tab, String url);
74
75     /**
76      * Called when the {@link TabBase} should enter or leave fullscreen mode.
77      * @param tab    The notifying {@link TabBase}.
78      * @param enable Whether or not to enter fullscreen mode.
79      */
80     void onToggleFullscreenMode(TabBase tab, boolean enable);
81
82     // WebContentsObserverAndroid methods ---------------------------------------------------------
83
84     /**
85      * Called when an error occurs while loading a page and/or the page fails to load.
86      * @param tab               The notifying {@link TabBase}.
87      * @param isProvisionalLoad Whether the failed load occurred during the provisional load.
88      * @param isMainFrame       Whether failed load happened for the main frame.
89      * @param errorCode         Code for the occurring error.
90      * @param description       The description for the error.
91      * @param failingUrl        The url that was loading when the error occurred.
92      */
93     void onDidFailLoad(TabBase tab, boolean isProvisionalLoad, boolean isMainFrame, int errorCode,
94             String description, String failingUrl);
95
96 }