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 * Get the Background color from underlying RenderWidgetHost for this WebContent.
48 public int getBackgroundColor();
51 * Requests the renderer insert a link to the specified stylesheet in the
52 * main frame's document.
54 void addStyleSheetByURL(String url);
57 * Shows an interstitial page driven by the passed in delegate.
59 * @param url The URL being blocked by the interstitial.
60 * @param delegate The delegate handling the interstitial.
62 public void showInterstitialPage(
63 String url, long interstitialPageDelegateAndroid);
66 * @return Whether the page is currently showing an interstitial, such as a bad HTTPS page.
68 public boolean isShowingInterstitialPage();
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.
76 public boolean isReady();
79 * Inform WebKit that Fullscreen mode has been exited by the user.
81 public void exitFullscreen();
84 * Changes whether hiding the top controls is enabled.
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.
90 public void updateTopControlsState(boolean enableHiding, boolean enableShowing,
94 * Shows the IME if the focused widget could accept text input.
96 public void showImeIfNeeded();
99 * Brings the Editable to the visible area while IME is up to make easier for inputing text.
101 public void scrollFocusedEditableNodeIntoView();
104 * Selects the word around the caret, if any.
105 * The caller can check if selection actually occurred by listening to OnSelectionChanged.
107 public void selectWordAroundCaret();
110 * Get the URL of the current page.
112 * @return The URL of the current page.
114 public String getUrl();
117 * Get the InCognito state of WebContents.
119 * @return whether this WebContents is in InCognito mode or not
121 public boolean isIncognito();
124 * Resumes the response which is deferred during start.
126 public void resumeResponseDeferredAtStart();
129 * Set pending Navigation for transition testing on this WebContents.
131 public void setHasPendingNavigationTransitionForTesting();
134 * Set delegate for notifying navigation transition.
136 public void setNavigationTransitionDelegate(NavigationTransitionDelegate delegate);
139 * Inserts the provided markup sandboxed into the frame.
141 public void setupTransitionView(String markup);
144 * Hides transition elements specified by the selector, and activates any
145 * exiting-transition stylesheets.
147 public void beginExitTransition(String cssSelector);
150 * Injects the passed Javascript code in the current page and evaluates it.
151 * If a result is required, pass in a callback.
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
160 public void evaluateJavaScript(String script, JavaScriptCallback callback,
161 boolean startRenderer);