| 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 "components/autofill/content/common/autofill_messages.h" | 22 #include "components/autofill/content/common/autofill_messages.h" |
| 22 #include "components/autofill/core/browser/password_generator.h" | 23 #include "components/autofill/core/browser/password_generator.h" |
| 23 #include "components/autofill/core/common/password_form.h" | 24 #include "components/autofill/core/common/password_form.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 service->UnregisterClient(this); | 75 service->UnregisterClient(this); |
| 75 } | 76 } |
| 76 | 77 |
| 77 bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const { | 78 bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const { |
| 78 return CommandLine::ForCurrentProcess()->HasSwitch( | 79 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 79 password_manager::switches::kEnableAutomaticPasswordSaving) && | 80 password_manager::switches::kEnableAutomaticPasswordSaving) && |
| 80 chrome::VersionInfo::GetChannel() == | 81 chrome::VersionInfo::GetChannel() == |
| 81 chrome::VersionInfo::CHANNEL_UNKNOWN; | 82 chrome::VersionInfo::CHANNEL_UNKNOWN; |
| 82 } | 83 } |
| 83 | 84 |
| 85 bool ChromePasswordManagerClient::IsPasswordSyncAccountCredential( |
| 86 const std::string& username, const std::string& origin) const { |
| 87 return password_manager_sync_metrics::IsPasswordSyncAccountCredential( |
| 88 profile_, username, origin); |
| 89 } |
| 90 |
| 84 void ChromePasswordManagerClient::PromptUserToSavePassword( | 91 void ChromePasswordManagerClient::PromptUserToSavePassword( |
| 85 password_manager::PasswordFormManager* form_to_save) { | 92 password_manager::PasswordFormManager* form_to_save) { |
| 86 if (IsTheHotNewBubbleUIEnabled()) { | 93 if (IsTheHotNewBubbleUIEnabled()) { |
| 87 ManagePasswordsUIController* manage_passwords_ui_controller = | 94 ManagePasswordsUIController* manage_passwords_ui_controller = |
| 88 ManagePasswordsUIController::FromWebContents(web_contents()); | 95 ManagePasswordsUIController::FromWebContents(web_contents()); |
| 89 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save); | 96 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save); |
| 90 } else { | 97 } else { |
| 91 std::string uma_histogram_suffix( | 98 std::string uma_histogram_suffix( |
| 92 password_manager::metrics_util::GroupIdToString( | 99 password_manager::metrics_util::GroupIdToString( |
| 93 password_manager::metrics_util::MonitoredDomainGroupId( | 100 password_manager::metrics_util::MonitoredDomainGroupId( |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 333 |
| 327 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) | 334 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) |
| 328 return true; | 335 return true; |
| 329 | 336 |
| 330 std::string group_name = | 337 std::string group_name = |
| 331 base::FieldTrialList::FindFullName("PasswordManagerUI"); | 338 base::FieldTrialList::FindFullName("PasswordManagerUI"); |
| 332 | 339 |
| 333 // The bubble should be the default case that runs on the bots. | 340 // The bubble should be the default case that runs on the bots. |
| 334 return group_name != "Infobar"; | 341 return group_name != "Infobar"; |
| 335 } | 342 } |
| OLD | NEW |