OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "android_webview/native/aw_contents.h" | 5 #include "android_webview/native/aw_contents.h" |
6 | 6 |
7 #include "android_webview/browser/aw_autofill_external_delegate.h" | |
7 #include "android_webview/browser/aw_browser_context.h" | 8 #include "android_webview/browser/aw_browser_context.h" |
8 #include "android_webview/browser/aw_browser_main_parts.h" | 9 #include "android_webview/browser/aw_browser_main_parts.h" |
9 #include "android_webview/browser/browser_view_renderer_impl.h" | 10 #include "android_webview/browser/browser_view_renderer_impl.h" |
10 #include "android_webview/browser/gpu_memory_buffer_impl.h" | 11 #include "android_webview/browser/gpu_memory_buffer_impl.h" |
11 #include "android_webview/browser/net_disk_cache_remover.h" | 12 #include "android_webview/browser/net_disk_cache_remover.h" |
12 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" | 13 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" |
13 #include "android_webview/common/aw_hit_test_data.h" | 14 #include "android_webview/common/aw_hit_test_data.h" |
14 #include "android_webview/native/aw_browser_dependency_factory.h" | 15 #include "android_webview/native/aw_browser_dependency_factory.h" |
15 #include "android_webview/native/aw_contents_client_bridge.h" | 16 #include "android_webview/native/aw_contents_client_bridge.h" |
16 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 17 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
17 #include "android_webview/native/aw_web_contents_delegate.h" | 18 #include "android_webview/native/aw_web_contents_delegate.h" |
18 #include "android_webview/native/java_browser_view_renderer_helper.h" | 19 #include "android_webview/native/java_browser_view_renderer_helper.h" |
19 #include "android_webview/native/state_serializer.h" | 20 #include "android_webview/native/state_serializer.h" |
20 #include "android_webview/public/browser/draw_gl.h" | 21 #include "android_webview/public/browser/draw_gl.h" |
21 #include "base/android/jni_android.h" | 22 #include "base/android/jni_android.h" |
22 #include "base/android/jni_array.h" | 23 #include "base/android/jni_array.h" |
23 #include "base/android/jni_string.h" | 24 #include "base/android/jni_string.h" |
24 #include "base/android/scoped_java_ref.h" | 25 #include "base/android/scoped_java_ref.h" |
25 #include "base/bind.h" | 26 #include "base/bind.h" |
26 #include "base/callback.h" | 27 #include "base/callback.h" |
27 #include "base/message_loop.h" | 28 #include "base/message_loop.h" |
28 #include "base/pickle.h" | 29 #include "base/pickle.h" |
29 #include "base/string16.h" | 30 #include "base/string16.h" |
30 #include "base/supports_user_data.h" | 31 #include "base/supports_user_data.h" |
31 #include "components/autofill/browser/autofill_external_delegate.h" | |
32 #include "components/autofill/browser/autofill_manager.h" | 32 #include "components/autofill/browser/autofill_manager.h" |
33 #include "components/autofill/browser/webdata/autofill_webdata_service.h" | 33 #include "components/autofill/browser/webdata/autofill_webdata_service.h" |
34 #include "components/navigation_interception/intercept_navigation_delegate.h" | 34 #include "components/navigation_interception/intercept_navigation_delegate.h" |
35 #include "content/public/browser/android/content_view_core.h" | 35 #include "content/public/browser/android/content_view_core.h" |
36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/cert_store.h" | 37 #include "content/public/browser/cert_store.h" |
38 #include "content/public/browser/navigation_entry.h" | 38 #include "content/public/browser/navigation_entry.h" |
39 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
40 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
41 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
42 #include "content/public/common/ssl_status.h" | 42 #include "content/public/common/ssl_status.h" |
43 #include "jni/AwContents_jni.h" | 43 #include "jni/AwContents_jni.h" |
44 #include "net/cert/x509_certificate.h" | 44 #include "net/cert/x509_certificate.h" |
45 #include "ui/base/l10n/l10n_util_android.h" | 45 #include "ui/base/l10n/l10n_util_android.h" |
46 #include "ui/gfx/android/java_bitmap.h" | 46 #include "ui/gfx/android/java_bitmap.h" |
47 | 47 |
48 struct AwDrawSWFunctionTable; | 48 struct AwDrawSWFunctionTable; |
49 struct AwDrawGLFunctionTable; | 49 struct AwDrawGLFunctionTable; |
50 | 50 |
51 using autofill::AutofillExternalDelegate; | |
52 using autofill::AutofillManager; | 51 using autofill::AutofillManager; |
53 using base::android::AttachCurrentThread; | 52 using base::android::AttachCurrentThread; |
54 using base::android::ConvertJavaStringToUTF16; | 53 using base::android::ConvertJavaStringToUTF16; |
55 using base::android::ConvertJavaStringToUTF8; | 54 using base::android::ConvertJavaStringToUTF8; |
56 using base::android::ConvertUTF16ToJavaString; | 55 using base::android::ConvertUTF16ToJavaString; |
57 using base::android::ConvertUTF8ToJavaString; | 56 using base::android::ConvertUTF8ToJavaString; |
58 using base::android::JavaRef; | 57 using base::android::JavaRef; |
59 using base::android::ScopedJavaGlobalRef; | 58 using base::android::ScopedJavaGlobalRef; |
60 using base::android::ScopedJavaLocalRef; | 59 using base::android::ScopedJavaLocalRef; |
61 using components::InterceptNavigationDelegate; | 60 using components::InterceptNavigationDelegate; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 icon_helper_->SetListener(this); | 146 icon_helper_->SetListener(this); |
148 web_contents_->SetUserData(kAwContentsUserDataKey, | 147 web_contents_->SetUserData(kAwContentsUserDataKey, |
149 new AwContentsUserData(this)); | 148 new AwContentsUserData(this)); |
150 AwContentsClientBridgeBase::Associate(web_contents_.get(), | 149 AwContentsClientBridgeBase::Associate(web_contents_.get(), |
151 contents_client_bridge_.get()); | 150 contents_client_bridge_.get()); |
152 web_contents_->SetDelegate(web_contents_delegate_.get()); | 151 web_contents_->SetDelegate(web_contents_delegate_.get()); |
153 render_view_host_ext_.reset( | 152 render_view_host_ext_.reset( |
154 new AwRenderViewHostExt(this, web_contents_.get())); | 153 new AwRenderViewHostExt(this, web_contents_.get())); |
155 | 154 |
156 AwAutofillManagerDelegate* autofill_manager_delegate = | 155 AwAutofillManagerDelegate* autofill_manager_delegate = |
157 AwBrowserContext::FromWebContents(web_contents_.get())-> | 156 AwAutofillManagerDelegate::FromWebContents(web_contents_.get()); |
158 AutofillManagerDelegate(); | |
159 if (autofill_manager_delegate) | 157 if (autofill_manager_delegate) |
160 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); | 158 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); |
161 } | 159 } |
162 | 160 |
163 void AwContents::SetSaveFormData(bool enabled) { | 161 void AwContents::SetSaveFormData(bool enabled) { |
164 InitAutofillIfNecessary(enabled); | 162 InitAutofillIfNecessary(enabled); |
165 // We need to check for the existence, since autofill_manager_delegate | 163 AwAutofillManagerDelegate::FromWebContents(web_contents_.get())-> |
166 // may not be created when the setting is false. | 164 SetSaveFormData(enabled); |
167 if (AutofillManager::FromWebContents(web_contents_.get())) { | |
168 AwAutofillManagerDelegate* autofill_manager_delegate = | |
169 AwBrowserContext::FromWebContents(web_contents_.get())-> | |
170 AutofillManagerDelegate(); | |
171 autofill_manager_delegate->SetSaveFormData(enabled); | |
172 } | |
173 } | 165 } |
174 | 166 |
175 void AwContents::InitAutofillIfNecessary(bool enabled) { | 167 void AwContents::InitAutofillIfNecessary(bool enabled) { |
176 // Do not initialize if the feature is not enabled. | 168 // Do not initialize if the feature is not enabled. |
177 if (!enabled) | 169 if (!enabled) |
178 return; | 170 return; |
179 // Check if the autofill manager already exists. | 171 |
180 content::WebContents* web_contents = web_contents_.get(); | 172 content::WebContents* web_contents = web_contents_.get(); |
181 if (AutofillManager::FromWebContents(web_contents)) | 173 if (AutofillManager::FromWebContents(web_contents)) |
182 return; | 174 return; |
183 | 175 |
176 AwBrowserContext::FromWebContents(web_contents)-> | |
177 CreateUserPrefServiceIfNecessary(); | |
178 | |
179 AwAutofillManagerDelegate::CreateForWebContents(web_contents); | |
180 | |
184 AutofillManager::CreateForWebContentsAndDelegate( | 181 AutofillManager::CreateForWebContentsAndDelegate( |
185 web_contents, | 182 web_contents, |
186 AwBrowserContext::FromWebContents(web_contents)-> | 183 AwAutofillManagerDelegate::FromWebContents(web_contents), |
187 CreateAutofillManagerDelegate(enabled), | |
188 l10n_util::GetDefaultLocale(), | 184 l10n_util::GetDefaultLocale(), |
189 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); | 185 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); |
190 AutofillManager* autofill_manager = | 186 AutofillManager* autofill_manager = |
191 AutofillManager::FromWebContents(web_contents); | 187 AutofillManager::FromWebContents(web_contents); |
192 AutofillExternalDelegate::CreateForWebContentsAndManager( | 188 AwAutofillExternalDelegate::CreateForWebContentsAndManager( |
benm (inactive)
2013/05/23 12:02:21
nit: move this consctruction into the setter below
sgurun-gerrit only
2013/05/23 17:10:01
not sure if I understand right (I did not have a m
| |
193 web_contents, | 189 web_contents, |
194 autofill_manager); | 190 autofill_manager); |
195 autofill_manager->SetExternalDelegate( | 191 autofill_manager->SetExternalDelegate( |
196 AutofillExternalDelegate::FromWebContents(web_contents)); | 192 AwAutofillExternalDelegate::FromWebContents(web_contents)); |
197 } | 193 } |
198 | 194 |
199 void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) { | 195 void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) { |
200 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc)); | 196 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc)); |
201 } | 197 } |
202 | 198 |
203 AwContents::~AwContents() { | 199 AwContents::~AwContents() { |
204 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this); | 200 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this); |
205 web_contents_->RemoveUserData(kAwContentsUserDataKey); | 201 web_contents_->RemoveUserData(kAwContentsUserDataKey); |
206 if (find_helper_.get()) | 202 if (find_helper_.get()) |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 return browser_view_renderer_->CapturePicture(); | 702 return browser_view_renderer_->CapturePicture(); |
707 } | 703 } |
708 | 704 |
709 void AwContents::EnableOnNewPicture(JNIEnv* env, | 705 void AwContents::EnableOnNewPicture(JNIEnv* env, |
710 jobject obj, | 706 jobject obj, |
711 jboolean enabled) { | 707 jboolean enabled) { |
712 browser_view_renderer_->EnableOnNewPicture(enabled); | 708 browser_view_renderer_->EnableOnNewPicture(enabled); |
713 } | 709 } |
714 | 710 |
715 } // namespace android_webview | 711 } // namespace android_webview |
OLD | NEW |