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.
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_ANDROID_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_ANDROID_H_
10 #include "base/android/scoped_java_ref.h"
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/supports_user_data.h"
14 #include "content/browser/frame_host/navigation_controller_android.h"
15 #include "content/browser/renderer_host/render_widget_host_view_android.h"
16 #include "content/browser/transition_request_manager.h"
17 #include "content/common/content_export.h"
22 struct TransitionLayerData
;
24 // Android wrapper around WebContents that provides safer passage from java and
25 // back to native and provides java with a means of communicating with its
26 // native counterpart.
27 class CONTENT_EXPORT WebContentsAndroid
28 : public base::SupportsUserData::Data
{
30 static bool Register(JNIEnv
* env
);
32 explicit WebContentsAndroid(WebContents
* web_contents
);
33 virtual ~WebContentsAndroid();
35 WebContents
* web_contents() const { return web_contents_
; }
37 base::android::ScopedJavaLocalRef
<jobject
> GetJavaObject();
39 // Methods called from Java
40 base::android::ScopedJavaLocalRef
<jstring
> GetTitle(JNIEnv
* env
,
42 base::android::ScopedJavaLocalRef
<jstring
> GetVisibleURL(JNIEnv
* env
,
44 void Stop(JNIEnv
* env
, jobject obj
);
45 jint
GetBackgroundColor(JNIEnv
* env
, jobject obj
);
46 base::android::ScopedJavaLocalRef
<jstring
> GetURL(JNIEnv
* env
, jobject
) const;
47 jboolean
IsIncognito(JNIEnv
* env
, jobject obj
);
49 void ResumeResponseDeferredAtStart(JNIEnv
* env
, jobject obj
);
50 void SetHasPendingNavigationTransitionForTesting(JNIEnv
* env
, jobject obj
);
51 void SetupTransitionView(JNIEnv
* env
, jobject jobj
, jstring markup
);
52 void BeginExitTransition(JNIEnv
* env
, jobject jobj
, jstring css_selector
);
54 // This method is invoked when the request is deferred immediately after
55 // receiving response headers.
56 void DidDeferAfterResponseStarted(const TransitionLayerData
& transition_data
);
58 // This method is invoked when a navigation transition is detected, to
59 // determine if the embedder intends to handle it.
60 bool WillHandleDeferAfterResponseStarted();
62 // This method is invoked when a navigation transition has started.
63 void DidStartNavigationTransitionForFrame(int64 frame_id
);
65 void OnHide(JNIEnv
* env
, jobject obj
);
66 void OnShow(JNIEnv
* env
, jobject obj
);
68 void AddStyleSheetByURL(
69 JNIEnv
* env
, jobject obj
, jstring url
);
70 void ShowInterstitialPage(
71 JNIEnv
* env
, jobject obj
, jstring jurl
, jlong delegate_ptr
);
72 jboolean
IsShowingInterstitialPage(JNIEnv
* env
, jobject obj
);
73 jboolean
IsRenderWidgetHostViewReady(JNIEnv
* env
, jobject obj
);
74 void ExitFullscreen(JNIEnv
* env
, jobject obj
);
75 void UpdateTopControlsState(
81 void ShowImeIfNeeded(JNIEnv
* env
, jobject obj
);
82 void ScrollFocusedEditableNodeIntoView(JNIEnv
* env
, jobject obj
);
83 void SelectWordAroundCaret(JNIEnv
* env
, jobject obj
);
85 void InsertCSS(JNIEnv
* env
, jobject jobj
, jstring jcss
);
86 void EvaluateJavaScript(JNIEnv
* env
,
90 jboolean start_renderer
);
93 RenderWidgetHostViewAndroid
* GetRenderWidgetHostViewAndroid();
95 WebContents
* web_contents_
;
96 NavigationControllerAndroid navigation_controller_
;
97 base::android::ScopedJavaGlobalRef
<jobject
> obj_
;
99 DISALLOW_COPY_AND_ASSIGN(WebContentsAndroid
);
102 } // namespace content
104 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_ANDROID_H_