OLD | NEW |
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.NavigationTransitionDelegate; |
10 import org.chromium.content_public.browser.WebContents; | 11 import org.chromium.content_public.browser.WebContents; |
11 | 12 |
12 /** | 13 /** |
13 * The WebContentsImpl Java wrapper to allow communicating with the native WebCo
ntentsImpl | 14 * The WebContentsImpl Java wrapper to allow communicating with the native WebCo
ntentsImpl |
14 * object. | 15 * object. |
15 */ | 16 */ |
16 @JNINamespace("content") | 17 @JNINamespace("content") |
17 //TODO(tedchoc): Remove the package restriction once this class moves to a non-p
ublic content | 18 //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. | 19 // package whose visibility will be enforced via DEPS. |
19 /* package */ class WebContentsImpl implements WebContents { | 20 /* package */ class WebContentsImpl implements WebContents { |
20 | 21 |
21 private long mNativeWebContentsAndroid; | 22 private long mNativeWebContentsAndroid; |
22 private NavigationController mNavigationController; | 23 private NavigationController mNavigationController; |
23 | 24 |
| 25 private NavigationTransitionDelegate mNavigationTransitionDelegate = null; |
| 26 |
24 private WebContentsImpl( | 27 private WebContentsImpl( |
25 long nativeWebContentsAndroid, NavigationController navigationContro
ller) { | 28 long nativeWebContentsAndroid, NavigationController navigationContro
ller) { |
26 mNativeWebContentsAndroid = nativeWebContentsAndroid; | 29 mNativeWebContentsAndroid = nativeWebContentsAndroid; |
27 mNavigationController = navigationController; | 30 mNavigationController = navigationController; |
28 } | 31 } |
29 | 32 |
30 @CalledByNative | 33 @CalledByNative |
31 private static WebContentsImpl create( | 34 private static WebContentsImpl create( |
32 long nativeWebContentsAndroid, NavigationController navigationContro
ller) { | 35 long nativeWebContentsAndroid, NavigationController navigationContro
ller) { |
33 return new WebContentsImpl(nativeWebContentsAndroid, navigationControlle
r); | 36 return new WebContentsImpl(nativeWebContentsAndroid, navigationControlle
r); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // more efficient to do it this way and sometimes fire an unnecessary me
ssage rather | 132 // 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. | 133 // than synchronize with the renderer and always have an additional mess
age. |
131 nativeScrollFocusedEditableNodeIntoView(mNativeWebContentsAndroid); | 134 nativeScrollFocusedEditableNodeIntoView(mNativeWebContentsAndroid); |
132 } | 135 } |
133 | 136 |
134 @Override | 137 @Override |
135 public void selectWordAroundCaret() { | 138 public void selectWordAroundCaret() { |
136 nativeSelectWordAroundCaret(mNativeWebContentsAndroid); | 139 nativeSelectWordAroundCaret(mNativeWebContentsAndroid); |
137 } | 140 } |
138 | 141 |
| 142 @Override |
| 143 public String getUrl() { |
| 144 return nativeGetURL(mNativeWebContentsAndroid); |
| 145 } |
| 146 |
| 147 @Override |
| 148 public boolean isIncognito() { |
| 149 return nativeIsIncognito(mNativeWebContentsAndroid); |
| 150 } |
| 151 |
| 152 @Override |
| 153 public void resumeResponseDeferredAtStart() { |
| 154 nativeResumeResponseDeferredAtStart(mNativeWebContentsAndroid); |
| 155 } |
| 156 |
| 157 @Override |
| 158 public void setHasPendingNavigationTransitionForTesting() { |
| 159 nativeSetHasPendingNavigationTransitionForTesting(mNativeWebContentsAnd
roid); |
| 160 } |
| 161 |
| 162 @Override |
| 163 public void setNavigationTransitionDelegate(NavigationTransitionDelegate del
egate) { |
| 164 mNavigationTransitionDelegate = delegate; |
| 165 } |
| 166 |
| 167 /** |
| 168 * Inserts the provided markup sandboxed into the frame. |
| 169 */ |
| 170 public void setupTransitionView(String markup) { |
| 171 nativeSetupTransitionView(mNativeWebContentsAndroid, markup); |
| 172 } |
| 173 |
| 174 /** |
| 175 * Hides transition elements specified by the selector, and activates any |
| 176 * exiting-transition stylesheets. |
| 177 */ |
| 178 public void beginExitTransition(String cssSelector) { |
| 179 nativeBeginExitTransition(mNativeWebContentsAndroid, cssSelector); |
| 180 } |
| 181 |
| 182 @CalledByNative |
| 183 private void didDeferAfterResponseStarted(String markup, String cssSelector, |
| 184 String enteringColor) { |
| 185 if (mNavigationTransitionDelegate != null ) { |
| 186 mNavigationTransitionDelegate.didDeferAfterResponseStarted(markup, |
| 187 cssSelector, enteringColor); |
| 188 } |
| 189 } |
| 190 |
| 191 @CalledByNative |
| 192 private boolean willHandleDeferAfterResponseStarted() { |
| 193 if (mNavigationTransitionDelegate == null) return false; |
| 194 return mNavigationTransitionDelegate.willHandleDeferAfterResponseStarted
(); |
| 195 } |
| 196 |
| 197 @CalledByNative |
| 198 private void addEnteringStylesheetToTransition(String stylesheet) { |
| 199 if (mNavigationTransitionDelegate != null ) { |
| 200 mNavigationTransitionDelegate.addEnteringStylesheetToTransition(styl
esheet); |
| 201 } |
| 202 } |
| 203 |
| 204 @CalledByNative |
| 205 private void didStartNavigationTransitionForFrame(long frameId) { |
| 206 if (mNavigationTransitionDelegate != null ) { |
| 207 mNavigationTransitionDelegate.didStartNavigationTransitionForFrame(f
rameId); |
| 208 } |
| 209 } |
| 210 |
139 private native String nativeGetTitle(long nativeWebContentsAndroid); | 211 private native String nativeGetTitle(long nativeWebContentsAndroid); |
140 private native String nativeGetVisibleURL(long nativeWebContentsAndroid); | 212 private native String nativeGetVisibleURL(long nativeWebContentsAndroid); |
141 private native void nativeStop(long nativeWebContentsAndroid); | 213 private native void nativeStop(long nativeWebContentsAndroid); |
142 private native void nativeInsertCSS(long nativeWebContentsAndroid, String cs
s); | 214 private native void nativeInsertCSS(long nativeWebContentsAndroid, String cs
s); |
143 private native void nativeOnHide(long nativeWebContentsAndroid); | 215 private native void nativeOnHide(long nativeWebContentsAndroid); |
144 private native void nativeOnShow(long nativeWebContentsAndroid); | 216 private native void nativeOnShow(long nativeWebContentsAndroid); |
145 private native int nativeGetBackgroundColor(long nativeWebContentsAndroid); | 217 private native int nativeGetBackgroundColor(long nativeWebContentsAndroid); |
146 private native void nativeAddStyleSheetByURL(long nativeWebContentsAndroid, | 218 private native void nativeAddStyleSheetByURL(long nativeWebContentsAndroid, |
147 String url); | 219 String url); |
148 private native void nativeShowInterstitialPage(long nativeWebContentsAndroid
, | 220 private native void nativeShowInterstitialPage(long nativeWebContentsAndroid
, |
149 String url, long nativeInterstitialPageDelegateAndroid); | 221 String url, long nativeInterstitialPageDelegateAndroid); |
150 private native boolean nativeIsShowingInterstitialPage(long nativeWebContent
sAndroid); | 222 private native boolean nativeIsShowingInterstitialPage(long nativeWebContent
sAndroid); |
151 private native boolean nativeIsRenderWidgetHostViewReady(long nativeWebConte
ntsAndroid); | 223 private native boolean nativeIsRenderWidgetHostViewReady(long nativeWebConte
ntsAndroid); |
152 private native void nativeExitFullscreen(long nativeWebContentsAndroid); | 224 private native void nativeExitFullscreen(long nativeWebContentsAndroid); |
153 private native void nativeUpdateTopControlsState(long nativeWebContentsAndro
id, | 225 private native void nativeUpdateTopControlsState(long nativeWebContentsAndro
id, |
154 boolean enableHiding, boolean enableShowing, boolean animate); | 226 boolean enableHiding, boolean enableShowing, boolean animate); |
155 private native void nativeShowImeIfNeeded(long nativeWebContentsAndroid); | 227 private native void nativeShowImeIfNeeded(long nativeWebContentsAndroid); |
156 private native void nativeScrollFocusedEditableNodeIntoView(long nativeWebCo
ntentsAndroid); | 228 private native void nativeScrollFocusedEditableNodeIntoView(long nativeWebCo
ntentsAndroid); |
157 private native void nativeSelectWordAroundCaret(long nativeWebContentsAndroi
d); | 229 private native void nativeSelectWordAroundCaret(long nativeWebContentsAndroi
d); |
| 230 private native String nativeGetURL(long nativeWebContentsAndroid); |
| 231 private native boolean nativeIsIncognito(long nativeWebContentsAndroid); |
| 232 private native void nativeResumeResponseDeferredAtStart(long nativeWebConten
tsAndroid); |
| 233 private native void nativeSetHasPendingNavigationTransitionForTesting( |
| 234 long nativeWebContentsAndroid); |
| 235 private native void nativeSetupTransitionView(long nativeWebContentsAndroid, |
| 236 String markup); |
| 237 private native void nativeBeginExitTransition(long nativeWebContentsAndroid, |
| 238 String cssSelector); |
158 } | 239 } |
OLD | NEW |