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 * Stops all media players for this WebContents. 47 */ 48 public void releaseMediaPlayers(); 49 50 /** 51 * Get the Background color from underlying RenderWidgetHost for this WebContent. 52 */ 53 public int getBackgroundColor(); 54 55 /** 56 * Requests the renderer insert a link to the specified stylesheet in the 57 * main frame's document. 58 */ 59 void addStyleSheetByURL(String url); 60 61 /** 62 * Shows an interstitial page driven by the passed in delegate. 63 * 64 * @param url The URL being blocked by the interstitial. 65 * @param delegate The delegate handling the interstitial. 66 */ 67 public void showInterstitialPage( 68 String url, long interstitialPageDelegateAndroid); 69 70 /** 71 * @return Whether the page is currently showing an interstitial, such as a bad HTTPS page. 72 */ 73 public boolean isShowingInterstitialPage(); 74 75 /** 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. 80 */ 81 public boolean isReady(); 82 83 /** 84 * Inform WebKit that Fullscreen mode has been exited by the user. 85 */ 86 public void exitFullscreen(); 87 88 /** 89 * Changes whether hiding the top controls is enabled. 90 * 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. 94 */ 95 public void updateTopControlsState(boolean enableHiding, boolean enableShowing, 96 boolean animate); 97 98 /** 99 * Shows the IME if the focused widget could accept text input. 100 */ 101 public void showImeIfNeeded(); 102 103 /** 104 * Brings the Editable to the visible area while IME is up to make easier for inputing text. 105 */ 106 public void scrollFocusedEditableNodeIntoView(); 107 108 /** 109 * Selects the word around the caret, if any. 110 * The caller can check if selection actually occurred by listening to OnSelectionChanged. 111 */ 112 public void selectWordAroundCaret(); 113 114 /** 115 * Get the URL of the current page. 116 * 117 * @return The URL of the current page. 118 */ 119 public String getUrl(); 120 121 /** 122 * Get the InCognito state of WebContents. 123 * 124 * @return whether this WebContents is in InCognito mode or not 125 */ 126 public boolean isIncognito(); 127 128 /** 129 * Resumes the response which is deferred during start. 130 */ 131 public void resumeResponseDeferredAtStart(); 132 133 /** 134 * Set pending Navigation for transition testing on this WebContents. 135 */ 136 public void setHasPendingNavigationTransitionForTesting(); 137 138 /** 139 * Set delegate for notifying navigation transition. 140 */ 141 public void setNavigationTransitionDelegate(NavigationTransitionDelegate delegate); 142 143 /** 144 * Inserts the provided markup sandboxed into the frame. 145 */ 146 public void setupTransitionView(String markup); 147 148 /** 149 * Hides transition elements specified by the selector, and activates any 150 * exiting-transition stylesheets. 151 */ 152 public void beginExitTransition(String cssSelector); 153 154 /** 155 * Injects the passed Javascript code in the current page and evaluates it. 156 * If a result is required, pass in a callback. 157 * 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. 163 */ 164 public void evaluateJavaScript(String script, JavaScriptCallback callback); 165 166 } 167