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.
5 package org.chromium.content_public.browser;
8 * The WebContents Java wrapper to allow communicating with the native WebContents object.
10 public interface WebContents {
12 * @return The navigation controller associated with this WebContents.
14 NavigationController getNavigationController();
17 * @return The title for the current visible page.
22 * @return The URL for the current visible page.
24 String getVisibleUrl();
27 * @return Whether this WebContents is loading a resource.
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).
35 boolean isLoadingToDifferentDocument();
38 * Stop any pending navigation.
43 * Inserts css into main frame's document.
45 void insertCSS(String css);
47 * To be called when the ContentView is hidden.
52 * To be called when the ContentView is shown.
57 * Stops all media players for this WebContents.
59 public void releaseMediaPlayers();
62 * Get the Background color from underlying RenderWidgetHost for this WebContent.
64 public int getBackgroundColor();
67 * Requests the renderer insert a link to the specified stylesheet in the
68 * main frame's document.
70 void addStyleSheetByURL(String url);
73 * Shows an interstitial page driven by the passed in delegate.
75 * @param url The URL being blocked by the interstitial.
76 * @param delegate The delegate handling the interstitial.
78 public void showInterstitialPage(
79 String url, long interstitialPageDelegateAndroid);
82 * @return Whether the page is currently showing an interstitial, such as a bad HTTPS page.
84 public boolean isShowingInterstitialPage();
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.
92 public boolean isReady();
95 * Inform WebKit that Fullscreen mode has been exited by the user.
97 public void exitFullscreen();
100 * Changes whether hiding the top controls is enabled.
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.
106 public void updateTopControlsState(boolean enableHiding, boolean enableShowing,
110 * Shows the IME if the focused widget could accept text input.
112 public void showImeIfNeeded();
115 * Brings the Editable to the visible area while IME is up to make easier for inputing text.
117 public void scrollFocusedEditableNodeIntoView();
120 * Selects the word around the caret, if any.
121 * The caller can check if selection actually occurred by listening to OnSelectionChanged.
123 public void selectWordAroundCaret();
126 * Get the URL of the current page.
128 * @return The URL of the current page.
130 public String getUrl();
133 * Get the InCognito state of WebContents.
135 * @return whether this WebContents is in InCognito mode or not
137 public boolean isIncognito();
140 * Resumes the response which is deferred during start.
142 public void resumeResponseDeferredAtStart();
145 * Set pending Navigation for transition testing on this WebContents.
147 public void setHasPendingNavigationTransitionForTesting();
150 * Set delegate for notifying navigation transition.
152 public void setNavigationTransitionDelegate(NavigationTransitionDelegate delegate);
155 * Inserts the provided markup sandboxed into the frame.
157 public void setupTransitionView(String markup);
160 * Hides transition elements specified by the selector, and activates any
161 * exiting-transition stylesheets.
163 public void beginExitTransition(String cssSelector);
166 * Clear the navigation transition data.
168 public void clearNavigationTransitionData();
171 * Injects the passed Javascript code in the current page and evaluates it.
172 * If a result is required, pass in a callback.
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.
180 public void evaluateJavaScript(String script, JavaScriptCallback callback);
183 * Post a message to a frame.
184 * TODO(sgurun) also add support for transferring a message channel port.
186 * @param frameName The name of the frame. If the name is null the message is posted
188 * @param message The message
189 * @param sourceOrigin The source origin
190 * @param targetOrigin The target origin
192 public void postMessageToFrame(String frameName, String message,
193 String sourceOrigin, String targetOrigin);