Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java

Issue 414423002: Removing ContentViewCore dependencies from few functions which acts as direct wrapper to WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restructured WillHandleDeferAfterResponseStarted and DidDeferAfterResponseStarted APIs. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser.webcontents; 5 package org.chromium.content.browser.webcontents;
6 6
7 import org.chromium.base.CalledByNative; 7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace; 8 import org.chromium.base.JNINamespace;
9 import org.chromium.content_public.browser.NavigationController; 9 import org.chromium.content_public.browser.NavigationController;
10 import org.chromium.content_public.browser.WebContents; 10 import org.chromium.content_public.browser.WebContents;
11 11
12 /** 12 /**
13 * The WebContentsImpl Java wrapper to allow communicating with the native WebCo ntentsImpl 13 * The WebContentsImpl Java wrapper to allow communicating with the native WebCo ntentsImpl
14 * object. 14 * object.
15 */ 15 */
16 @JNINamespace("content") 16 @JNINamespace("content")
17 //TODO(tedchoc): Remove the package restriction once this class moves to a non-p ublic content 17 //TODO(tedchoc): Remove the package restriction once this class moves to a non-p ublic content
18 // package whose visibility will be enforced via DEPS. 18 // package whose visibility will be enforced via DEPS.
19 /* package */ class WebContentsImpl implements WebContents { 19 /* package */ class WebContentsImpl implements WebContents {
20 20
21 private long mNativeWebContentsAndroid; 21 private long mNativeWebContentsAndroid;
22 private NavigationController mNavigationController; 22 private NavigationController mNavigationController;
23 23
24 /**
25 * An interface that allows the embedder to be notified of navigation transi tion
26 * related events and respond to them.
27 */
28 public interface NavigationTransitionDelegate {
29 /**
30 * Called when the navigation is deferred immediately after the response started.
31 *
32 * @param enteringColor The background color of the entering document, a s a String
33 * representing a legal CSS color value. This is in serted into
34 * the transition layer's markup after the entering stylesheets
35 * have been applied.
36 */
37 public void didDeferAfterResponseStarted(String enteringColor);
38
39 /**
40 * Called when a navigation transition has been detected, and we need to check
41 * if it's supported.
42 */
43 public boolean willHandleDeferAfterResponseStarted();
44
45 /**
46 * Called when the navigation is deferred immediately after the response
47 * started.
48 */
49 public void addEnteringStylesheetToTransition(String stylesheet);
50
51 /**
52 * Notifies that a navigation transition is started for a given frame.
53 * @param frameId A positive, non-zero integer identifying the navigatin g frame.
54 */
55 public void didStartNavigationTransitionForFrame(long frameId);
56 }
57
58 private NavigationTransitionDelegate mNavigationTransitionDelegate = null;
59
24 private WebContentsImpl( 60 private WebContentsImpl(
25 long nativeWebContentsAndroid, NavigationController navigationContro ller) { 61 long nativeWebContentsAndroid, NavigationController navigationContro ller) {
26 mNativeWebContentsAndroid = nativeWebContentsAndroid; 62 mNativeWebContentsAndroid = nativeWebContentsAndroid;
27 mNavigationController = navigationController; 63 mNavigationController = navigationController;
28 } 64 }
29 65
30 @CalledByNative 66 @CalledByNative
31 private static WebContentsImpl create( 67 private static WebContentsImpl create(
32 long nativeWebContentsAndroid, NavigationController navigationContro ller) { 68 long nativeWebContentsAndroid, NavigationController navigationContro ller) {
33 return new WebContentsImpl(nativeWebContentsAndroid, navigationControlle r); 69 return new WebContentsImpl(nativeWebContentsAndroid, navigationControlle r);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // more efficient to do it this way and sometimes fire an unnecessary me ssage rather 165 // more efficient to do it this way and sometimes fire an unnecessary me ssage rather
130 // than synchronize with the renderer and always have an additional mess age. 166 // than synchronize with the renderer and always have an additional mess age.
131 nativeScrollFocusedEditableNodeIntoView(mNativeWebContentsAndroid); 167 nativeScrollFocusedEditableNodeIntoView(mNativeWebContentsAndroid);
132 } 168 }
133 169
134 @Override 170 @Override
135 public void selectWordAroundCaret() { 171 public void selectWordAroundCaret() {
136 nativeSelectWordAroundCaret(mNativeWebContentsAndroid); 172 nativeSelectWordAroundCaret(mNativeWebContentsAndroid);
137 } 173 }
138 174
175 @Override
176 public String getUrl() {
177 return nativeGetURL(mNativeWebContentsAndroid);
178 }
179
180 @Override
181 public boolean isIncognito() {
182 return nativeIsIncognito(mNativeWebContentsAndroid);
183 }
184
185 @Override
186 public void resumeResponseDeferredAtStart() {
187 nativeResumeResponseDeferredAtStart(mNativeWebContentsAndroid);
188 }
189
190 @Override
191 public void setHasPendingNavigationTransitionForTesting() {
192 nativeSetHasPendingNavigationTransitionForTesting(mNativeWebContentsAnd roid);
193 }
194
195 public void setNavigationTransitionDelegate(NavigationTransitionDelegate del egate) {
196 mNavigationTransitionDelegate = delegate;
197 }
198
199 @CalledByNative
200 private void didDeferAfterResponseStarted(String enteringColor) {
201 if (mNavigationTransitionDelegate != null ) {
202 mNavigationTransitionDelegate.didDeferAfterResponseStarted(enteringC olor);
203 }
204 }
205
206 @CalledByNative
207 private boolean willHandleDeferAfterResponseStarted() {
208 if (mNavigationTransitionDelegate == null) return false;
209 return mNavigationTransitionDelegate.willHandleDeferAfterResponseStarted ();
210 }
211
212 @CalledByNative
213 private void addEnteringStylesheetToTransition(String stylesheet) {
214 if (mNavigationTransitionDelegate != null ) {
215 mNavigationTransitionDelegate.addEnteringStylesheetToTransition(styl esheet);
216 }
217 }
218
139 private native String nativeGetTitle(long nativeWebContentsAndroid); 219 private native String nativeGetTitle(long nativeWebContentsAndroid);
140 private native String nativeGetVisibleURL(long nativeWebContentsAndroid); 220 private native String nativeGetVisibleURL(long nativeWebContentsAndroid);
141 private native void nativeStop(long nativeWebContentsAndroid); 221 private native void nativeStop(long nativeWebContentsAndroid);
142 private native void nativeInsertCSS(long nativeWebContentsAndroid, String cs s); 222 private native void nativeInsertCSS(long nativeWebContentsAndroid, String cs s);
143 private native void nativeOnHide(long nativeWebContentsAndroid); 223 private native void nativeOnHide(long nativeWebContentsAndroid);
144 private native void nativeOnShow(long nativeWebContentsAndroid); 224 private native void nativeOnShow(long nativeWebContentsAndroid);
145 private native int nativeGetBackgroundColor(long nativeWebContentsAndroid); 225 private native int nativeGetBackgroundColor(long nativeWebContentsAndroid);
146 private native void nativeAddStyleSheetByURL(long nativeWebContentsAndroid, 226 private native void nativeAddStyleSheetByURL(long nativeWebContentsAndroid,
147 String url); 227 String url);
148 private native void nativeShowInterstitialPage(long nativeWebContentsAndroid , 228 private native void nativeShowInterstitialPage(long nativeWebContentsAndroid ,
149 String url, long nativeInterstitialPageDelegateAndroid); 229 String url, long nativeInterstitialPageDelegateAndroid);
150 private native boolean nativeIsShowingInterstitialPage(long nativeWebContent sAndroid); 230 private native boolean nativeIsShowingInterstitialPage(long nativeWebContent sAndroid);
151 private native boolean nativeIsRenderWidgetHostViewReady(long nativeWebConte ntsAndroid); 231 private native boolean nativeIsRenderWidgetHostViewReady(long nativeWebConte ntsAndroid);
152 private native void nativeExitFullscreen(long nativeWebContentsAndroid); 232 private native void nativeExitFullscreen(long nativeWebContentsAndroid);
153 private native void nativeUpdateTopControlsState(long nativeWebContentsAndro id, 233 private native void nativeUpdateTopControlsState(long nativeWebContentsAndro id,
154 boolean enableHiding, boolean enableShowing, boolean animate); 234 boolean enableHiding, boolean enableShowing, boolean animate);
155 private native void nativeShowImeIfNeeded(long nativeWebContentsAndroid); 235 private native void nativeShowImeIfNeeded(long nativeWebContentsAndroid);
156 private native void nativeScrollFocusedEditableNodeIntoView(long nativeWebCo ntentsAndroid); 236 private native void nativeScrollFocusedEditableNodeIntoView(long nativeWebCo ntentsAndroid);
157 private native void nativeSelectWordAroundCaret(long nativeWebContentsAndroi d); 237 private native void nativeSelectWordAroundCaret(long nativeWebContentsAndroi d);
238 private native String nativeGetURL(long nativeWebContentsAndroid);
239 private native boolean nativeIsIncognito(long nativeWebContentsAndroid);
240 private native void nativeResumeResponseDeferredAtStart(long nativeWebConten tsAndroid);
241 private native void nativeSetHasPendingNavigationTransitionForTesting(
242 long nativeWebContentsAndroid);
158 } 243 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698