| 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 ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
| 6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> |
| 12 | 13 |
| 13 #include "android_webview/browser/browser_view_renderer.h" | 14 #include "android_webview/browser/browser_view_renderer.h" |
| 14 #include "android_webview/browser/find_helper.h" | 15 #include "android_webview/browser/find_helper.h" |
| 15 #include "android_webview/browser/icon_helper.h" | 16 #include "android_webview/browser/icon_helper.h" |
| 16 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 17 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
| 17 #include "base/android/scoped_java_ref.h" | 18 #include "base/android/scoped_java_ref.h" |
| 18 #include "base/android/jni_helper.h" | 19 #include "base/android/jni_helper.h" |
| 19 #include "base/callback_forward.h" | 20 #include "base/callback_forward.h" |
| 20 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 21 | 22 |
| 22 class SkBitmap; | 23 class SkBitmap; |
| 23 class TabContents; | 24 class TabContents; |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 class WebContents; | 27 class WebContents; |
| 27 } | 28 } |
| 28 | 29 |
| 30 namespace gfx { |
| 31 class RectF; |
| 32 } |
| 33 |
| 29 namespace android_webview { | 34 namespace android_webview { |
| 30 | 35 |
| 31 class AwContentsContainer; | 36 class AwContentsContainer; |
| 32 class AwContentsClientBridge; | 37 class AwContentsClientBridge; |
| 33 class AwWebContentsDelegate; | 38 class AwWebContentsDelegate; |
| 34 | 39 |
| 35 // Native side of java-class of same name. | 40 // Native side of java-class of same name. |
| 36 // Provides the ownership of and access to browser components required for | 41 // Provides the ownership of and access to browser components required for |
| 37 // WebView functionality; analogous to chrome's TabContents, but with a | 42 // WebView functionality; analogous to chrome's TabContents, but with a |
| 38 // level of indirection provided by the AwContentsContainer abstraction. | 43 // level of indirection provided by the AwContentsContainer abstraction. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 jboolean enabled); | 116 jboolean enabled); |
| 112 | 117 |
| 113 // Geolocation API support | 118 // Geolocation API support |
| 114 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); | 119 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); |
| 115 void HideGeolocationPrompt(const GURL& origin); | 120 void HideGeolocationPrompt(const GURL& origin); |
| 116 void InvokeGeolocationCallback(JNIEnv* env, | 121 void InvokeGeolocationCallback(JNIEnv* env, |
| 117 jobject obj, | 122 jobject obj, |
| 118 jboolean value, | 123 jboolean value, |
| 119 jstring origin); | 124 jstring origin); |
| 120 | 125 |
| 126 void SuggestionSelected(JNIEnv* env, |
| 127 jobject obj, |
| 128 int position); |
| 129 |
| 121 // Find-in-page API and related methods. | 130 // Find-in-page API and related methods. |
| 122 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string); | 131 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string); |
| 123 void FindNext(JNIEnv* env, jobject obj, jboolean forward); | 132 void FindNext(JNIEnv* env, jobject obj, jboolean forward); |
| 124 void ClearMatches(JNIEnv* env, jobject obj); | 133 void ClearMatches(JNIEnv* env, jobject obj); |
| 125 FindHelper* GetFindHelper(); | 134 FindHelper* GetFindHelper(); |
| 126 | 135 |
| 127 // FindHelper::Listener implementation. | 136 // FindHelper::Listener implementation. |
| 128 virtual void OnFindResultReceived(int active_ordinal, | 137 virtual void OnFindResultReceived(int active_ordinal, |
| 129 int match_count, | 138 int match_count, |
| 130 bool finished) OVERRIDE; | 139 bool finished) OVERRIDE; |
| 131 // IconHelper::Listener implementation. | 140 // IconHelper::Listener implementation. |
| 132 virtual void OnReceivedIcon(const SkBitmap& bitmap) OVERRIDE; | 141 virtual void OnReceivedIcon(const SkBitmap& bitmap) OVERRIDE; |
| 133 virtual void OnReceivedTouchIconUrl(const std::string& url, | 142 virtual void OnReceivedTouchIconUrl(const std::string& url, |
| 134 const bool precomposed) OVERRIDE; | 143 const bool precomposed) OVERRIDE; |
| 135 | 144 |
| 136 // AwRenderViewHostExtClient implementation. | 145 // AwRenderViewHostExtClient implementation. |
| 137 virtual void OnPageScaleFactorChanged(float page_scale_factor) OVERRIDE; | 146 virtual void OnPageScaleFactorChanged(float page_scale_factor) OVERRIDE; |
| 138 | 147 |
| 139 // BrowserViewRenderer::Client implementation. | 148 // BrowserViewRenderer::Client implementation. |
| 140 virtual void RequestProcessMode() OVERRIDE; | 149 virtual void RequestProcessMode() OVERRIDE; |
| 141 virtual void Invalidate() OVERRIDE; | 150 virtual void Invalidate() OVERRIDE; |
| 142 virtual void OnNewPicture() OVERRIDE; | 151 virtual void OnNewPicture() OVERRIDE; |
| 143 virtual gfx::Point GetLocationOnScreen() OVERRIDE; | 152 virtual gfx::Point GetLocationOnScreen() OVERRIDE; |
| 144 | 153 |
| 145 void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files); | 154 void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files); |
| 146 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); | 155 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); |
| 147 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); | 156 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); |
| 148 | 157 |
| 149 void SetSaveFormData(bool enabled); | 158 void SetSaveFormData(bool enabled); |
| 150 | 159 void ShowAutofillPopup(const gfx::RectF& element_bounds, |
| 160 const std::vector<string16>& values, |
| 161 const std::vector<string16>& labels, |
| 162 const std::vector<int>& identifiers); |
| 163 void HideAutofillPopup(); |
| 151 private: | 164 private: |
| 152 void SetWebContents(content::WebContents* web_contents); | 165 void SetWebContents(content::WebContents* web_contents); |
| 153 void InitAutofillIfNecessary(bool enabled); | 166 void InitAutofillIfNecessary(bool enabled); |
| 154 | 167 |
| 155 JavaObjectWeakGlobalRef java_ref_; | 168 JavaObjectWeakGlobalRef java_ref_; |
| 156 scoped_ptr<content::WebContents> web_contents_; | 169 scoped_ptr<content::WebContents> web_contents_; |
| 157 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 170 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
| 158 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; | 171 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; |
| 159 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; | 172 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; |
| 160 scoped_ptr<FindHelper> find_helper_; | 173 scoped_ptr<FindHelper> find_helper_; |
| 161 scoped_ptr<IconHelper> icon_helper_; | 174 scoped_ptr<IconHelper> icon_helper_; |
| 162 scoped_ptr<content::WebContents> pending_contents_; | 175 scoped_ptr<content::WebContents> pending_contents_; |
| 163 scoped_ptr<BrowserViewRenderer> browser_view_renderer_; | 176 scoped_ptr<BrowserViewRenderer> browser_view_renderer_; |
| 164 | 177 |
| 165 // GURL is supplied by the content layer as requesting frame. | 178 // GURL is supplied by the content layer as requesting frame. |
| 166 // Callback is supplied by the content layer, and is invoked with the result | 179 // Callback is supplied by the content layer, and is invoked with the result |
| 167 // from the permission prompt. | 180 // from the permission prompt. |
| 168 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; | 181 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; |
| 169 // The first element in the list is always the currently pending request. | 182 // The first element in the list is always the currently pending request. |
| 170 std::list<OriginCallback> pending_geolocation_prompts_; | 183 std::list<OriginCallback> pending_geolocation_prompts_; |
| 171 | 184 |
| 172 DISALLOW_COPY_AND_ASSIGN(AwContents); | 185 DISALLOW_COPY_AND_ASSIGN(AwContents); |
| 173 }; | 186 }; |
| 174 | 187 |
| 175 bool RegisterAwContents(JNIEnv* env); | 188 bool RegisterAwContents(JNIEnv* env); |
| 176 | 189 |
| 177 } // namespace android_webview | 190 } // namespace android_webview |
| 178 | 191 |
| 179 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 192 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
| OLD | NEW |