| 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_form_manager.h" | 11 #include "chrome/browser/password_manager/password_form_manager.h" |
| 12 #include "chrome/browser/password_manager/password_manager.h" | 12 #include "chrome/browser/password_manager/password_manager.h" |
| 13 #include "chrome/browser/password_manager/password_manager_util.h" | 13 #include "chrome/browser/password_manager/password_manager_util.h" |
| 14 #include "chrome/browser/password_manager/password_store_factory.h" | 14 #include "chrome/browser/password_manager/password_store_factory.h" |
| 15 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" | 15 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/sync/profile_sync_service.h" | 17 #include "chrome/browser/sync/profile_sync_service.h" |
| 18 #include "chrome/browser/sync/profile_sync_service_factory.h" | 18 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 19 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" | 19 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
| 22 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 22 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 | 24 |
| 25 #if defined(OS_ANDROID) | 25 #if defined(OS_ANDROID) |
| 26 #include "chrome/browser/android/password_authentication_manager.h" | 26 #include "chrome/browser/android/password_authentication_manager.h" |
| 27 #endif // OS_ANDROID | 27 #endif // OS_ANDROID |
| 28 | 28 |
| 29 namespace { | |
| 30 | |
| 31 void ReportOsPassword() { | |
| 32 password_manager_util::OsPasswordStatus status = | |
| 33 password_manager_util::GetOsPasswordStatus(); | |
| 34 | |
| 35 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OsPasswordStatus", | |
| 36 status, | |
| 37 password_manager_util::MAX_PASSWORD_STATUS); | |
| 38 } | |
| 39 | |
| 40 } // namespace | |
| 41 | |
| 42 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient); | 29 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient); |
| 43 | 30 |
| 44 ChromePasswordManagerClient::ChromePasswordManagerClient( | 31 ChromePasswordManagerClient::ChromePasswordManagerClient( |
| 45 content::WebContents* web_contents) | 32 content::WebContents* web_contents) |
| 46 : web_contents_(web_contents), | 33 : web_contents_(web_contents), |
| 47 driver_(web_contents, this), | 34 driver_(web_contents, this), |
| 48 weak_factory_(this) { | 35 weak_factory_(this) { |
| 49 // Avoid checking OS password until later on in browser startup | |
| 50 // since it calls a few Windows APIs. | |
| 51 base::MessageLoopProxy::current()->PostDelayedTask( | |
| 52 FROM_HERE, | |
| 53 base::Bind(&ReportOsPassword), | |
| 54 base::TimeDelta::FromSeconds(10)); | |
| 55 } | 36 } |
| 56 | 37 |
| 57 ChromePasswordManagerClient::~ChromePasswordManagerClient() {} | 38 ChromePasswordManagerClient::~ChromePasswordManagerClient() {} |
| 58 | 39 |
| 59 void ChromePasswordManagerClient::PromptUserToSavePassword( | 40 void ChromePasswordManagerClient::PromptUserToSavePassword( |
| 60 PasswordFormManager* form_to_save) { | 41 PasswordFormManager* form_to_save) { |
| 61 if (CommandLine::ForCurrentProcess()->HasSwitch( | 42 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 62 switches::kEnableSavePasswordBubble)) { | 43 switches::kEnableSavePasswordBubble)) { |
| 63 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = | 44 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = |
| 64 ManagePasswordsBubbleUIController::FromWebContents(web_contents_); | 45 ManagePasswordsBubbleUIController::FromWebContents(web_contents_); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 ChromePasswordManagerClient::FromWebContents(contents); | 147 ChromePasswordManagerClient::FromWebContents(contents); |
| 167 if (!client) | 148 if (!client) |
| 168 return NULL; | 149 return NULL; |
| 169 return client->GetDriver()->GetPasswordManager(); | 150 return client->GetDriver()->GetPasswordManager(); |
| 170 } | 151 } |
| 171 | 152 |
| 172 void ChromePasswordManagerClient::CommitFillPasswordForm( | 153 void ChromePasswordManagerClient::CommitFillPasswordForm( |
| 173 autofill::PasswordFormFillData* data) { | 154 autofill::PasswordFormFillData* data) { |
| 174 driver_.FillPasswordForm(*data); | 155 driver_.FillPasswordForm(*data); |
| 175 } | 156 } |
| OLD | NEW |