| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.Activity; | 9 import android.app.Activity; |
| 10 import android.app.SearchManager; | 10 import android.app.SearchManager; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 import java.util.List; | 96 import java.util.List; |
| 97 import java.util.Map; | 97 import java.util.Map; |
| 98 | 98 |
| 99 /** | 99 /** |
| 100 * Provides a Java-side 'wrapper' around a WebContent (native) instance. | 100 * Provides a Java-side 'wrapper' around a WebContent (native) instance. |
| 101 * Contains all the major functionality necessary to manage the lifecycle of a C
ontentView without | 101 * Contains all the major functionality necessary to manage the lifecycle of a C
ontentView without |
| 102 * being tied to the view system. | 102 * being tied to the view system. |
| 103 */ | 103 */ |
| 104 @JNINamespace("content") | 104 @JNINamespace("content") |
| 105 public class ContentViewCore implements AccessibilityStateChangeListener, Screen
OrientationObserver, | 105 public class ContentViewCore implements AccessibilityStateChangeListener, Screen
OrientationObserver, |
| 106 SystemCaptioningBridge.SystemCaptioningB
ridgeListener { | 106 SystemCaptioningBridge.SystemCaptioningB
ridgeListener, |
| 107 WindowAndroidProvider { |
| 107 private static final String TAG = "cr_ContentViewCore"; | 108 private static final String TAG = "cr_ContentViewCore"; |
| 108 | 109 |
| 109 // Used to avoid enabling zooming in / out if resulting zooming will | 110 // Used to avoid enabling zooming in / out if resulting zooming will |
| 110 // produce little visible difference. | 111 // produce little visible difference. |
| 111 private static final float ZOOM_CONTROLS_EPSILON = 0.007f; | 112 private static final float ZOOM_CONTROLS_EPSILON = 0.007f; |
| 112 | 113 |
| 113 private static final ZoomControlsDelegate NO_OP_ZOOM_CONTROLS_DELEGATE = | 114 private static final ZoomControlsDelegate NO_OP_ZOOM_CONTROLS_DELEGATE = |
| 114 new ZoomControlsDelegate() { | 115 new ZoomControlsDelegate() { |
| 115 @Override | 116 @Override |
| 116 public void invokeZoomPicker() {} | 117 public void invokeZoomPicker() {} |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 // A flag to determine if we enable hover feature or not. | 456 // A flag to determine if we enable hover feature or not. |
| 456 private Boolean mEnableTouchHover; | 457 private Boolean mEnableTouchHover; |
| 457 | 458 |
| 458 // The client that implements Contextual Search functionality, or null if no
ne exists. | 459 // The client that implements Contextual Search functionality, or null if no
ne exists. |
| 459 private ContextualSearchClient mContextualSearchClient; | 460 private ContextualSearchClient mContextualSearchClient; |
| 460 | 461 |
| 461 // NOTE: This object will not be released by Android framework until the mat
ching | 462 // NOTE: This object will not be released by Android framework until the mat
ching |
| 462 // ResultReceiver in the InputMethodService (IME app) gets gc'ed. | 463 // ResultReceiver in the InputMethodService (IME app) gets gc'ed. |
| 463 private ShowKeyboardResultReceiver mShowKeyboardResultReceiver; | 464 private ShowKeyboardResultReceiver mShowKeyboardResultReceiver; |
| 464 | 465 |
| 466 // The list of observers that are notified when ContentViewCore changes its
WindowAndroid. |
| 467 private final ObserverList<WindowAndroidChangedObserver> mWindowAndroidChang
edObservers; |
| 468 |
| 465 /** | 469 /** |
| 466 * @param webContents The {@link WebContents} to find a {@link ContentViewCo
re} of. | 470 * @param webContents The {@link WebContents} to find a {@link ContentViewCo
re} of. |
| 467 * @return A {@link ContentViewCore} that is connected to {@code
webContents} or | 471 * @return A {@link ContentViewCore} that is connected to {@code
webContents} or |
| 468 * {@code null} if none exists. | 472 * {@code null} if none exists. |
| 469 */ | 473 */ |
| 470 public static ContentViewCore fromWebContents(WebContents webContents) { | 474 public static ContentViewCore fromWebContents(WebContents webContents) { |
| 471 return nativeFromWebContentsAndroid(webContents); | 475 return nativeFromWebContentsAndroid(webContents); |
| 472 } | 476 } |
| 473 | 477 |
| 474 /** | 478 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 488 deviceScaleFactor = Float.valueOf(forceScaleFactor); | 492 deviceScaleFactor = Float.valueOf(forceScaleFactor); |
| 489 } | 493 } |
| 490 mRenderCoordinates.setDeviceScaleFactor(deviceScaleFactor); | 494 mRenderCoordinates.setDeviceScaleFactor(deviceScaleFactor); |
| 491 mAccessibilityManager = (AccessibilityManager) | 495 mAccessibilityManager = (AccessibilityManager) |
| 492 getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); | 496 getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); |
| 493 mSystemCaptioningBridge = CaptioningBridgeFactory.getSystemCaptioningBri
dge(mContext); | 497 mSystemCaptioningBridge = CaptioningBridgeFactory.getSystemCaptioningBri
dge(mContext); |
| 494 mGestureStateListeners = new ObserverList<GestureStateListener>(); | 498 mGestureStateListeners = new ObserverList<GestureStateListener>(); |
| 495 mGestureStateListenersIterator = mGestureStateListeners.rewindableIterat
or(); | 499 mGestureStateListenersIterator = mGestureStateListeners.rewindableIterat
or(); |
| 496 | 500 |
| 497 mContainerViewObservers = new ObserverList<ContainerViewObserver>(); | 501 mContainerViewObservers = new ObserverList<ContainerViewObserver>(); |
| 502 mWindowAndroidChangedObservers = new ObserverList<WindowAndroidChangedOb
server>(); |
| 498 } | 503 } |
| 499 | 504 |
| 500 /** | 505 /** |
| 501 * @return The context used for creating this ContentViewCore. | 506 * @return The context used for creating this ContentViewCore. |
| 502 */ | 507 */ |
| 503 @CalledByNative | 508 @CalledByNative |
| 504 public Context getContext() { | 509 public Context getContext() { |
| 505 return mContext; | 510 return mContext; |
| 506 } | 511 } |
| 507 | 512 |
| 508 /** | 513 /** |
| 509 * @return The ViewGroup that all view actions of this ContentViewCore shoul
d interact with. | 514 * @return The ViewGroup that all view actions of this ContentViewCore shoul
d interact with. |
| 510 */ | 515 */ |
| 511 public ViewGroup getContainerView() { | 516 public ViewGroup getContainerView() { |
| 512 return mContainerView; | 517 return mContainerView; |
| 513 } | 518 } |
| 514 | 519 |
| 515 /** | 520 /** |
| 516 * @return The WebContents currently being rendered. | 521 * @return The WebContents currently being rendered. |
| 517 */ | 522 */ |
| 518 public WebContents getWebContents() { | 523 public WebContents getWebContents() { |
| 519 return mWebContents; | 524 return mWebContents; |
| 520 } | 525 } |
| 521 | 526 |
| 522 /** | 527 /** |
| 523 * @return The WindowAndroid associated with this ContentViewCore. | 528 * @return The WindowAndroid associated with this ContentViewCore. |
| 524 */ | 529 */ |
| 530 @Override |
| 525 public WindowAndroid getWindowAndroid() { | 531 public WindowAndroid getWindowAndroid() { |
| 526 if (mNativeContentViewCore == 0) return null; | 532 if (mNativeContentViewCore == 0) return null; |
| 527 return nativeGetJavaWindowAndroid(mNativeContentViewCore); | 533 return nativeGetJavaWindowAndroid(mNativeContentViewCore); |
| 528 } | 534 } |
| 529 | 535 |
| 536 @Override |
| 537 public void addWindowAndroidChangedObserver(WindowAndroidChangedObserver obs
erver) { |
| 538 mWindowAndroidChangedObservers.addObserver(observer); |
| 539 } |
| 540 |
| 541 @Override |
| 542 public void removeWindowAndroidChangedObserver(WindowAndroidChangedObserver
observer) { |
| 543 mWindowAndroidChangedObservers.removeObserver(observer); |
| 544 } |
| 545 |
| 530 /** | 546 /** |
| 531 * | 547 * |
| 532 * @param topControlsHeightPix The height of the top controls in pixel
s. | 548 * @param topControlsHeightPix The height of the top controls in pixel
s. |
| 533 * @param topControlsShrinkBlinkSize The Y amount in pixels to shrink the vi
ewport by. This | 549 * @param topControlsShrinkBlinkSize The Y amount in pixels to shrink the vi
ewport by. This |
| 534 * specifies how much smaller the Blink la
yout size should be | 550 * specifies how much smaller the Blink la
yout size should be |
| 535 * relative to the size of this View. | 551 * relative to the size of this View. |
| 536 */ | 552 */ |
| 537 public void setTopControlsHeight(int topControlsHeightPix, boolean topContro
lsShrinkBlinkSize) { | 553 public void setTopControlsHeight(int topControlsHeightPix, boolean topContro
lsShrinkBlinkSize) { |
| 538 if (topControlsHeightPix == mTopControlsHeightPix | 554 if (topControlsHeightPix == mTopControlsHeightPix |
| 539 && topControlsShrinkBlinkSize == mTopControlsShrinkBlinkSize) { | 555 && topControlsShrinkBlinkSize == mTopControlsShrinkBlinkSize) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 * @param windowAndroid The new {@link WindowAndroid} for this {@link Conten
tViewCore}. | 674 * @param windowAndroid The new {@link WindowAndroid} for this {@link Conten
tViewCore}. |
| 659 */ | 675 */ |
| 660 public void updateWindowAndroid(WindowAndroid windowAndroid) { | 676 public void updateWindowAndroid(WindowAndroid windowAndroid) { |
| 661 long windowNativePointer = windowAndroid == null ? 0 : windowAndroid.get
NativePointer(); | 677 long windowNativePointer = windowAndroid == null ? 0 : windowAndroid.get
NativePointer(); |
| 662 nativeUpdateWindowAndroid(mNativeContentViewCore, windowNativePointer); | 678 nativeUpdateWindowAndroid(mNativeContentViewCore, windowNativePointer); |
| 663 | 679 |
| 664 // TODO(yusufo): Rename this call to be general for tab reparenting. | 680 // TODO(yusufo): Rename this call to be general for tab reparenting. |
| 665 // Clean up cached popups that may have been created with an old activit
y. | 681 // Clean up cached popups that may have been created with an old activit
y. |
| 666 mSelectPopup = null; | 682 mSelectPopup = null; |
| 667 mPastePopupMenu = null; | 683 mPastePopupMenu = null; |
| 684 |
| 685 for (WindowAndroidChangedObserver observer : mWindowAndroidChangedObserv
ers) { |
| 686 observer.onWindowAndroidChanged(windowAndroid); |
| 687 } |
| 668 } | 688 } |
| 669 | 689 |
| 670 /** | 690 /** |
| 671 * Sets a new container view for this {@link ContentViewCore}. | 691 * Sets a new container view for this {@link ContentViewCore}. |
| 672 * | 692 * |
| 673 * <p>WARNING: This method can also be used to replace the existing containe
r view, | 693 * <p>WARNING: This method can also be used to replace the existing containe
r view, |
| 674 * but you should only do it if you have a very good reason to. Replacing th
e | 694 * but you should only do it if you have a very good reason to. Replacing th
e |
| 675 * container view has been designed to support fullscreen in the Webview so
it | 695 * container view has been designed to support fullscreen in the Webview so
it |
| 676 * might not be appropriate for other use cases. | 696 * might not be appropriate for other use cases. |
| 677 * | 697 * |
| (...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3399 String textTrackTextShadow, String textTrackTextSize); | 3419 String textTrackTextShadow, String textTrackTextSize); |
| 3400 | 3420 |
| 3401 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, | 3421 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, |
| 3402 int x, int y, int w, int h); | 3422 int x, int y, int w, int h); |
| 3403 | 3423 |
| 3404 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); | 3424 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); |
| 3405 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo
reImpl); | 3425 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo
reImpl); |
| 3406 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac
tion, int x, int y, | 3426 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac
tion, int x, int y, |
| 3407 int screenX, int screenY, String[] mimeTypes, String content); | 3427 int screenX, int screenY, String[] mimeTypes, String content); |
| 3408 } | 3428 } |
| OLD | NEW |