[Mac] Implement Ambient Light API
[chromium-blink-merge.git] / content / browser / web_contents / web_contents_android.h
blob89f871478c1376d48ea734b914747cd57f6a4481
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/browser/transition_request_manager.h"
19 #include "content/common/content_export.h"
21 namespace content {
23 class WebContents;
24 struct TransitionLayerData;
26 // Android wrapper around WebContents that provides safer passage from java and
27 // back to native and provides java with a means of communicating with its
28 // native counterpart.
29 class CONTENT_EXPORT WebContentsAndroid
30 : public base::SupportsUserData::Data {
31 public:
32 static bool Register(JNIEnv* env);
34 explicit WebContentsAndroid(WebContents* web_contents);
35 virtual ~WebContentsAndroid();
37 WebContents* web_contents() const { return web_contents_; }
39 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
41 // Methods called from Java
42 base::android::ScopedJavaLocalRef<jstring> GetTitle(JNIEnv* env,
43 jobject obj) const;
44 base::android::ScopedJavaLocalRef<jstring> GetVisibleURL(JNIEnv* env,
45 jobject obj) const;
47 bool IsLoading(JNIEnv* env, jobject obj) const;
48 bool IsLoadingToDifferentDocument(JNIEnv* env, jobject obj) const;
50 void Stop(JNIEnv* env, jobject obj);
51 jint GetBackgroundColor(JNIEnv* env, jobject obj);
52 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const;
53 jboolean IsIncognito(JNIEnv* env, jobject obj);
55 void ResumeResponseDeferredAtStart(JNIEnv* env, jobject obj);
56 void SetHasPendingNavigationTransitionForTesting(JNIEnv* env, jobject obj);
57 void SetupTransitionView(JNIEnv* env, jobject jobj, jstring markup);
58 void BeginExitTransition(JNIEnv* env, jobject jobj, jstring css_selector,
59 jboolean exit_to_native_app);
60 void RevertExitTransition(JNIEnv* env, jobject jobj);
61 void HideTransitionElements(JNIEnv* env, jobject jobj, jstring css_selector);
62 void ShowTransitionElements(JNIEnv* env, jobject jobj, jstring css_selector);
63 void ClearNavigationTransitionData(JNIEnv* env, jobject jobj);
64 void FetchTransitionElements(JNIEnv* env, jobject jobj, jstring jurl);
65 void OnTransitionElementsFetched(
66 scoped_ptr<const TransitionLayerData> transition_data,
67 bool has_transition_data);
69 // This method is invoked when the request is deferred immediately after
70 // receiving response headers.
71 void DidDeferAfterResponseStarted(const TransitionLayerData& transition_data);
73 // This method is invoked when a navigation transition is detected, to
74 // determine if the embedder intends to handle it.
75 bool WillHandleDeferAfterResponseStarted();
77 // This method is invoked when a navigation transition has started.
78 void DidStartNavigationTransitionForFrame(int64 frame_id);
80 void OnHide(JNIEnv* env, jobject obj);
81 void OnShow(JNIEnv* env, jobject obj);
82 void ReleaseMediaPlayers(JNIEnv* env, jobject jobj);
84 void AddStyleSheetByURL(
85 JNIEnv* env, jobject obj, jstring url);
86 void ShowInterstitialPage(
87 JNIEnv* env, jobject obj, jstring jurl, jlong delegate_ptr);
88 jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj);
89 jboolean IsRenderWidgetHostViewReady(JNIEnv* env, jobject obj);
90 void ExitFullscreen(JNIEnv* env, jobject obj);
91 void UpdateTopControlsState(
92 JNIEnv* env,
93 jobject obj,
94 bool enable_hiding,
95 bool enable_showing,
96 bool animate);
97 void ShowImeIfNeeded(JNIEnv* env, jobject obj);
98 void ScrollFocusedEditableNodeIntoView(JNIEnv* env, jobject obj);
99 void SelectWordAroundCaret(JNIEnv* env, jobject obj);
101 void InsertCSS(JNIEnv* env, jobject jobj, jstring jcss);
102 void EvaluateJavaScript(JNIEnv* env,
103 jobject obj,
104 jstring script,
105 jobject callback);
106 private:
107 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid();
109 WebContents* web_contents_;
110 NavigationControllerAndroid navigation_controller_;
111 base::android::ScopedJavaGlobalRef<jobject> obj_;
113 base::WeakPtrFactory<WebContentsAndroid> weak_factory_;
115 DISALLOW_COPY_AND_ASSIGN(WebContentsAndroid);
118 } // namespace content
120 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_ANDROID_H_