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

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

Issue 2681933002: Add Java wrapper for RenderFrameHost (Closed)
Patch Set: Fix potential dtor problem Created 3 years, 10 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 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;
(...skipping 10 matching lines...) Expand all
21 import org.chromium.content.browser.AppWebMessagePort; 21 import org.chromium.content.browser.AppWebMessagePort;
22 import org.chromium.content.browser.AppWebMessagePortService; 22 import org.chromium.content.browser.AppWebMessagePortService;
23 import org.chromium.content.browser.MediaSessionImpl; 23 import org.chromium.content.browser.MediaSessionImpl;
24 import org.chromium.content_public.browser.AccessibilitySnapshotCallback; 24 import org.chromium.content_public.browser.AccessibilitySnapshotCallback;
25 import org.chromium.content_public.browser.AccessibilitySnapshotNode; 25 import org.chromium.content_public.browser.AccessibilitySnapshotNode;
26 import org.chromium.content_public.browser.ContentBitmapCallback; 26 import org.chromium.content_public.browser.ContentBitmapCallback;
27 import org.chromium.content_public.browser.ImageDownloadCallback; 27 import org.chromium.content_public.browser.ImageDownloadCallback;
28 import org.chromium.content_public.browser.JavaScriptCallback; 28 import org.chromium.content_public.browser.JavaScriptCallback;
29 import org.chromium.content_public.browser.MessagePortService; 29 import org.chromium.content_public.browser.MessagePortService;
30 import org.chromium.content_public.browser.NavigationController; 30 import org.chromium.content_public.browser.NavigationController;
31 import org.chromium.content_public.browser.RenderFrameHost;
31 import org.chromium.content_public.browser.SmartClipCallback; 32 import org.chromium.content_public.browser.SmartClipCallback;
32 import org.chromium.content_public.browser.WebContents; 33 import org.chromium.content_public.browser.WebContents;
33 import org.chromium.content_public.browser.WebContentsObserver; 34 import org.chromium.content_public.browser.WebContentsObserver;
34 import org.chromium.ui.OverscrollRefreshHandler; 35 import org.chromium.ui.OverscrollRefreshHandler;
35 import org.chromium.ui.accessibility.AXTextStyle; 36 import org.chromium.ui.accessibility.AXTextStyle;
36 37
37 import java.util.ArrayList; 38 import java.util.ArrayList;
38 import java.util.List; 39 import java.util.List;
39 import java.util.UUID; 40 import java.util.UUID;
40 41
41 /** 42 /**
42 * 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
43 * object. 44 * object.
44 */ 45 */
45 @JNINamespace("content") 46 @JNINamespace("content")
46 //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
47 // package whose visibility will be enforced via DEPS. 48 // package whose visibility will be enforced via DEPS.
48 /* package */ class WebContentsImpl implements WebContents { 49 /* package */ public class WebContentsImpl implements WebContents {
boliu 2017/02/16 01:00:58 this doesn't need to be public, after RFH stops im
rwlbuis 2017/03/01 21:53:57 Done.
49 private static final String PARCEL_VERSION_KEY = "version"; 50 private static final String PARCEL_VERSION_KEY = "version";
50 private static final String PARCEL_WEBCONTENTS_KEY = "webcontents"; 51 private static final String PARCEL_WEBCONTENTS_KEY = "webcontents";
51 private static final String PARCEL_PROCESS_GUARD_KEY = "processguard"; 52 private static final String PARCEL_PROCESS_GUARD_KEY = "processguard";
52 53
53 private static final long PARCELABLE_VERSION_ID = 0; 54 private static final long PARCELABLE_VERSION_ID = 0;
54 // 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.
55 private static UUID sParcelableUUID = UUID.randomUUID(); 56 private static UUID sParcelableUUID = UUID.randomUUID();
56 57
57 /** 58 /**
58 * 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 public boolean isDestroyed() { 161 public boolean isDestroyed() {
161 return mNativeWebContentsAndroid == 0; 162 return mNativeWebContentsAndroid == 0;
162 } 163 }
163 164
164 @Override 165 @Override
165 public NavigationController getNavigationController() { 166 public NavigationController getNavigationController() {
166 return mNavigationController; 167 return mNavigationController;
167 } 168 }
168 169
169 @Override 170 @Override
171 public RenderFrameHost getMainFrame() {
172 return nativeGetMainFrame(mNativeWebContentsAndroid);
173 }
174
175 public static WebContents fromRenderFrameHost(RenderFrameHost rfh) {
176 return nativeFromRenderFrameHost(rfh);
177 }
178
179 @Override
170 public String getTitle() { 180 public String getTitle() {
171 return nativeGetTitle(mNativeWebContentsAndroid); 181 return nativeGetTitle(mNativeWebContentsAndroid);
172 } 182 }
173 183
174 @Override 184 @Override
175 public String getVisibleUrl() { 185 public String getVisibleUrl() {
176 return nativeGetVisibleURL(mNativeWebContentsAndroid); 186 return nativeGetVisibleURL(mNativeWebContentsAndroid);
177 } 187 }
178 188
179 @Override 189 @Override
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 @CalledByNative 543 @CalledByNative
534 private static void createSizeAndAddToList(List<Rect> sizes, int width, int height) { 544 private static void createSizeAndAddToList(List<Rect> sizes, int width, int height) {
535 sizes.add(new Rect(0, 0, width, height)); 545 sizes.add(new Rect(0, 0, width, height));
536 } 546 }
537 547
538 // This is static to avoid exposing a public destroy method on the native si de of this class. 548 // This is static to avoid exposing a public destroy method on the native si de of this class.
539 private static native void nativeDestroyWebContents(long webContentsAndroidP tr); 549 private static native void nativeDestroyWebContents(long webContentsAndroidP tr);
540 550
541 private static native WebContents nativeFromNativePtr(long webContentsAndroi dPtr); 551 private static native WebContents nativeFromNativePtr(long webContentsAndroi dPtr);
542 552
553 private native RenderFrameHost nativeGetMainFrame(long nativeWebContentsAndr oid);
554 private static native WebContents nativeFromRenderFrameHost(RenderFrameHost rfh);
543 private native String nativeGetTitle(long nativeWebContentsAndroid); 555 private native String nativeGetTitle(long nativeWebContentsAndroid);
544 private native String nativeGetVisibleURL(long nativeWebContentsAndroid); 556 private native String nativeGetVisibleURL(long nativeWebContentsAndroid);
545 private native boolean nativeIsLoading(long nativeWebContentsAndroid); 557 private native boolean nativeIsLoading(long nativeWebContentsAndroid);
546 private native boolean nativeIsLoadingToDifferentDocument(long nativeWebCont entsAndroid); 558 private native boolean nativeIsLoadingToDifferentDocument(long nativeWebCont entsAndroid);
547 private native void nativeStop(long nativeWebContentsAndroid); 559 private native void nativeStop(long nativeWebContentsAndroid);
548 private native void nativeCut(long nativeWebContentsAndroid); 560 private native void nativeCut(long nativeWebContentsAndroid);
549 private native void nativeCopy(long nativeWebContentsAndroid); 561 private native void nativeCopy(long nativeWebContentsAndroid);
550 private native void nativePaste(long nativeWebContentsAndroid); 562 private native void nativePaste(long nativeWebContentsAndroid);
551 private native void nativeReplace(long nativeWebContentsAndroid, String word ); 563 private native void nativeReplace(long nativeWebContentsAndroid, String word );
552 private native void nativeSelectAll(long nativeWebContentsAndroid); 564 private native void nativeSelectAll(long nativeWebContentsAndroid);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 long nativeWebContentsAndroid, OverscrollRefreshHandler nativeOversc rollRefreshHandler); 605 long nativeWebContentsAndroid, OverscrollRefreshHandler nativeOversc rollRefreshHandler);
594 private native void nativeGetContentBitmap(long nativeWebContentsAndroid, 606 private native void nativeGetContentBitmap(long nativeWebContentsAndroid,
595 ContentBitmapCallback callback, Bitmap.Config config, float scale, 607 ContentBitmapCallback callback, Bitmap.Config config, float scale,
596 float x, float y, float width, float height); 608 float x, float y, float width, float height);
597 private native void nativeReloadLoFiImages(long nativeWebContentsAndroid); 609 private native void nativeReloadLoFiImages(long nativeWebContentsAndroid);
598 private native int nativeDownloadImage(long nativeWebContentsAndroid, 610 private native int nativeDownloadImage(long nativeWebContentsAndroid,
599 String url, boolean isFavicon, int maxBitmapSize, 611 String url, boolean isFavicon, int maxBitmapSize,
600 boolean bypassCache, ImageDownloadCallback callback); 612 boolean bypassCache, ImageDownloadCallback callback);
601 private native void nativeDismissTextHandles(long nativeWebContentsAndroid); 613 private native void nativeDismissTextHandles(long nativeWebContentsAndroid);
602 } 614 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698