Chromium Code Reviews| 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 <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include "base/location.h" | 47 #include "base/location.h" |
| 48 #include "base/memory/memory_pressure_listener.h" | 48 #include "base/memory/memory_pressure_listener.h" |
| 49 #include "base/memory/ptr_util.h" | 49 #include "base/memory/ptr_util.h" |
| 50 #include "base/pickle.h" | 50 #include "base/pickle.h" |
| 51 #include "base/single_thread_task_runner.h" | 51 #include "base/single_thread_task_runner.h" |
| 52 #include "base/strings/string16.h" | 52 #include "base/strings/string16.h" |
| 53 #include "base/supports_user_data.h" | 53 #include "base/supports_user_data.h" |
| 54 #include "base/threading/thread_task_runner_handle.h" | 54 #include "base/threading/thread_task_runner_handle.h" |
| 55 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 55 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
| 56 #include "components/autofill/core/browser/autofill_manager.h" | 56 #include "components/autofill/core/browser/autofill_manager.h" |
| 57 #include "components/autofill/core/browser/autofill_provider_android.h" | |
| 57 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 58 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 58 #include "components/navigation_interception/intercept_navigation_delegate.h" | 59 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 59 #include "content/public/browser/android/content_view_core.h" | 60 #include "content/public/browser/android/content_view_core.h" |
| 60 #include "content/public/browser/android/synchronous_compositor.h" | 61 #include "content/public/browser/android/synchronous_compositor.h" |
| 61 #include "content/public/browser/browser_thread.h" | 62 #include "content/public/browser/browser_thread.h" |
| 62 #include "content/public/browser/child_process_security_policy.h" | 63 #include "content/public/browser/child_process_security_policy.h" |
| 63 #include "content/public/browser/favicon_status.h" | 64 #include "content/public/browser/favicon_status.h" |
| 64 #include "content/public/browser/interstitial_page.h" | 65 #include "content/public/browser/interstitial_page.h" |
| 65 #include "content/public/browser/message_port_provider.h" | 66 #include "content/public/browser/message_port_provider.h" |
| 66 #include "content/public/browser/navigation_entry.h" | 67 #include "content/public/browser/navigation_entry.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 282 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 282 InitAutofillIfNecessary(enabled); | 283 InitAutofillIfNecessary(enabled); |
| 283 // We need to check for the existence, since autofill_manager_delegate | 284 // We need to check for the existence, since autofill_manager_delegate |
| 284 // may not be created when the setting is false. | 285 // may not be created when the setting is false. |
| 285 if (AwAutofillClient::FromWebContents(web_contents_.get())) { | 286 if (AwAutofillClient::FromWebContents(web_contents_.get())) { |
| 286 AwAutofillClient::FromWebContents(web_contents_.get())-> | 287 AwAutofillClient::FromWebContents(web_contents_.get())-> |
| 287 SetSaveFormData(enabled); | 288 SetSaveFormData(enabled); |
| 288 } | 289 } |
| 289 } | 290 } |
| 290 | 291 |
| 291 void AwContents::InitAutofillIfNecessary(bool enabled) { | 292 void AwContents::InitAutofillIfNecessary(bool enabled) { |
|
sgurun-gerrit only
2017/04/28 01:46:39
In O and above initautofillifnecessary should alwa
michaelbai
2017/05/03 04:43:59
Used different way, see new patch of this method.
| |
| 292 // Do not initialize if the feature is not enabled. | 293 // Do not initialize if the feature is not enabled. |
| 293 if (!enabled) | 294 if (!enabled) |
| 294 return; | 295 return; |
| 295 // Check if the autofill driver factory already exists. | 296 // Check if the autofill driver factory already exists. |
| 296 content::WebContents* web_contents = web_contents_.get(); | 297 content::WebContents* web_contents = web_contents_.get(); |
| 297 if (ContentAutofillDriverFactory::FromWebContents(web_contents)) | 298 if (ContentAutofillDriverFactory::FromWebContents(web_contents)) |
| 298 return; | 299 return; |
| 299 | 300 |
| 301 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 302 JNIEnv* env = AttachCurrentThread(); | |
| 303 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 304 if (obj.is_null()) | |
| 305 return; | |
| 306 | |
| 307 jlong nativeAutofillProvider = | |
| 308 Java_AwContents_getNativeAutofillAndroid(env, obj); | |
| 309 autofill_provider_.reset( | |
| 310 reinterpret_cast<autofill::AutofillProvider*>(nativeAutofillProvider)); | |
| 300 AwAutofillClient::CreateForWebContents(web_contents); | 311 AwAutofillClient::CreateForWebContents(web_contents); |
| 301 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( | 312 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( |
| 302 web_contents, AwAutofillClient::FromWebContents(web_contents), | 313 web_contents, AwAutofillClient::FromWebContents(web_contents), |
| 303 base::android::GetDefaultLocaleString(), | 314 base::android::GetDefaultLocaleString(), |
| 304 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); | 315 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER, |
| 316 autofill_provider_.get()); | |
| 305 } | 317 } |
| 306 | 318 |
| 307 void AwContents::SetAwAutofillClient(const JavaRef<jobject>& client) { | 319 void AwContents::SetAwAutofillClient(const JavaRef<jobject>& client) { |
| 308 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 320 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 309 JNIEnv* env = AttachCurrentThread(); | 321 JNIEnv* env = AttachCurrentThread(); |
| 310 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 322 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 311 if (obj.is_null()) | 323 if (obj.is_null()) |
| 312 return; | 324 return; |
| 313 Java_AwContents_setAwAutofillClient(env, obj, client); | 325 Java_AwContents_setAwAutofillClient(env, obj, client); |
| 314 } | 326 } |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1449 | 1461 |
| 1450 return Java_AwContents_onRenderProcessGoneDetail(env, obj, | 1462 return Java_AwContents_onRenderProcessGoneDetail(env, obj, |
| 1451 child_process_id, crashed); | 1463 child_process_id, crashed); |
| 1452 } | 1464 } |
| 1453 | 1465 |
| 1454 void AwContents::RenderProcessReady(content::RenderProcessHost* host) { | 1466 void AwContents::RenderProcessReady(content::RenderProcessHost* host) { |
| 1455 UpdateRendererPriority(); | 1467 UpdateRendererPriority(); |
| 1456 } | 1468 } |
| 1457 | 1469 |
| 1458 } // namespace android_webview | 1470 } // namespace android_webview |
| OLD | NEW |