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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "base/callback.h" | 45 #include "base/callback.h" |
| 46 #include "base/command_line.h" | 46 #include "base/command_line.h" |
| 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/android/autofill_provider_android.h" | |
| 55 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 56 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
| 56 #include "components/autofill/core/browser/autofill_manager.h" | 57 #include "components/autofill/core/browser/autofill_manager.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" |
| (...skipping 216 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/05/11 00:13:29
rename enabled to autocomplete_enabled
| |
| 292 // Do not initialize if the feature is not enabled. | |
| 293 if (!enabled) | |
| 294 return; | |
| 295 // Check if the autofill driver factory already exists. | 293 // Check if the autofill driver factory already exists. |
| 296 content::WebContents* web_contents = web_contents_.get(); | 294 content::WebContents* web_contents = web_contents_.get(); |
| 297 if (ContentAutofillDriverFactory::FromWebContents(web_contents)) | 295 if (ContentAutofillDriverFactory::FromWebContents(web_contents)) |
| 298 return; | 296 return; |
| 299 | 297 |
| 298 // Check if AutofillProvider is available. | |
| 299 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 300 JNIEnv* env = AttachCurrentThread(); | |
| 301 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 302 if (obj.is_null()) | |
| 303 return; | |
| 304 | |
| 305 base::android::ScopedJavaLocalRef<_jobject*> jAutofillProvider = | |
|
sgurun-gerrit only
2017/05/11 00:13:29
you can drop this once you use nativeSetJavaPeers.
michaelbai
2017/05/12 00:37:23
Done.
| |
| 306 Java_AwContents_getAutofillProvider(env, obj); | |
| 307 | |
| 308 // Just return, if the app neither targets for O nor enables autocomplete. | |
|
sgurun-gerrit only
2017/05/11 00:13:29
s/app targets for O/app runs on O SDK/
michaelbai
2017/05/12 00:37:23
Done.
| |
| 309 if (jAutofillProvider.is_null() && !enabled) | |
| 310 return; | |
| 311 | |
| 312 autofill_provider_ = base::MakeUnique<autofill::AutofillProviderAndroid>( | |
| 313 jAutofillProvider, web_contents); | |
| 300 AwAutofillClient::CreateForWebContents(web_contents); | 314 AwAutofillClient::CreateForWebContents(web_contents); |
| 301 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( | 315 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( |
| 302 web_contents, AwAutofillClient::FromWebContents(web_contents), | 316 web_contents, AwAutofillClient::FromWebContents(web_contents), |
| 303 base::android::GetDefaultLocaleString(), | 317 base::android::GetDefaultLocaleString(), |
| 304 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); | 318 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER, |
| 319 autofill_provider_.get()); | |
| 305 } | 320 } |
| 306 | 321 |
| 307 void AwContents::SetAwAutofillClient(const JavaRef<jobject>& client) { | 322 void AwContents::SetAwAutofillClient(const JavaRef<jobject>& client) { |
| 308 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 323 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 309 JNIEnv* env = AttachCurrentThread(); | 324 JNIEnv* env = AttachCurrentThread(); |
| 310 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 325 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 311 if (obj.is_null()) | 326 if (obj.is_null()) |
| 312 return; | 327 return; |
| 313 Java_AwContents_setAwAutofillClient(env, obj, client); | 328 Java_AwContents_setAwAutofillClient(env, obj, client); |
| 314 } | 329 } |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1357 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | 1372 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( |
| 1358 web_contents_->GetRenderProcessHost()->GetID(), url::kFileScheme); | 1373 web_contents_->GetRenderProcessHost()->GetID(), url::kFileScheme); |
| 1359 } | 1374 } |
| 1360 | 1375 |
| 1361 void AwContents::ResumeLoadingCreatedPopupWebContents( | 1376 void AwContents::ResumeLoadingCreatedPopupWebContents( |
| 1362 JNIEnv* env, | 1377 JNIEnv* env, |
| 1363 const JavaParamRef<jobject>& obj) { | 1378 const JavaParamRef<jobject>& obj) { |
| 1364 web_contents_->ResumeLoadingCreatedWebContents(); | 1379 web_contents_->ResumeLoadingCreatedWebContents(); |
| 1365 } | 1380 } |
| 1366 | 1381 |
| 1382 jlong AwContents::GetAutofillProvider( | |
| 1383 JNIEnv* env, | |
| 1384 const base::android::JavaParamRef<jobject>& obj) { | |
| 1385 return reinterpret_cast<jlong>(autofill_provider_.get()); | |
| 1386 } | |
| 1387 | |
| 1367 void SetShouldDownloadFavicons(JNIEnv* env, | 1388 void SetShouldDownloadFavicons(JNIEnv* env, |
| 1368 const JavaParamRef<jclass>& jclazz) { | 1389 const JavaParamRef<jclass>& jclazz) { |
| 1369 g_should_download_favicons = true; | 1390 g_should_download_favicons = true; |
| 1370 } | 1391 } |
| 1371 | 1392 |
| 1372 void AwContents::RenderViewHostChanged(content::RenderViewHost* old_host, | 1393 void AwContents::RenderViewHostChanged(content::RenderViewHost* old_host, |
| 1373 content::RenderViewHost* new_host) { | 1394 content::RenderViewHost* new_host) { |
| 1374 DCHECK(new_host); | 1395 DCHECK(new_host); |
| 1375 | 1396 |
| 1376 int process_id = new_host->GetProcess()->GetID(); | 1397 int process_id = new_host->GetProcess()->GetID(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1449 | 1470 |
| 1450 return Java_AwContents_onRenderProcessGoneDetail(env, obj, | 1471 return Java_AwContents_onRenderProcessGoneDetail(env, obj, |
| 1451 child_process_id, crashed); | 1472 child_process_id, crashed); |
| 1452 } | 1473 } |
| 1453 | 1474 |
| 1454 void AwContents::RenderProcessReady(content::RenderProcessHost* host) { | 1475 void AwContents::RenderProcessReady(content::RenderProcessHost* host) { |
| 1455 UpdateRendererPriority(); | 1476 UpdateRendererPriority(); |
| 1456 } | 1477 } |
| 1457 | 1478 |
| 1458 } // namespace android_webview | 1479 } // namespace android_webview |
| OLD | NEW |