OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.graphics.Canvas; | 10 import android.graphics.Canvas; |
(...skipping 17 matching lines...) Expand all Loading... |
28 import org.chromium.base.JNINamespace; | 28 import org.chromium.base.JNINamespace; |
29 import org.chromium.base.WeakContext; | 29 import org.chromium.base.WeakContext; |
30 import org.chromium.content.app.AppResource; | 30 import org.chromium.content.app.AppResource; |
31 import org.chromium.content.browser.accessibility.AccessibilityInjector; | 31 import org.chromium.content.browser.accessibility.AccessibilityInjector; |
32 import org.chromium.content.browser.ContentViewGestureHandler; | 32 import org.chromium.content.browser.ContentViewGestureHandler; |
33 import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegat
e; | 33 import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegat
e; |
34 import org.chromium.content.browser.TouchPoint; | 34 import org.chromium.content.browser.TouchPoint; |
35 import org.chromium.content.browser.ZoomManager; | 35 import org.chromium.content.browser.ZoomManager; |
36 import org.chromium.content.common.CleanupReference; | 36 import org.chromium.content.common.CleanupReference; |
37 import org.chromium.content.common.TraceEvent; | 37 import org.chromium.content.common.TraceEvent; |
| 38 import org.chromium.ui.gfx.NativeWindow; |
38 | 39 |
39 /** | 40 /** |
40 * Provides a Java-side 'wrapper' around a WebContent (native) instance. | 41 * Provides a Java-side 'wrapper' around a WebContent (native) instance. |
41 * Contains all the major functionality necessary to manage the lifecycle of a C
ontentView without | 42 * Contains all the major functionality necessary to manage the lifecycle of a C
ontentView without |
42 * being tied to the view system. | 43 * being tied to the view system. |
43 */ | 44 */ |
44 @JNINamespace("content") | 45 @JNINamespace("content") |
45 public class ContentViewCore implements MotionEventDelegate { | 46 public class ContentViewCore implements MotionEventDelegate { |
46 private static final String TAG = ContentViewCore.class.getName(); | 47 private static final String TAG = ContentViewCore.class.getName(); |
47 | 48 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 305 } |
305 | 306 |
306 /** | 307 /** |
307 * | 308 * |
308 * @param containerView The view that will act as a container for all views
created by this. | 309 * @param containerView The view that will act as a container for all views
created by this. |
309 * @param internalDispatcher Handles dispatching all hidden or super methods
to the | 310 * @param internalDispatcher Handles dispatching all hidden or super methods
to the |
310 * containerView. | 311 * containerView. |
311 * @param takeOwnershipOfWebContents Whether this object will take ownership
of | 312 * @param takeOwnershipOfWebContents Whether this object will take ownership
of |
312 * nativeWebContents over on its native si
de. | 313 * nativeWebContents over on its native si
de. |
313 * @param nativeWebContents A pointer to the native web contents. | 314 * @param nativeWebContents A pointer to the native web contents. |
| 315 * @param nativeWindow An instance of the NativeWindow. |
314 * @param isAccessFromFileURLsGrantedByDefault Default WebSettings configura
tion. | 316 * @param isAccessFromFileURLsGrantedByDefault Default WebSettings configura
tion. |
315 */ | 317 */ |
316 // Perform important post-construction set up of the ContentViewCore. | 318 // Perform important post-construction set up of the ContentViewCore. |
317 // We do not require the containing view in the constructor to allow embedde
rs to create a | 319 // We do not require the containing view in the constructor to allow embedde
rs to create a |
318 // ContentViewCore without having fully created it's containing view. The co
ntaining view | 320 // ContentViewCore without having fully created it's containing view. The co
ntaining view |
319 // is a vital component of the ContentViewCore, so embedders must exercise c
aution in what | 321 // is a vital component of the ContentViewCore, so embedders must exercise c
aution in what |
320 // they do with the ContentViewCore before calling initialize(). | 322 // they do with the ContentViewCore before calling initialize(). |
321 // We supply the nativeWebContents pointer here rather than in the construct
or to allow us | 323 // We supply the nativeWebContents pointer here rather than in the construct
or to allow us |
322 // to set the private browsing mode at a later point for the WebView impleme
ntation. | 324 // to set the private browsing mode at a later point for the WebView impleme
ntation. |
323 public void initialize(ViewGroup containerView, InternalAccessDelegate inter
nalDispatcher, | 325 public void initialize(ViewGroup containerView, InternalAccessDelegate inter
nalDispatcher, |
324 boolean takeOwnershipOfWebContents, int nativeWebContents, | 326 boolean takeOwnershipOfWebContents, int nativeWebContents, NativeWin
dow nativeWindow, |
325 boolean isAccessFromFileURLsGrantedByDefault) { | 327 boolean isAccessFromFileURLsGrantedByDefault) { |
326 mContainerView = containerView; | 328 mContainerView = containerView; |
327 mNativeContentViewCore = nativeInit(mHardwareAccelerated, takeOwnershipO
fWebContents, | 329 mNativeContentViewCore = nativeInit(mHardwareAccelerated, takeOwnershipO
fWebContents, |
328 nativeWebContents); | 330 nativeWebContents, nativeWindow.getNativePointer()); |
329 mCleanupReference = new CleanupReference( | 331 mCleanupReference = new CleanupReference( |
330 this, new DestroyRunnable(mNativeContentViewCore)); | 332 this, new DestroyRunnable(mNativeContentViewCore)); |
331 mContentSettings = new ContentSettings( | 333 mContentSettings = new ContentSettings( |
332 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau
lt); | 334 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau
lt); |
333 initializeContainerView(internalDispatcher); | 335 initializeContainerView(internalDispatcher); |
334 if (mPersonality == PERSONALITY_VIEW) { | 336 if (mPersonality == PERSONALITY_VIEW) { |
335 setAllUserAgentOverridesInHistory(); | 337 setAllUserAgentOverridesInHistory(); |
336 } | 338 } |
337 | 339 |
338 String contentDescription = "Web View"; | 340 String contentDescription = "Web View"; |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 public NavigationHistory getNavigationHistory() { | 1322 public NavigationHistory getNavigationHistory() { |
1321 NavigationHistory history = new NavigationHistory(); | 1323 NavigationHistory history = new NavigationHistory(); |
1322 int currentIndex = nativeGetNavigationHistory(mNativeContentViewCore, hi
story); | 1324 int currentIndex = nativeGetNavigationHistory(mNativeContentViewCore, hi
story); |
1323 history.setCurrentEntryIndex(currentIndex); | 1325 history.setCurrentEntryIndex(currentIndex); |
1324 return history; | 1326 return history; |
1325 } | 1327 } |
1326 | 1328 |
1327 // The following methods are implemented at native side. | 1329 // The following methods are implemented at native side. |
1328 | 1330 |
1329 private native int nativeInit(boolean hardwareAccelerated, boolean takeOwner
shipOfWebContents, | 1331 private native int nativeInit(boolean hardwareAccelerated, boolean takeOwner
shipOfWebContents, |
1330 int webContentsPtr); | 1332 int webContentsPtr, int windowAndroidPtr); |
1331 | 1333 |
1332 private static native void nativeDestroy(int nativeContentViewCore); | 1334 private static native void nativeDestroy(int nativeContentViewCore); |
1333 | 1335 |
1334 private native void nativeLoadUrl( | 1336 private native void nativeLoadUrl( |
1335 int nativeContentViewCoreImpl, | 1337 int nativeContentViewCoreImpl, |
1336 String url, | 1338 String url, |
1337 int loadUrlType, | 1339 int loadUrlType, |
1338 int transitionType, | 1340 int transitionType, |
1339 int uaOverrideOption, | 1341 int uaOverrideOption, |
1340 String extraHeaders, | 1342 String extraHeaders, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 | 1418 |
1417 private native int nativeGetNativeImeAdapter(int nativeContentViewCore); | 1419 private native int nativeGetNativeImeAdapter(int nativeContentViewCore); |
1418 | 1420 |
1419 private native void nativeAddJavascriptInterface(int nativeContentViewCoreIm
pl, Object object, | 1421 private native void nativeAddJavascriptInterface(int nativeContentViewCoreIm
pl, Object object, |
1420 String name, boolean requir
eAnnotation); | 1422 String name, boolean requir
eAnnotation); |
1421 | 1423 |
1422 private native void nativeRemoveJavascriptInterface(int nativeContentViewCor
eImpl, String name); | 1424 private native void nativeRemoveJavascriptInterface(int nativeContentViewCor
eImpl, String name); |
1423 | 1425 |
1424 private native int nativeGetNavigationHistory(int nativeContentViewCoreImpl,
Object context); | 1426 private native int nativeGetNavigationHistory(int nativeContentViewCoreImpl,
Object context); |
1425 } | 1427 } |
OLD | NEW |