[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / web_contents / web_contents_android.h
blob5088d97b6de16be23ce92a5653556c81f127668d
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_
8 #include <jni.h>
10 #include "base/android/scoped_java_ref.h"
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/supports_user_data.h"
16 #include "content/browser/frame_host/navigation_controller_android.h"
17 #include "content/browser/renderer_host/render_widget_host_view_android.h"
18 #include "content/common/content_export.h"
20 namespace content {
22 class WebContents;
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 {
29 public:
30 static bool Register(JNIEnv* env);
32 explicit WebContentsAndroid(WebContents* web_contents);
33 ~WebContentsAndroid() override;
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,
41 jobject obj) const;
42 base::android::ScopedJavaLocalRef<jstring> GetVisibleURL(JNIEnv* env,
43 jobject obj) const;
45 bool IsLoading(JNIEnv* env, jobject obj) const;
46 bool IsLoadingToDifferentDocument(JNIEnv* env, jobject obj) const;
48 void Stop(JNIEnv* env, jobject obj);
49 void Cut(JNIEnv* env, jobject obj);
50 void Copy(JNIEnv* env, jobject obj);
51 void Paste(JNIEnv* env, jobject obj);
52 void SelectAll(JNIEnv* env, jobject obj);
53 void Unselect(JNIEnv* env, jobject obj);
54 jint GetBackgroundColor(JNIEnv* env, jobject obj);
55 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const;
56 base::android::ScopedJavaLocalRef<jstring> GetLastCommittedURL(JNIEnv* env,
57 jobject) const;
58 jboolean IsIncognito(JNIEnv* env, jobject obj);
60 void ResumeLoadingCreatedWebContents(JNIEnv* env, jobject obj);
62 void OnHide(JNIEnv* env, jobject obj);
63 void OnShow(JNIEnv* env, jobject obj);
64 void ReleaseMediaPlayers(JNIEnv* env, jobject jobj);
66 void ShowInterstitialPage(
67 JNIEnv* env, jobject obj, jstring jurl, jlong delegate_ptr);
68 jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj);
69 jboolean IsRenderWidgetHostViewReady(JNIEnv* env, jobject obj);
70 void ExitFullscreen(JNIEnv* env, jobject obj);
71 void UpdateTopControlsState(
72 JNIEnv* env,
73 jobject obj,
74 bool enable_hiding,
75 bool enable_showing,
76 bool animate);
77 void ShowImeIfNeeded(JNIEnv* env, jobject obj);
78 void ScrollFocusedEditableNodeIntoView(JNIEnv* env, jobject obj);
79 void SelectWordAroundCaret(JNIEnv* env, jobject obj);
80 void AdjustSelectionByCharacterOffset(JNIEnv* env,
81 jobject obj,
82 jint start_adjust,
83 jint end_adjust);
84 void InsertCSS(JNIEnv* env, jobject jobj, jstring jcss);
85 void EvaluateJavaScript(JNIEnv* env,
86 jobject obj,
87 jstring script,
88 jobject callback);
89 void EvaluateJavaScriptForTests(JNIEnv* env,
90 jobject obj,
91 jstring script,
92 jobject callback);
94 void AddMessageToDevToolsConsole(JNIEnv* env,
95 jobject jobj,
96 jint level,
97 jstring message);
99 void SendMessageToFrame(JNIEnv* env,
100 jobject obj,
101 jstring frame_name,
102 jstring message,
103 jstring target_origin);
105 jboolean HasAccessedInitialDocument(JNIEnv* env, jobject jobj);
107 jint GetThemeColor(JNIEnv* env, jobject obj);
109 void RequestAccessibilitySnapshot(JNIEnv* env,
110 jobject obj,
111 jobject callback,
112 jfloat y_offset,
113 jfloat x_scroll);
115 void ResumeMediaSession(JNIEnv* env, jobject obj);
116 void SuspendMediaSession(JNIEnv* env, jobject obj);
117 void StopMediaSession(JNIEnv* env, jobject obj);
119 base::android::ScopedJavaLocalRef<jstring> GetEncoding(JNIEnv* env,
120 jobject obj) const;
122 private:
123 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid();
125 WebContents* web_contents_;
126 NavigationControllerAndroid navigation_controller_;
127 base::android::ScopedJavaGlobalRef<jobject> obj_;
129 base::WeakPtrFactory<WebContentsAndroid> weak_factory_;
131 DISALLOW_COPY_AND_ASSIGN(WebContentsAndroid);
134 } // namespace content
136 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_ANDROID_H_