• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 package org.chromium.content.browser.webcontents;
6 
7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace;
9 import org.chromium.content_public.browser.NavigationController;
10 import org.chromium.content_public.browser.WebContents;
11 
12 /**
13  * The WebContentsImpl Java wrapper to allow communicating with the native WebContentsImpl
14  * object.
15  */
16 @JNINamespace("content")
17 //TODO(tedchoc): Remove the package restriction once this class moves to a non-public content
18 //               package whose visibility will be enforced via DEPS.
19 /* package */ class WebContentsImpl implements WebContents {
20 
21     private long mNativeWebContentsAndroid;
22     private NavigationController mNavigationController;
23 
WebContentsImpl( long nativeWebContentsAndroid, NavigationController navigationController)24     private WebContentsImpl(
25             long nativeWebContentsAndroid, NavigationController navigationController) {
26         mNativeWebContentsAndroid = nativeWebContentsAndroid;
27         mNavigationController = navigationController;
28     }
29 
30     @CalledByNative
create( long nativeWebContentsAndroid, NavigationController navigationController)31     private static WebContentsImpl create(
32             long nativeWebContentsAndroid, NavigationController navigationController) {
33         return new WebContentsImpl(nativeWebContentsAndroid, navigationController);
34     }
35 
36     @CalledByNative
destroy()37     private void destroy() {
38         mNativeWebContentsAndroid = 0;
39         mNavigationController = null;
40     }
41 
42     @CalledByNative
getNativePointer()43     private long getNativePointer() {
44         return mNativeWebContentsAndroid;
45     }
46 
47     @Override
getNavigationController()48     public NavigationController getNavigationController() {
49         return mNavigationController;
50     }
51 
52     @Override
getTitle()53     public String getTitle() {
54         return nativeGetTitle(mNativeWebContentsAndroid);
55     }
56 
57     @Override
getVisibleUrl()58     public String getVisibleUrl() {
59         return nativeGetVisibleURL(mNativeWebContentsAndroid);
60     }
61 
62     @Override
stop()63     public void stop() {
64         nativeStop(mNativeWebContentsAndroid);
65     }
66 
nativeGetTitle(long nativeWebContentsAndroid)67     private native String nativeGetTitle(long nativeWebContentsAndroid);
nativeGetVisibleURL(long nativeWebContentsAndroid)68     private native String nativeGetVisibleURL(long nativeWebContentsAndroid);
nativeStop(long nativeWebContentsAndroid)69     private native void nativeStop(long nativeWebContentsAndroid);
70 }
71