| 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 android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 9 import android.graphics.Rect; | 9 import android.graphics.Rect; |
| 10 import android.os.Bundle; | 10 import android.os.Bundle; |
| 11 import android.os.Handler; | 11 import android.os.Handler; |
| 12 import android.os.Message; | 12 import android.os.Message; |
| 13 import android.os.Parcel; | 13 import android.os.Parcel; |
| 14 import android.os.ParcelUuid; | 14 import android.os.ParcelUuid; |
| 15 import android.os.Parcelable; | 15 import android.os.Parcelable; |
| 16 | 16 |
| 17 import org.chromium.base.ThreadUtils; | 17 import org.chromium.base.ThreadUtils; |
| 18 import org.chromium.base.VisibleForTesting; | 18 import org.chromium.base.VisibleForTesting; |
| 19 import org.chromium.base.annotations.CalledByNative; | 19 import org.chromium.base.annotations.CalledByNative; |
| 20 import org.chromium.base.annotations.JNINamespace; | 20 import org.chromium.base.annotations.JNINamespace; |
| 21 import org.chromium.content.browser.AppWebMessagePort; | 21 import org.chromium.content.browser.AppWebMessagePort; |
| 22 import org.chromium.content.browser.MediaSessionImpl; | 22 import org.chromium.content.browser.MediaSessionImpl; |
| 23 import org.chromium.content_public.browser.AccessibilitySnapshotCallback; | 23 import org.chromium.content_public.browser.AccessibilitySnapshotCallback; |
| 24 import org.chromium.content_public.browser.AccessibilitySnapshotNode; | 24 import org.chromium.content_public.browser.AccessibilitySnapshotNode; |
| 25 import org.chromium.content_public.browser.ContentBitmapCallback; | 25 import org.chromium.content_public.browser.ContentBitmapCallback; |
| 26 import org.chromium.content_public.browser.ImageDownloadCallback; | 26 import org.chromium.content_public.browser.ImageDownloadCallback; |
| 27 import org.chromium.content_public.browser.JavaScriptCallback; | 27 import org.chromium.content_public.browser.JavaScriptCallback; |
| 28 import org.chromium.content_public.browser.MessagePort; | 28 import org.chromium.content_public.browser.MessagePort; |
| 29 import org.chromium.content_public.browser.NavigationController; | 29 import org.chromium.content_public.browser.NavigationController; |
| 30 import org.chromium.content_public.browser.RenderFrameHost; |
| 31 import org.chromium.content_public.browser.RenderFrameHostDelegate; |
| 30 import org.chromium.content_public.browser.SmartClipCallback; | 32 import org.chromium.content_public.browser.SmartClipCallback; |
| 31 import org.chromium.content_public.browser.WebContents; | 33 import org.chromium.content_public.browser.WebContents; |
| 32 import org.chromium.content_public.browser.WebContentsObserver; | 34 import org.chromium.content_public.browser.WebContentsObserver; |
| 33 import org.chromium.ui.OverscrollRefreshHandler; | 35 import org.chromium.ui.OverscrollRefreshHandler; |
| 34 import org.chromium.ui.accessibility.AXTextStyle; | 36 import org.chromium.ui.accessibility.AXTextStyle; |
| 35 | 37 |
| 36 import java.util.ArrayList; | 38 import java.util.ArrayList; |
| 37 import java.util.List; | 39 import java.util.List; |
| 38 import java.util.UUID; | 40 import java.util.UUID; |
| 39 | 41 |
| 40 /** | 42 /** |
| 41 * The WebContentsImpl Java wrapper to allow communicating with the native WebCo
ntentsImpl | 43 * The WebContentsImpl Java wrapper to allow communicating with the native WebCo
ntentsImpl |
| 42 * object. | 44 * object. |
| 43 */ | 45 */ |
| 44 @JNINamespace("content") | 46 @JNINamespace("content") |
| 45 //TODO(tedchoc): Remove the package restriction once this class moves to a non-p
ublic content | 47 // TODO(tedchoc): Remove the package restriction once this class moves to a non-
public content |
| 46 // package whose visibility will be enforced via DEPS. | 48 // package whose visibility will be enforced via DEPS. |
| 47 /* package */ class WebContentsImpl implements WebContents { | 49 /* package */ class WebContentsImpl implements WebContents, RenderFrameHostDeleg
ate { |
| 48 private static final String PARCEL_VERSION_KEY = "version"; | 50 private static final String PARCEL_VERSION_KEY = "version"; |
| 49 private static final String PARCEL_WEBCONTENTS_KEY = "webcontents"; | 51 private static final String PARCEL_WEBCONTENTS_KEY = "webcontents"; |
| 50 private static final String PARCEL_PROCESS_GUARD_KEY = "processguard"; | 52 private static final String PARCEL_PROCESS_GUARD_KEY = "processguard"; |
| 51 | 53 |
| 52 private static final long PARCELABLE_VERSION_ID = 0; | 54 private static final long PARCELABLE_VERSION_ID = 0; |
| 53 // Non-final for testing purposes, so resetting of the UUID can happen. | 55 // Non-final for testing purposes, so resetting of the UUID can happen. |
| 54 private static UUID sParcelableUUID = UUID.randomUUID(); | 56 private static UUID sParcelableUUID = UUID.randomUUID(); |
| 55 | 57 |
| 56 /** | 58 /** |
| 57 * Used to reset the internal tracking for whether or not a serialized {@lin
k WebContents} | 59 * Used to reset the internal tracking for whether or not a serialized {@lin
k WebContents} |
| (...skipping 28 matching lines...) Expand all Loading... |
| 86 } | 88 } |
| 87 | 89 |
| 88 @Override | 90 @Override |
| 89 public WebContents[] newArray(int size) { | 91 public WebContents[] newArray(int size) { |
| 90 return new WebContents[size]; | 92 return new WebContents[size]; |
| 91 } | 93 } |
| 92 }; | 94 }; |
| 93 | 95 |
| 94 private long mNativeWebContentsAndroid; | 96 private long mNativeWebContentsAndroid; |
| 95 private NavigationController mNavigationController; | 97 private NavigationController mNavigationController; |
| 98 private RenderFrameHost mMainFrame; |
| 96 | 99 |
| 97 // Lazily created proxy observer for handling all Java-based WebContentsObse
rvers. | 100 // Lazily created proxy observer for handling all Java-based WebContentsObse
rvers. |
| 98 private WebContentsObserverProxy mObserverProxy; | 101 private WebContentsObserverProxy mObserverProxy; |
| 99 | 102 |
| 100 // The media session for this WebContents. It is constructed by the native M
ediaSession and has | 103 // The media session for this WebContents. It is constructed by the native M
ediaSession and has |
| 101 // the same life time as native MediaSession. | 104 // the same life time as native MediaSession. |
| 102 private MediaSessionImpl mMediaSession; | 105 private MediaSessionImpl mMediaSession; |
| 103 | 106 |
| 104 private SmartClipCallback mSmartClipCallback; | 107 private SmartClipCallback mSmartClipCallback; |
| 105 | 108 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 public boolean isDestroyed() { | 162 public boolean isDestroyed() { |
| 160 return mNativeWebContentsAndroid == 0; | 163 return mNativeWebContentsAndroid == 0; |
| 161 } | 164 } |
| 162 | 165 |
| 163 @Override | 166 @Override |
| 164 public NavigationController getNavigationController() { | 167 public NavigationController getNavigationController() { |
| 165 return mNavigationController; | 168 return mNavigationController; |
| 166 } | 169 } |
| 167 | 170 |
| 168 @Override | 171 @Override |
| 172 public RenderFrameHost getMainFrame() { |
| 173 if (mMainFrame == null) { |
| 174 mMainFrame = nativeGetMainFrame(mNativeWebContentsAndroid); |
| 175 } |
| 176 return mMainFrame; |
| 177 } |
| 178 |
| 179 @Override |
| 169 public String getTitle() { | 180 public String getTitle() { |
| 170 return nativeGetTitle(mNativeWebContentsAndroid); | 181 return nativeGetTitle(mNativeWebContentsAndroid); |
| 171 } | 182 } |
| 172 | 183 |
| 173 @Override | 184 @Override |
| 174 public String getVisibleUrl() { | 185 public String getVisibleUrl() { |
| 175 return nativeGetVisibleURL(mNativeWebContentsAndroid); | 186 return nativeGetVisibleURL(mNativeWebContentsAndroid); |
| 176 } | 187 } |
| 177 | 188 |
| 178 @Override | 189 @Override |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 @CalledByNative | 556 @CalledByNative |
| 546 private static List<Rect> createSizeList() { | 557 private static List<Rect> createSizeList() { |
| 547 return new ArrayList<Rect>(); | 558 return new ArrayList<Rect>(); |
| 548 } | 559 } |
| 549 | 560 |
| 550 @CalledByNative | 561 @CalledByNative |
| 551 private static void createSizeAndAddToList(List<Rect> sizes, int width, int
height) { | 562 private static void createSizeAndAddToList(List<Rect> sizes, int width, int
height) { |
| 552 sizes.add(new Rect(0, 0, width, height)); | 563 sizes.add(new Rect(0, 0, width, height)); |
| 553 } | 564 } |
| 554 | 565 |
| 566 @Override |
| 567 public WebContents getAsWebContents() { |
| 568 return this; |
| 569 } |
| 570 |
| 555 // This is static to avoid exposing a public destroy method on the native si
de of this class. | 571 // This is static to avoid exposing a public destroy method on the native si
de of this class. |
| 556 private static native void nativeDestroyWebContents(long webContentsAndroidP
tr); | 572 private static native void nativeDestroyWebContents(long webContentsAndroidP
tr); |
| 557 | 573 |
| 558 private static native WebContents nativeFromNativePtr(long webContentsAndroi
dPtr); | 574 private static native WebContents nativeFromNativePtr(long webContentsAndroi
dPtr); |
| 559 | 575 |
| 576 private native RenderFrameHost nativeGetMainFrame(long nativeWebContentsAndr
oid); |
| 560 private native String nativeGetTitle(long nativeWebContentsAndroid); | 577 private native String nativeGetTitle(long nativeWebContentsAndroid); |
| 561 private native String nativeGetVisibleURL(long nativeWebContentsAndroid); | 578 private native String nativeGetVisibleURL(long nativeWebContentsAndroid); |
| 562 private native boolean nativeIsLoading(long nativeWebContentsAndroid); | 579 private native boolean nativeIsLoading(long nativeWebContentsAndroid); |
| 563 private native boolean nativeIsLoadingToDifferentDocument(long nativeWebCont
entsAndroid); | 580 private native boolean nativeIsLoadingToDifferentDocument(long nativeWebCont
entsAndroid); |
| 564 private native void nativeStop(long nativeWebContentsAndroid); | 581 private native void nativeStop(long nativeWebContentsAndroid); |
| 565 private native void nativeCut(long nativeWebContentsAndroid); | 582 private native void nativeCut(long nativeWebContentsAndroid); |
| 566 private native void nativeCopy(long nativeWebContentsAndroid); | 583 private native void nativeCopy(long nativeWebContentsAndroid); |
| 567 private native void nativePaste(long nativeWebContentsAndroid); | 584 private native void nativePaste(long nativeWebContentsAndroid); |
| 568 private native void nativeReplace(long nativeWebContentsAndroid, String word
); | 585 private native void nativeReplace(long nativeWebContentsAndroid, String word
); |
| 569 private native void nativeSelectAll(long nativeWebContentsAndroid); | 586 private native void nativeSelectAll(long nativeWebContentsAndroid); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 ContentBitmapCallback callback, Bitmap.Config config, float scale, | 627 ContentBitmapCallback callback, Bitmap.Config config, float scale, |
| 611 float x, float y, float width, float height); | 628 float x, float y, float width, float height); |
| 612 private native void nativeReloadLoFiImages(long nativeWebContentsAndroid); | 629 private native void nativeReloadLoFiImages(long nativeWebContentsAndroid); |
| 613 private native int nativeDownloadImage(long nativeWebContentsAndroid, | 630 private native int nativeDownloadImage(long nativeWebContentsAndroid, |
| 614 String url, boolean isFavicon, int maxBitmapSize, | 631 String url, boolean isFavicon, int maxBitmapSize, |
| 615 boolean bypassCache, ImageDownloadCallback callback); | 632 boolean bypassCache, ImageDownloadCallback callback); |
| 616 private native void nativeDismissTextHandles(long nativeWebContentsAndroid); | 633 private native void nativeDismissTextHandles(long nativeWebContentsAndroid); |
| 617 private native void nativeSetHasPersistentVideo(long nativeWebContentsAndroi
d, boolean value); | 634 private native void nativeSetHasPersistentVideo(long nativeWebContentsAndroi
d, boolean value); |
| 618 private native boolean nativeHasActiveEffectivelyFullscreenVideo(long native
WebContentsAndroid); | 635 private native boolean nativeHasActiveEffectivelyFullscreenVideo(long native
WebContentsAndroid); |
| 619 } | 636 } |
| OLD | NEW |