| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 17 #include "chrome/browser/password_manager/password_store_factory.h" | 17 #include "chrome/browser/password_manager/password_store_factory.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/signin/signin_manager_factory.h" | 19 #include "chrome/browser/signin/signin_manager_factory.h" |
| 20 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 21 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" | 21 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" |
| 22 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" | 22 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" |
| 23 #include "chrome/common/channel_info.h" | 23 #include "chrome/common/channel_info.h" |
| 24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/common/features.h" |
| 25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 26 #include "components/autofill/content/browser/content_autofill_driver.h" | 27 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 27 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 28 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
| 28 #include "components/autofill/content/common/autofill_messages.h" | 29 #include "components/autofill/content/common/autofill_messages.h" |
| 29 #include "components/autofill/core/browser/password_generator.h" | 30 #include "components/autofill/core/browser/password_generator.h" |
| 30 #include "components/autofill/core/common/password_form.h" | 31 #include "components/autofill/core/common/password_form.h" |
| 31 #include "components/browser_sync/browser/profile_sync_service.h" | 32 #include "components/browser_sync/browser/profile_sync_service.h" |
| 32 #include "components/password_manager/content/browser/content_password_manager_d
river.h" | 33 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
| 33 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" | 34 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" |
| 34 #include "components/password_manager/content/common/credential_manager_messages
.h" | 35 #include "components/password_manager/content/common/credential_manager_messages
.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 #include "components/password_manager/sync/browser/password_sync_util.h" | 47 #include "components/password_manager/sync/browser/password_sync_util.h" |
| 47 #include "components/signin/core/browser/signin_manager.h" | 48 #include "components/signin/core/browser/signin_manager.h" |
| 48 #include "components/version_info/version_info.h" | 49 #include "components/version_info/version_info.h" |
| 49 #include "content/public/browser/navigation_entry.h" | 50 #include "content/public/browser/navigation_entry.h" |
| 50 #include "content/public/browser/render_view_host.h" | 51 #include "content/public/browser/render_view_host.h" |
| 51 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
| 52 #include "google_apis/gaia/gaia_urls.h" | 53 #include "google_apis/gaia/gaia_urls.h" |
| 53 #include "net/base/url_util.h" | 54 #include "net/base/url_util.h" |
| 54 #include "third_party/re2/re2/re2.h" | 55 #include "third_party/re2/re2/re2.h" |
| 55 | 56 |
| 56 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 57 #if defined(OS_MACOSX) || BUILDFLAG(ANDROID_JAVA_UI) |
| 57 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" | 58 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
| 58 #endif | 59 #endif |
| 59 | 60 |
| 60 #if defined(OS_ANDROID) | 61 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 61 #include "chrome/browser/android/tab_android.h" | 62 #include "chrome/browser/android/tab_android.h" |
| 62 #include "chrome/browser/password_manager/account_chooser_dialog_android.h" | 63 #include "chrome/browser/password_manager/account_chooser_dialog_android.h" |
| 63 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" | 64 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" |
| 64 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h" | 65 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h" |
| 65 #endif | 66 #endif |
| 66 | 67 |
| 67 using password_manager::ContentPasswordManagerDriverFactory; | 68 using password_manager::ContentPasswordManagerDriverFactory; |
| 68 using password_manager::PasswordManagerInternalsService; | 69 using password_manager::PasswordManagerInternalsService; |
| 69 | 70 |
| 70 // Shorten the name to spare line breaks. The code provides enough context | 71 // Shorten the name to spare line breaks. The code provides enough context |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 if (IsTheHotNewBubbleUIEnabled()) { | 222 if (IsTheHotNewBubbleUIEnabled()) { |
| 222 PasswordsClientUIDelegate* manage_passwords_ui_controller = | 223 PasswordsClientUIDelegate* manage_passwords_ui_controller = |
| 223 PasswordsClientUIDelegateFromWebContents(web_contents()); | 224 PasswordsClientUIDelegateFromWebContents(web_contents()); |
| 224 if (update_password && IsUpdatePasswordUIEnabled()) { | 225 if (update_password && IsUpdatePasswordUIEnabled()) { |
| 225 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( | 226 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( |
| 226 form_to_save.Pass()); | 227 form_to_save.Pass()); |
| 227 } else { | 228 } else { |
| 228 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass()); | 229 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass()); |
| 229 } | 230 } |
| 230 } else { | 231 } else { |
| 231 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 232 #if defined(OS_MACOSX) || BUILDFLAG(ANDROID_JAVA_UI) |
| 232 if (form_to_save->IsBlacklisted()) | 233 if (form_to_save->IsBlacklisted()) |
| 233 return false; | 234 return false; |
| 234 std::string uma_histogram_suffix( | 235 std::string uma_histogram_suffix( |
| 235 password_manager::metrics_util::GroupIdToString( | 236 password_manager::metrics_util::GroupIdToString( |
| 236 password_manager::metrics_util::MonitoredDomainGroupId( | 237 password_manager::metrics_util::MonitoredDomainGroupId( |
| 237 form_to_save->pending_credentials().signon_realm, GetPrefs()))); | 238 form_to_save->pending_credentials().signon_realm, GetPrefs()))); |
| 238 SavePasswordInfoBarDelegate::Create( | 239 SavePasswordInfoBarDelegate::Create( |
| 239 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type); | 240 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type); |
| 240 #else | 241 #else |
| 241 NOTREACHED() << "Aura platforms should always use the bubble"; | 242 NOTREACHED() << "Aura platforms should always use the bubble"; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 266 | 267 |
| 267 void ChromePasswordManagerClient::ForceSavePassword() { | 268 void ChromePasswordManagerClient::ForceSavePassword() { |
| 268 password_manager::ContentPasswordManagerDriver* driver = | 269 password_manager::ContentPasswordManagerDriver* driver = |
| 269 driver_factory_->GetDriverForFrame(web_contents()->GetFocusedFrame()); | 270 driver_factory_->GetDriverForFrame(web_contents()->GetFocusedFrame()); |
| 270 driver->ForceSavePassword(); | 271 driver->ForceSavePassword(); |
| 271 } | 272 } |
| 272 | 273 |
| 273 void ChromePasswordManagerClient::NotifyUserAutoSignin( | 274 void ChromePasswordManagerClient::NotifyUserAutoSignin( |
| 274 ScopedVector<autofill::PasswordForm> local_forms) { | 275 ScopedVector<autofill::PasswordForm> local_forms) { |
| 275 DCHECK(!local_forms.empty()); | 276 DCHECK(!local_forms.empty()); |
| 276 #if defined(OS_ANDROID) | 277 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 277 ShowAutoSigninPrompt(web_contents(), local_forms[0]->username_value); | 278 ShowAutoSigninPrompt(web_contents(), local_forms[0]->username_value); |
| 278 #else | 279 #else |
| 279 PasswordsClientUIDelegateFromWebContents(web_contents()) | 280 PasswordsClientUIDelegateFromWebContents(web_contents()) |
| 280 ->OnAutoSignin(local_forms.Pass()); | 281 ->OnAutoSignin(local_forms.Pass()); |
| 281 | 282 |
| 282 #endif | 283 #endif |
| 283 } | 284 } |
| 284 | 285 |
| 285 void ChromePasswordManagerClient::AutomaticPasswordSave( | 286 void ChromePasswordManagerClient::AutomaticPasswordSave( |
| 286 scoped_ptr<password_manager::PasswordFormManager> saved_form) { | 287 scoped_ptr<password_manager::PasswordFormManager> saved_form) { |
| 287 #if defined(OS_ANDROID) | 288 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 288 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents()); | 289 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents()); |
| 289 #else | 290 #else |
| 290 if (IsTheHotNewBubbleUIEnabled()) { | 291 if (IsTheHotNewBubbleUIEnabled()) { |
| 291 PasswordsClientUIDelegate* manage_passwords_ui_controller = | 292 PasswordsClientUIDelegate* manage_passwords_ui_controller = |
| 292 PasswordsClientUIDelegateFromWebContents(web_contents()); | 293 PasswordsClientUIDelegateFromWebContents(web_contents()); |
| 293 manage_passwords_ui_controller->OnAutomaticPasswordSave( | 294 manage_passwords_ui_controller->OnAutomaticPasswordSave( |
| 294 saved_form.Pass()); | 295 saved_form.Pass()); |
| 295 } | 296 } |
| 296 #endif | 297 #endif |
| 297 } | 298 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 web_contents(), web_contents()->GetNativeView()); | 467 web_contents(), web_contents()->GetNativeView()); |
| 467 popup_controller_->Show(false /* display_password */); | 468 popup_controller_->Show(false /* display_password */); |
| 468 } | 469 } |
| 469 | 470 |
| 470 void ChromePasswordManagerClient::GenerationAvailableForForm( | 471 void ChromePasswordManagerClient::GenerationAvailableForForm( |
| 471 const autofill::PasswordForm& form) { | 472 const autofill::PasswordForm& form) { |
| 472 password_manager_.GenerationAvailableForForm(form); | 473 password_manager_.GenerationAvailableForForm(form); |
| 473 } | 474 } |
| 474 | 475 |
| 475 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { | 476 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { |
| 476 #if defined(OS_ANDROID) | 477 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 477 return false; | 478 return false; |
| 478 #elif defined(OS_MACOSX) | 479 #elif defined(OS_MACOSX) |
| 479 // Query the group first for correct UMA reporting. | 480 // Query the group first for correct UMA reporting. |
| 480 std::string group_name = | 481 std::string group_name = |
| 481 base::FieldTrialList::FindFullName("PasswordManagerUI"); | 482 base::FieldTrialList::FindFullName("PasswordManagerUI"); |
| 482 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 483 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 483 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) | 484 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) |
| 484 return false; | 485 return false; |
| 485 | 486 |
| 486 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) | 487 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 535 |
| 535 const password_manager::CredentialsFilter* | 536 const password_manager::CredentialsFilter* |
| 536 ChromePasswordManagerClient::GetStoreResultFilter() const { | 537 ChromePasswordManagerClient::GetStoreResultFilter() const { |
| 537 return &credentials_filter_; | 538 return &credentials_filter_; |
| 538 } | 539 } |
| 539 | 540 |
| 540 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() | 541 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() |
| 541 const { | 542 const { |
| 542 return log_manager_.get(); | 543 return log_manager_.get(); |
| 543 } | 544 } |
| OLD | NEW |