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
3// found in the LICENSE file.
4
5package org.chromium.chrome.browser;
6
7import org.chromium.content.browser.ContentViewCore;
8
9/**
10 * This class provides a way to create the native WebContents required for instantiating a
11 * ContentView.
12 */
13public abstract class ContentViewUtil {
14    // Don't instantiate me.
15    private ContentViewUtil() {
16    }
17
18    /**
19     * @return pointer to native WebContents instance, suitable for using with a
20     *         (java) ContentViewCore instance.
21     */
22    public static long createNativeWebContents(boolean incognito) {
23        return nativeCreateNativeWebContents(incognito, false);
24    }
25
26    /**
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 initiallyHidden) {
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(contentViewCore);
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);
52    private static native long nativeCreateNativeWebContentsWithSharedSiteInstance(
53            ContentViewCore contentViewCore);
54    private static native void nativeDestroyNativeWebContents(long webContentsPtr);
55}
56