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 * Stop any pending navigation.
32 * Inserts css into main frame's document.
34 void insertCSS(String css);
36 * To be called when the ContentView is hidden.
41 * To be called when the ContentView is shown.
46 * Stops all media players for this WebContents.
48 public void releaseMediaPlayers();
51 * Get the Background color from underlying RenderWidgetHost for this WebContent.
53 public int getBackgroundColor();
56 * Requests the renderer insert a link to the specified stylesheet in the
57 * main frame's document.
59 void addStyleSheetByURL(String url);
62 * Shows an interstitial page driven by the passed in delegate.
64 * @param url The URL being blocked by the interstitial.
65 * @param delegate The delegate handling the interstitial.
67 public void showInterstitialPage(
68 String url, long interstitialPageDelegateAndroid);
71 * @return Whether the page is currently showing an interstitial, such as a bad HTTPS page.
73 public boolean isShowingInterstitialPage();
76 * If the view is ready to draw contents to the screen. In hardware mode,
77 * the initialization of the surface texture may not occur until after the
78 * view has been added to the layout. This method will return {@code true}
79 * once the texture is actually ready.
81 public boolean isReady();
84 * Inform WebKit that Fullscreen mode has been exited by the user.
86 public void exitFullscreen();
89 * Changes whether hiding the top controls is enabled.
91 * @param enableHiding Whether hiding the top controls should be enabled or not.
92 * @param enableShowing Whether showing the top controls should be enabled or not.
93 * @param animate Whether the transition should be animated or not.
95 public void updateTopControlsState(boolean enableHiding, boolean enableShowing,
99 * Shows the IME if the focused widget could accept text input.
101 public void showImeIfNeeded();
104 * Brings the Editable to the visible area while IME is up to make easier for inputing text.
106 public void scrollFocusedEditableNodeIntoView();
109 * Selects the word around the caret, if any.
110 * The caller can check if selection actually occurred by listening to OnSelectionChanged.
112 public void selectWordAroundCaret();
115 * Get the URL of the current page.
117 * @return The URL of the current page.
119 public String getUrl();
122 * Get the InCognito state of WebContents.
124 * @return whether this WebContents is in InCognito mode or not
126 public boolean isIncognito();
129 * Resumes the response which is deferred during start.
131 public void resumeResponseDeferredAtStart();
134 * Set pending Navigation for transition testing on this WebContents.
136 public void setHasPendingNavigationTransitionForTesting();
139 * Set delegate for notifying navigation transition.
141 public void setNavigationTransitionDelegate(NavigationTransitionDelegate delegate);
144 * Inserts the provided markup sandboxed into the frame.
146 public void setupTransitionView(String markup);
149 * Hides transition elements specified by the selector, and activates any
150 * exiting-transition stylesheets.
152 public void beginExitTransition(String cssSelector);
155 * Injects the passed Javascript code in the current page and evaluates it.
156 * If a result is required, pass in a callback.
158 * @param script The Javascript to execute.
159 * @param callback The callback to be fired off when a result is ready. The script's
160 * result will be json encoded and passed as the parameter, and the call
161 * will be made on the main thread.
162 * If no result is required, pass null.
164 public void evaluateJavaScript(String script, JavaScriptCallback callback);