| 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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "chrome/browser/password_manager/password_manager_util.h" | 11 #include "chrome/browser/password_manager/password_manager_util.h" |
| 12 #include "chrome/browser/password_manager/password_store_factory.h" | 12 #include "chrome/browser/password_manager/password_store_factory.h" |
| 13 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" | 13 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
| 14 #include "chrome/browser/password_manager/sync_metrics.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/sync/profile_sync_service.h" | 16 #include "chrome/browser/sync/profile_sync_service.h" |
| 16 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 17 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" | 18 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" |
| 18 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 19 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
| 21 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 22 #include "components/autofill/content/common/autofill_messages.h" | 23 #include "components/autofill/content/common/autofill_messages.h" |
| 23 #include "components/autofill/core/browser/password_generator.h" | 24 #include "components/autofill/core/browser/password_generator.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 if (!entry) { | 95 if (!entry) { |
| 95 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. | 96 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. |
| 96 return true; | 97 return true; |
| 97 } | 98 } |
| 98 // Do not fill nor save password when a user is signing in for sync. This | 99 // Do not fill nor save password when a user is signing in for sync. This |
| 99 // is because users need to remember their password if they are syncing as | 100 // is because users need to remember their password if they are syncing as |
| 100 // this is effectively their master password. | 101 // this is effectively their master password. |
| 101 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; | 102 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; |
| 102 } | 103 } |
| 103 | 104 |
| 105 bool ChromePasswordManagerClient::IsPasswordSyncAccountCredential( |
| 106 const std::string& username, const std::string& origin) const { |
| 107 return password_manager_sync_metrics::IsPasswordSyncAccountCredential( |
| 108 profile_, username, origin); |
| 109 } |
| 110 |
| 104 void ChromePasswordManagerClient::PromptUserToSavePassword( | 111 void ChromePasswordManagerClient::PromptUserToSavePassword( |
| 105 password_manager::PasswordFormManager* form_to_save) { | 112 password_manager::PasswordFormManager* form_to_save) { |
| 106 if (IsTheHotNewBubbleUIEnabled()) { | 113 if (IsTheHotNewBubbleUIEnabled()) { |
| 107 ManagePasswordsUIController* manage_passwords_ui_controller = | 114 ManagePasswordsUIController* manage_passwords_ui_controller = |
| 108 ManagePasswordsUIController::FromWebContents(web_contents()); | 115 ManagePasswordsUIController::FromWebContents(web_contents()); |
| 109 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save); | 116 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save); |
| 110 } else { | 117 } else { |
| 111 std::string uma_histogram_suffix( | 118 std::string uma_histogram_suffix( |
| 112 password_manager::metrics_util::GroupIdToString( | 119 password_manager::metrics_util::GroupIdToString( |
| 113 password_manager::metrics_util::MonitoredDomainGroupId( | 120 password_manager::metrics_util::MonitoredDomainGroupId( |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 369 |
| 363 if (command_line->HasSwitch( | 370 if (command_line->HasSwitch( |
| 364 password_manager::switches::kEnableManagerForSyncSignin)) | 371 password_manager::switches::kEnableManagerForSyncSignin)) |
| 365 return true; | 372 return true; |
| 366 | 373 |
| 367 // Default is enabled. | 374 // Default is enabled. |
| 368 std::string group_name = | 375 std::string group_name = |
| 369 base::FieldTrialList::FindFullName("PasswordManagerStateForSyncSignin"); | 376 base::FieldTrialList::FindFullName("PasswordManagerStateForSyncSignin"); |
| 370 return group_name != "Disabled"; | 377 return group_name != "Disabled"; |
| 371 } | 378 } |
| OLD | NEW |