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/public/browser/android/content_view_core.h" | 17 #include "content/public/browser/android/content_view_core.h" |
17 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
19 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
20 | 22 |
21 struct WebMenuItem; | 23 struct WebMenuItem; |
22 | 24 |
23 namespace content { | 25 namespace content { |
24 class ContentViewClient; | 26 class ContentViewClient; |
25 class RenderWidgetHostViewAndroid; | 27 class RenderWidgetHostViewAndroid; |
26 | 28 |
27 // TODO(jrg): this is a shell. Upstream the rest. | 29 // TODO(jrg): this is a shell. Upstream the rest. |
28 class ContentViewCoreImpl : public ContentViewCore, | 30 class ContentViewCoreImpl : public ContentViewCore, |
29 public NotificationObserver { | 31 public NotificationObserver { |
30 public: | 32 public: |
31 ContentViewCoreImpl(JNIEnv* env, | 33 ContentViewCoreImpl(JNIEnv* env, |
32 jobject obj, | 34 jobject obj, |
33 WebContents* web_contents); | 35 WebContents* web_contents); |
34 virtual void Destroy(JNIEnv* env, jobject obj); | 36 virtual void Destroy(JNIEnv* env, jobject obj) OVERRIDE; |
35 | 37 |
36 // -------------------------------------------------------------------------- | 38 // -------------------------------------------------------------------------- |
37 // Methods called from Java via JNI | 39 // Methods called from Java via JNI |
38 // -------------------------------------------------------------------------- | 40 // -------------------------------------------------------------------------- |
39 | 41 |
40 // Notifies the ContentViewCore that items were selected in the currently | 42 // Notifies the ContentViewCore that items were selected in the currently |
41 // showing select popup. | 43 // showing select popup. |
42 void SelectPopupMenuItems(JNIEnv* env, jobject obj, jintArray indices); | 44 void SelectPopupMenuItems(JNIEnv* env, jobject obj, jintArray indices); |
43 | 45 |
44 void LoadUrlWithoutUrlSanitization(JNIEnv* env, | 46 void LoadUrlWithoutUrlSanitization(JNIEnv* env, |
45 jobject, | 47 jobject, |
46 jstring jurl, | 48 jstring jurl, |
47 int page_transition); | 49 int page_transition); |
48 void LoadUrlWithoutUrlSanitizationWithUserAgentOverride( | 50 void LoadUrlWithoutUrlSanitizationWithUserAgentOverride( |
49 JNIEnv* env, | 51 JNIEnv* env, |
50 jobject, | 52 jobject, |
51 jstring jurl, | 53 jstring jurl, |
52 int page_transition, | 54 int page_transition, |
53 jstring user_agent_override); | 55 jstring user_agent_override); |
54 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const; | 56 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const; |
55 base::android::ScopedJavaLocalRef<jstring> GetTitle( | 57 base::android::ScopedJavaLocalRef<jstring> GetTitle( |
56 JNIEnv* env, jobject obj) const; | 58 JNIEnv* env, jobject obj) const; |
57 jboolean IsIncognito(JNIEnv* env, jobject obj); | 59 jboolean IsIncognito(JNIEnv* env, jobject obj); |
58 jboolean Crashed(JNIEnv* env, jobject obj) const { return tab_crashed_; } | 60 jboolean Crashed(JNIEnv* env, jobject obj) const { return tab_crashed_; } |
61 | |
62 jboolean TouchEvent(JNIEnv* env, | |
63 jobject obj, | |
64 jlong time_ms, | |
65 jint type, | |
66 jobjectArray pts); | |
67 | |
Ted C
2012/07/27 01:31:53
why the blank line here and above?
| |
68 void ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, jint x, jint y); | |
69 void ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms); | |
70 void ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, jint dx, jint dy); | |
71 void FlingStart(JNIEnv* env, | |
72 jobject obj, | |
73 jlong time_ms, | |
74 jint x, | |
75 jint y, | |
76 jint vx, | |
77 jint vy); | |
78 void FlingCancel(JNIEnv* env, jobject obj, jlong time_ms); | |
79 void SingleTap(JNIEnv* env, | |
80 jobject obj, | |
81 jlong time_ms, | |
82 jint x, | |
83 jint y, | |
84 jboolean link_preview_tap); | |
85 void ShowPressState(JNIEnv* env, jobject obj, jlong time_ms, jint x, jint y); | |
86 void DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, jint x, jint y) ; | |
87 void LongPress(JNIEnv* env, | |
88 jobject obj, | |
89 jlong time_ms, | |
90 jint x, | |
91 jint y, | |
92 jboolean link_preview_tap); | |
93 void PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, jint x, jint y); | |
94 void PinchEnd(JNIEnv* env, jobject obj, jlong time_ms); | |
95 void PinchBy(JNIEnv* env, | |
96 jobject obj, | |
97 jlong time_ms, | |
98 jint x, | |
99 jint y, | |
100 jfloat delta); | |
59 jboolean CanGoBack(JNIEnv* env, jobject obj); | 101 jboolean CanGoBack(JNIEnv* env, jobject obj); |
60 jboolean CanGoForward(JNIEnv* env, jobject obj); | 102 jboolean CanGoForward(JNIEnv* env, jobject obj); |
61 jboolean CanGoToOffset(JNIEnv* env, jobject obj, jint offset); | 103 jboolean CanGoToOffset(JNIEnv* env, jobject obj, jint offset); |
62 void GoBack(JNIEnv* env, jobject obj); | 104 void GoBack(JNIEnv* env, jobject obj); |
63 void GoForward(JNIEnv* env, jobject obj); | 105 void GoForward(JNIEnv* env, jobject obj); |
64 void GoToOffset(JNIEnv* env, jobject obj, jint offset); | 106 void GoToOffset(JNIEnv* env, jobject obj, jint offset); |
65 jdouble GetLoadProgress(JNIEnv* env, jobject obj) const; | 107 jdouble GetLoadProgress(JNIEnv* env, jobject obj) const; |
66 void StopLoading(JNIEnv* env, jobject obj); | 108 void StopLoading(JNIEnv* env, jobject obj); |
67 void Reload(JNIEnv* env, jobject obj); | 109 void Reload(JNIEnv* env, jobject obj); |
68 jboolean NeedsReload(JNIEnv* env, jobject obj); | 110 jboolean NeedsReload(JNIEnv* env, jobject obj); |
69 void ClearHistory(JNIEnv* env, jobject obj); | 111 void ClearHistory(JNIEnv* env, jobject obj); |
70 void SetClient(JNIEnv* env, jobject obj, jobject jclient); | 112 void SetClient(JNIEnv* env, jobject obj, jobject jclient); |
71 | 113 |
72 // -------------------------------------------------------------------------- | 114 // -------------------------------------------------------------------------- |
73 // Public methods that call to Java via JNI | 115 // Public methods that call to Java via JNI |
74 // -------------------------------------------------------------------------- | 116 // -------------------------------------------------------------------------- |
75 | 117 |
76 // Creates a popup menu with |items|. | 118 // Creates a popup menu with |items|. |
77 // |multiple| defines if it should support multi-select. | 119 // |multiple| defines if it should support multi-select. |
78 // If not |multiple|, |selected_item| sets the initially selected item. | 120 // If not |multiple|, |selected_item| sets the initially selected item. |
79 // Otherwise, item's "checked" flag selects it. | 121 // Otherwise, item's "checked" flag selects it. |
80 void ShowSelectPopupMenu(const std::vector<WebMenuItem>& items, | 122 void ShowSelectPopupMenu(const std::vector<WebMenuItem>& items, |
81 int selected_item, | 123 int selected_item, |
82 bool multiple); | 124 bool multiple); |
83 | 125 |
84 void OnTabCrashed(const base::ProcessHandle handle); | 126 void OnTabCrashed(const base::ProcessHandle handle); |
85 void SetTitle(const string16& title); | 127 void SetTitle(const string16& title); |
86 | 128 |
87 bool HasFocus(); | 129 bool HasFocus(); |
130 void ConfirmTouchEvent(bool handled); | |
131 void DidSetNeedTouchEvents(bool need_touch_events); | |
88 void OnSelectionChanged(const std::string& text); | 132 void OnSelectionChanged(const std::string& text); |
89 void OnSelectionBoundsChanged(int startx, | 133 void OnSelectionBoundsChanged(int startx, |
90 int starty, | 134 int starty, |
91 base::i18n::TextDirection start_dir, | 135 base::i18n::TextDirection start_dir, |
92 int endx, | 136 int endx, |
93 int endy, | 137 int endy, |
94 base::i18n::TextDirection end_dir); | 138 base::i18n::TextDirection end_dir); |
95 | 139 |
96 // Called when page loading begins. | 140 // Called when page loading begins. |
97 void DidStartLoading(); | 141 void DidStartLoading(); |
(...skipping 26 matching lines...) Expand all Loading... | |
124 // Private methods that call to Java via JNI | 168 // Private methods that call to Java via JNI |
125 // -------------------------------------------------------------------------- | 169 // -------------------------------------------------------------------------- |
126 virtual ~ContentViewCoreImpl(); | 170 virtual ~ContentViewCoreImpl(); |
127 | 171 |
128 // -------------------------------------------------------------------------- | 172 // -------------------------------------------------------------------------- |
129 // Other private methods and data | 173 // Other private methods and data |
130 // -------------------------------------------------------------------------- | 174 // -------------------------------------------------------------------------- |
131 | 175 |
132 void InitJNI(JNIEnv* env, jobject obj); | 176 void InitJNI(JNIEnv* env, jobject obj); |
133 | 177 |
178 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid(); | |
179 | |
180 void SendGestureEvent(WebKit::WebInputEvent::Type type, long time_ms, | |
181 int x, int y, | |
182 float dx, float dy, bool link_preview_tap); | |
183 | |
134 void PostLoadUrl(const GURL& url); | 184 void PostLoadUrl(const GURL& url); |
135 | 185 |
136 struct JavaObject; | 186 struct JavaObject; |
137 JavaObject* java_object_; | 187 JavaObject* java_object_; |
138 | 188 |
139 // Reference to the current WebContents used to determine how and what to | 189 // Reference to the current WebContents used to determine how and what to |
140 // display in the ContentViewCore. | 190 // display in the ContentViewCore. |
141 WebContents* web_contents_; | 191 WebContents* web_contents_; |
142 | 192 |
143 // We only set this to be the delegate of the web_contents if we own it. | 193 // We only set this to be the delegate of the web_contents if we own it. |
144 scoped_ptr<ContentViewClient> content_view_client_; | 194 scoped_ptr<ContentViewClient> content_view_client_; |
145 | 195 |
146 // Whether the renderer backing this ContentViewCore has crashed. | 196 // Whether the renderer backing this ContentViewCore has crashed. |
147 bool tab_crashed_; | 197 bool tab_crashed_; |
148 | 198 |
149 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); | 199 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); |
150 }; | 200 }; |
151 | 201 |
152 bool RegisterContentViewCore(JNIEnv* env); | 202 bool RegisterContentViewCore(JNIEnv* env); |
153 | 203 |
154 }; // namespace content | 204 } // namespace content |
155 | 205 |
156 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 206 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
OLD | NEW |