Update To 11.40.268.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      * @return Whether this WebContents is loading a resource.
28      */
29     boolean isLoading();
30
31     /**
32      * @return Whether this WebContents is loading and and the load is to a different top-level
33      *         document (rather than being a navigation within the same document).
34      */
35     boolean isLoadingToDifferentDocument();
36
37     /**
38      * Stop any pending navigation.
39      */
40     void stop();
41
42     /**
43      * Inserts css into main frame's document.
44      */
45     void insertCSS(String css);
46     /**
47      * To be called when the ContentView is hidden.
48      */
49     public void onHide();
50
51     /**
52      * To be called when the ContentView is shown.
53      */
54     public void onShow();
55
56     /**
57      * Stops all media players for this WebContents.
58      */
59     public void releaseMediaPlayers();
60
61     /**
62      * Get the Background color from underlying RenderWidgetHost for this WebContent.
63      */
64     public int getBackgroundColor();
65
66     /**
67      * Requests the renderer insert a link to the specified stylesheet in the
68      * main frame's document.
69      */
70     void addStyleSheetByURL(String url);
71
72     /**
73      * Shows an interstitial page driven by the passed in delegate.
74      *
75      * @param url The URL being blocked by the interstitial.
76      * @param delegate The delegate handling the interstitial.
77      */
78     public void showInterstitialPage(
79             String url, long interstitialPageDelegateAndroid);
80
81     /**
82      * @return Whether the page is currently showing an interstitial, such as a bad HTTPS page.
83      */
84     public boolean isShowingInterstitialPage();
85
86     /**
87      * If the view is ready to draw contents to the screen. In hardware mode,
88      * the initialization of the surface texture may not occur until after the
89      * view has been added to the layout. This method will return {@code true}
90      * once the texture is actually ready.
91      */
92     public boolean isReady();
93
94      /**
95      * Inform WebKit that Fullscreen mode has been exited by the user.
96      */
97     public void exitFullscreen();
98
99     /**
100      * Changes whether hiding the top controls is enabled.
101      *
102      * @param enableHiding Whether hiding the top controls should be enabled or not.
103      * @param enableShowing Whether showing the top controls should be enabled or not.
104      * @param animate Whether the transition should be animated or not.
105      */
106     public void updateTopControlsState(boolean enableHiding, boolean enableShowing,
107             boolean animate);
108
109     /**
110      * Shows the IME if the focused widget could accept text input.
111      */
112     public void showImeIfNeeded();
113
114     /**
115      * Brings the Editable to the visible area while IME is up to make easier for inputing text.
116      */
117     public void scrollFocusedEditableNodeIntoView();
118
119     /**
120      * Selects the word around the caret, if any.
121      * The caller can check if selection actually occurred by listening to OnSelectionChanged.
122      */
123     public void selectWordAroundCaret();
124
125     /**
126      * Get the URL of the current page.
127      *
128      * @return The URL of the current page.
129      */
130     public String getUrl();
131
132     /**
133      * Get the InCognito state of WebContents.
134      *
135      * @return whether this WebContents is in InCognito mode or not
136      */
137     public boolean isIncognito();
138
139     /**
140      * Resumes the response which is deferred during start.
141      */
142     public void resumeResponseDeferredAtStart();
143
144     /**
145      * Set pending Navigation for transition testing on this WebContents.
146      */
147     public void setHasPendingNavigationTransitionForTesting();
148
149     /**
150      * Set delegate for notifying navigation transition.
151      */
152     public void setNavigationTransitionDelegate(NavigationTransitionDelegate delegate);
153
154     /**
155      * Inserts the provided markup sandboxed into the frame.
156      */
157     public void setupTransitionView(String markup);
158
159     /**
160      * Hides transition elements specified by the selector, and activates any
161      * exiting-transition stylesheets.
162      */
163     public void beginExitTransition(String cssSelector);
164
165     /**
166      * Clear the navigation transition data.
167      */
168     public void clearNavigationTransitionData();
169
170     /**
171      * Injects the passed Javascript code in the current page and evaluates it.
172      * If a result is required, pass in a callback.
173      *
174      * @param script The Javascript to execute.
175      * @param callback The callback to be fired off when a result is ready. The script's
176      *                 result will be json encoded and passed as the parameter, and the call
177      *                 will be made on the main thread.
178      *                 If no result is required, pass null.
179      */
180     public void evaluateJavaScript(String script, JavaScriptCallback callback);
181
182     /**
183      * Post a message to a frame.
184      * TODO(sgurun) also add support for transferring a message channel port.
185      *
186      * @param frameName The name of the frame. If the name is null the message is posted
187      *                  to the main frame.
188      * @param message   The message
189      * @param sourceOrigin  The source origin
190      * @param targetOrigin  The target origin
191      */
192     public void postMessageToFrame(String frameName, String message,
193             String sourceOrigin, String targetOrigin);
194 }