Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / public / android / java / src / org / chromium / content_public / browser / WebContents.java
1 // Copyright 2014 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.content_public.browser;
6
7 /**
8  * The WebContents Java wrapper to allow communicating with the native WebContents object.
9  */
10 public interface WebContents {
11     /**
12      * @return The navigation controller associated with this WebContents.
13      */
14     NavigationController getNavigationController();
15
16     /**
17      * @return The title for the current visible page.
18      */
19     String getTitle();
20
21     /**
22      * @return The URL for the current visible page.
23      */
24     String getVisibleUrl();
25
26     /**
27      * Stop any pending navigation.
28      */
29     void stop();
30
31     /**
32      * Inserts css into main frame's document.
33      */
34     void insertCSS(String css);
35     /**
36      * To be called when the ContentView is hidden.
37      */
38     public void onHide();
39
40     /**
41      * To be called when the ContentView is shown.
42      */
43     public void onShow();
44
45     /**
46      * Get the Background color from underlying RenderWidgetHost for this WebContent.
47      */
48     public int getBackgroundColor();
49
50     /**
51      * Requests the renderer insert a link to the specified stylesheet in the
52      * main frame's document.
53      */
54     void addStyleSheetByURL(String url);
55
56     /**
57      * Shows an interstitial page driven by the passed in delegate.
58      *
59      * @param url The URL being blocked by the interstitial.
60      * @param delegate The delegate handling the interstitial.
61      */
62     public void showInterstitialPage(
63             String url, long interstitialPageDelegateAndroid);
64
65     /**
66      * @return Whether the page is currently showing an interstitial, such as a bad HTTPS page.
67      */
68     public boolean isShowingInterstitialPage();
69
70     /**
71      * If the view is ready to draw contents to the screen. In hardware mode,
72      * the initialization of the surface texture may not occur until after the
73      * view has been added to the layout. This method will return {@code true}
74      * once the texture is actually ready.
75      */
76     public boolean isReady();
77
78      /**
79      * Inform WebKit that Fullscreen mode has been exited by the user.
80      */
81     public void exitFullscreen();
82
83     /**
84      * Changes whether hiding the top controls is enabled.
85      *
86      * @param enableHiding Whether hiding the top controls should be enabled or not.
87      * @param enableShowing Whether showing the top controls should be enabled or not.
88      * @param animate Whether the transition should be animated or not.
89      */
90     public void updateTopControlsState(boolean enableHiding, boolean enableShowing,
91             boolean animate);
92
93     /**
94      * Shows the IME if the focused widget could accept text input.
95      */
96     public void showImeIfNeeded();
97
98     /**
99      * Brings the Editable to the visible area while IME is up to make easier for inputing text.
100      */
101     public void scrollFocusedEditableNodeIntoView();
102
103     /**
104      * Selects the word around the caret, if any.
105      * The caller can check if selection actually occurred by listening to OnSelectionChanged.
106      */
107     public void selectWordAroundCaret();
108
109     /**
110      * Get the URL of the current page.
111      *
112      * @return The URL of the current page.
113      */
114     public String getUrl();
115
116     /**
117      * Get the InCognito state of WebContents.
118      *
119      * @return whether this WebContents is in InCognito mode or not
120      */
121     public boolean isIncognito();
122
123     /**
124      * Resumes the response which is deferred during start.
125      */
126     public void resumeResponseDeferredAtStart();
127
128     /**
129      * Set pending Navigation for transition testing on this WebContents.
130      */
131     public void setHasPendingNavigationTransitionForTesting();
132
133     /**
134      * Set delegate for notifying navigation transition.
135      */
136     public void setNavigationTransitionDelegate(NavigationTransitionDelegate delegate);
137
138     /**
139      * Inserts the provided markup sandboxed into the frame.
140      */
141     public void setupTransitionView(String markup);
142
143     /**
144      * Hides transition elements specified by the selector, and activates any
145      * exiting-transition stylesheets.
146      */
147     public void beginExitTransition(String cssSelector);
148
149     /**
150      * Injects the passed Javascript code in the current page and evaluates it.
151      * If a result is required, pass in a callback.
152      *
153      * @param script The Javascript to execute.
154      * @param callback The callback to be fired off when a result is ready. The script's
155      *                 result will be json encoded and passed as the parameter, and the call
156      *                 will be made on the main thread.
157      *                 If no result is required, pass null.
158      * @param startRenderer Tells whether to start Renderer or not for initial empty document
159      */
160     public void evaluateJavaScript(String script, JavaScriptCallback callback,
161             boolean startRenderer);
162
163 }