Apply _RELATIVE relocations ahead of others.
[chromium-blink-merge.git] / content / browser / web_contents / web_contents_android.h
blob4b79231c005745b4e24190cf2ae6720c04698512
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/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"
19 namespace content {
21 class WebContents;
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 {
29 public:
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,
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 jint GetBackgroundColor(JNIEnv* env, jobject obj);
50 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const;
51 jboolean IsIncognito(JNIEnv* env, jobject obj);
53 void ResumeResponseDeferredAtStart(JNIEnv* env, jobject obj);
54 void SetHasPendingNavigationTransitionForTesting(JNIEnv* env, jobject obj);
55 void SetupTransitionView(JNIEnv* env, jobject jobj, jstring markup);
56 void BeginExitTransition(JNIEnv* env, jobject jobj, jstring css_selector);
57 void ClearNavigationTransitionData(JNIEnv* env, jobject jobj);
59 // This method is invoked when the request is deferred immediately after
60 // receiving response headers.
61 void DidDeferAfterResponseStarted(const TransitionLayerData& transition_data);
63 // This method is invoked when a navigation transition is detected, to
64 // determine if the embedder intends to handle it.
65 bool WillHandleDeferAfterResponseStarted();
67 // This method is invoked when a navigation transition has started.
68 void DidStartNavigationTransitionForFrame(int64 frame_id);
70 void OnHide(JNIEnv* env, jobject obj);
71 void OnShow(JNIEnv* env, jobject obj);
72 void ReleaseMediaPlayers(JNIEnv* env, jobject jobj);
74 void AddStyleSheetByURL(
75 JNIEnv* env, jobject obj, jstring url);
76 void ShowInterstitialPage(
77 JNIEnv* env, jobject obj, jstring jurl, jlong delegate_ptr);
78 jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj);
79 jboolean IsRenderWidgetHostViewReady(JNIEnv* env, jobject obj);
80 void ExitFullscreen(JNIEnv* env, jobject obj);
81 void UpdateTopControlsState(
82 JNIEnv* env,
83 jobject obj,
84 bool enable_hiding,
85 bool enable_showing,
86 bool animate);
87 void ShowImeIfNeeded(JNIEnv* env, jobject obj);
88 void ScrollFocusedEditableNodeIntoView(JNIEnv* env, jobject obj);
89 void SelectWordAroundCaret(JNIEnv* env, jobject obj);
91 void InsertCSS(JNIEnv* env, jobject jobj, jstring jcss);
92 void EvaluateJavaScript(JNIEnv* env,
93 jobject obj,
94 jstring script,
95 jobject callback);
96 void PostMessageToFrame(JNIEnv* env, jobject obj, jstring frame_id,
97 jstring message, jstring source_origin, jstring target_origin);
98 private:
99 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid();
101 WebContents* web_contents_;
102 NavigationControllerAndroid navigation_controller_;
103 base::android::ScopedJavaGlobalRef<jobject> obj_;
105 DISALLOW_COPY_AND_ASSIGN(WebContentsAndroid);
108 } // namespace content
110 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_ANDROID_H_