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.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import org.chromium.content.browser.ContentViewCore; | 7 import org.chromium.content.browser.ContentViewCore; |
| 8 import org.chromium.content_public.browser.WebContents; |
8 | 9 |
9 /** | 10 /** |
10 * This class provides a way to create the native WebContents required for insta
ntiating a | 11 * This class provides a way to create the native WebContents required for insta
ntiating a |
11 * ContentView. | 12 * ContentView. |
12 */ | 13 */ |
13 public abstract class ContentViewUtil { | 14 public abstract class ContentViewUtil { |
14 // Don't instantiate me. | 15 // Don't instantiate me. |
15 private ContentViewUtil() { | 16 private ContentViewUtil() { |
16 } | 17 } |
17 | 18 |
18 /** | 19 /** |
| 20 * A factory method to build a {@link WebContents} object. |
| 21 * @param incognito Whether or not the {@link WebContents} should be b
uilt with an |
| 22 * incognito profile or not. |
| 23 * @param initiallyHidden Whether or not the {@link WebContents} should be i
nitially hidden. |
| 24 * @return A newly created {@link WebContents} object. |
| 25 */ |
| 26 public static WebContents createWebContents(boolean incognito, boolean initi
allyHidden) { |
| 27 return nativeCreateWebContents(incognito, initiallyHidden); |
| 28 } |
| 29 |
| 30 /** |
| 31 * TODO(dtrainor): Remove when this is no longer used. |
| 32 * Helper method for getting a {@link WebContents} from a native WebContents
pointer. |
| 33 * @param webContentsPtr A native WebContents pointer. |
| 34 * @return A {@link WebContents} object that is linked to {@co
de webContentsPtr}. |
| 35 */ |
| 36 public static WebContents fromNativeWebContents(long webContentsPtr) { |
| 37 return nativeGetWebContentsFromNative(webContentsPtr); |
| 38 } |
| 39 |
| 40 /** |
| 41 * TODO(dtrainor): Remove when this is no longer used. |
| 42 * Helper method for getting a native WebContents pointer from a {@link WebC
ontents} object. |
| 43 * @param webContents A {@link WebContents} object. |
| 44 * @return A native WebContents poniter that is linked to {@code
webContents}. |
| 45 */ |
| 46 public static long getNativeWebContentsFromWebContents(WebContents webConten
ts) { |
| 47 return nativeGetNativeWebContentsPtr(webContents); |
| 48 } |
| 49 |
| 50 /** |
19 * @return pointer to native WebContents instance, suitable for using with a | 51 * @return pointer to native WebContents instance, suitable for using with a |
20 * (java) ContentViewCore instance. | 52 * (java) ContentViewCore instance. |
21 */ | 53 */ |
22 public static long createNativeWebContents(boolean incognito) { | 54 public static WebContents createWebContentsWithSharedSiteInstance( |
23 return nativeCreateNativeWebContents(incognito, false); | 55 ContentViewCore contentViewCore) { |
| 56 return nativeCreateWebContentsWithSharedSiteInstance(contentViewCore); |
24 } | 57 } |
25 | 58 |
26 /** | 59 private static native WebContents nativeCreateWebContents(boolean incognito, |
27 * @return pointer to native WebContents instance, suitable for using with a | |
28 * (java) ContentViewCore instance. | |
29 */ | |
30 public static long createNativeWebContents(boolean incognito, boolean initia
llyHidden) { | |
31 return nativeCreateNativeWebContents(incognito, initiallyHidden); | |
32 } | |
33 | |
34 /** | |
35 * @return pointer to native WebContents instance, suitable for using with a | |
36 * (java) ContentViewCore instance. | |
37 */ | |
38 public static long createNativeWebContentsWithSharedSiteInstance( | |
39 ContentViewCore contentViewCore) { | |
40 return nativeCreateNativeWebContentsWithSharedSiteInstance(contentViewCo
re); | |
41 } | |
42 | |
43 /** | |
44 * @param webContentsPtr The WebContents reference to be deleted. | |
45 */ | |
46 public static void destroyNativeWebContents(long webContentsPtr) { | |
47 nativeDestroyNativeWebContents(webContentsPtr); | |
48 } | |
49 | |
50 private static native long nativeCreateNativeWebContents(boolean incognito, | |
51 boolean initiallyHidden); | 60 boolean initiallyHidden); |
52 private static native long nativeCreateNativeWebContentsWithSharedSiteInstan
ce( | 61 private static native WebContents nativeCreateWebContentsWithSharedSiteInsta
nce( |
53 ContentViewCore contentViewCore); | 62 ContentViewCore contentViewCore); |
54 private static native void nativeDestroyNativeWebContents(long webContentsPt
r); | 63 private static native WebContents nativeGetWebContentsFromNative(long webCon
tentsPtr); |
| 64 private static native long nativeGetNativeWebContentsPtr(WebContents webCont
ents); |
55 } | 65 } |
OLD | NEW |