OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/android/jni_helper.h" | 10 #include "base/android/jni_helper.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/process.h" | 15 #include "base/process.h" |
16 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 16 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
17 #include "content/browser/web_contents/web_contents_impl.h" | |
18 #include "content/public/browser/android/content_view_core.h" | 17 #include "content/public/browser/android/content_view_core.h" |
19 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
20 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
22 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
23 | 22 |
24 struct WebMenuItem; | 23 struct WebMenuItem; |
25 | 24 |
26 namespace content { | 25 namespace content { |
27 class ContentViewClient; | 26 class ContentViewClient; |
28 class RenderWidgetHostViewAndroid; | 27 class RenderWidgetHostViewAndroid; |
29 | 28 |
30 // TODO(jrg): this is a shell. Upstream the rest. | 29 // TODO(jrg): this is a shell. Upstream the rest. |
31 class ContentViewCoreImpl : public ContentViewCore, | 30 class ContentViewCoreImpl : public ContentViewCore, |
32 public NotificationObserver { | 31 public NotificationObserver { |
33 public: | 32 public: |
34 ContentViewCoreImpl(JNIEnv* env, | 33 ContentViewCoreImpl(JNIEnv* env, |
35 jobject obj, | 34 jobject obj, |
36 WebContents* web_contents); | 35 WebContents* web_contents); |
37 | |
38 // ContentViewCore overrides | |
39 virtual void Destroy(JNIEnv* env, jobject obj) OVERRIDE; | 36 virtual void Destroy(JNIEnv* env, jobject obj) OVERRIDE; |
40 | 37 |
41 // -------------------------------------------------------------------------- | 38 // -------------------------------------------------------------------------- |
42 // Methods called from Java via JNI | 39 // Methods called from Java via JNI |
43 // -------------------------------------------------------------------------- | 40 // -------------------------------------------------------------------------- |
44 | 41 |
45 // Notifies the ContentViewCore that items were selected in the currently | 42 // Notifies the ContentViewCore that items were selected in the currently |
46 // showing select popup. | 43 // showing select popup. |
47 void SelectPopupMenuItems(JNIEnv* env, jobject obj, jintArray indices); | 44 void SelectPopupMenuItems(JNIEnv* env, jobject obj, jintArray indices); |
48 | 45 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 jboolean CanGoToOffset(JNIEnv* env, jobject obj, jint offset); | 101 jboolean CanGoToOffset(JNIEnv* env, jobject obj, jint offset); |
105 void GoBack(JNIEnv* env, jobject obj); | 102 void GoBack(JNIEnv* env, jobject obj); |
106 void GoForward(JNIEnv* env, jobject obj); | 103 void GoForward(JNIEnv* env, jobject obj); |
107 void GoToOffset(JNIEnv* env, jobject obj, jint offset); | 104 void GoToOffset(JNIEnv* env, jobject obj, jint offset); |
108 jdouble GetLoadProgress(JNIEnv* env, jobject obj) const; | 105 jdouble GetLoadProgress(JNIEnv* env, jobject obj) const; |
109 void StopLoading(JNIEnv* env, jobject obj); | 106 void StopLoading(JNIEnv* env, jobject obj); |
110 void Reload(JNIEnv* env, jobject obj); | 107 void Reload(JNIEnv* env, jobject obj); |
111 jboolean NeedsReload(JNIEnv* env, jobject obj); | 108 jboolean NeedsReload(JNIEnv* env, jobject obj); |
112 void ClearHistory(JNIEnv* env, jobject obj); | 109 void ClearHistory(JNIEnv* env, jobject obj); |
113 void SetClient(JNIEnv* env, jobject obj, jobject jclient); | 110 void SetClient(JNIEnv* env, jobject obj, jobject jclient); |
114 void AddJavascriptInterface(JNIEnv* env, | |
115 jobject obj, | |
116 jobject object, | |
117 jstring name, | |
118 jboolean allow_inherited_methods); | |
119 void RemoveJavascriptInterface(JNIEnv* env, jobject obj, jstring name); | |
120 | 111 |
121 // -------------------------------------------------------------------------- | 112 // -------------------------------------------------------------------------- |
122 // Public methods that call to Java via JNI | 113 // Public methods that call to Java via JNI |
123 // -------------------------------------------------------------------------- | 114 // -------------------------------------------------------------------------- |
124 | 115 |
125 // Creates a popup menu with |items|. | 116 // Creates a popup menu with |items|. |
126 // |multiple| defines if it should support multi-select. | 117 // |multiple| defines if it should support multi-select. |
127 // If not |multiple|, |selected_item| sets the initially selected item. | 118 // If not |multiple|, |selected_item| sets the initially selected item. |
128 // Otherwise, item's "checked" flag selects it. | 119 // Otherwise, item's "checked" flag selects it. |
129 void ShowSelectPopupMenu(const std::vector<WebMenuItem>& items, | 120 void ShowSelectPopupMenu(const std::vector<WebMenuItem>& items, |
(...skipping 13 matching lines...) Expand all Loading... |
143 int endx, | 134 int endx, |
144 int endy, | 135 int endy, |
145 base::i18n::TextDirection end_dir); | 136 base::i18n::TextDirection end_dir); |
146 | 137 |
147 // Called when page loading begins. | 138 // Called when page loading begins. |
148 void DidStartLoading(); | 139 void DidStartLoading(); |
149 | 140 |
150 void OnAcceleratedCompositingStateChange(RenderWidgetHostViewAndroid* rwhva, | 141 void OnAcceleratedCompositingStateChange(RenderWidgetHostViewAndroid* rwhva, |
151 bool activated, | 142 bool activated, |
152 bool force); | 143 bool force); |
153 void StartContentIntent(const GURL& content_url); | 144 virtual void StartContentIntent(const GURL& content_url) OVERRIDE; |
154 | 145 |
155 // -------------------------------------------------------------------------- | 146 // -------------------------------------------------------------------------- |
156 // Methods called from native code | 147 // Methods called from native code |
157 // -------------------------------------------------------------------------- | 148 // -------------------------------------------------------------------------- |
158 | 149 |
159 gfx::Rect GetBounds() const; | 150 gfx::Rect GetBounds() const; |
160 | 151 |
161 WebContents* web_contents() const { return web_contents_; } | 152 WebContents* web_contents() const { return web_contents_; } |
162 void LoadUrl(const GURL& url, int page_transition); | 153 void LoadUrl(const GURL& url, int page_transition); |
163 void LoadUrlWithUserAgentOverride( | 154 void LoadUrlWithUserAgentOverride( |
(...skipping 24 matching lines...) Expand all Loading... |
188 int x, int y, | 179 int x, int y, |
189 float dx, float dy, bool link_preview_tap); | 180 float dx, float dy, bool link_preview_tap); |
190 | 181 |
191 void PostLoadUrl(const GURL& url); | 182 void PostLoadUrl(const GURL& url); |
192 | 183 |
193 struct JavaObject; | 184 struct JavaObject; |
194 JavaObject* java_object_; | 185 JavaObject* java_object_; |
195 | 186 |
196 // Reference to the current WebContents used to determine how and what to | 187 // Reference to the current WebContents used to determine how and what to |
197 // display in the ContentViewCore. | 188 // display in the ContentViewCore. |
198 WebContentsImpl* web_contents_; | 189 WebContents* web_contents_; |
199 | 190 |
200 // We only set this to be the delegate of the web_contents if we own it. | 191 // We only set this to be the delegate of the web_contents if we own it. |
201 scoped_ptr<ContentViewClient> content_view_client_; | 192 scoped_ptr<ContentViewClient> content_view_client_; |
202 | 193 |
203 // Whether the renderer backing this ContentViewCore has crashed. | 194 // Whether the renderer backing this ContentViewCore has crashed. |
204 bool tab_crashed_; | 195 bool tab_crashed_; |
205 | 196 |
206 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); | 197 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); |
207 }; | 198 }; |
208 | 199 |
209 bool RegisterContentViewCore(JNIEnv* env); | 200 bool RegisterContentViewCore(JNIEnv* env); |
210 | 201 |
211 } // namespace content | 202 } // namespace content |
212 | 203 |
213 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 204 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
OLD | NEW |