| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/passwords/password_manager_presenter.h" | 5 #include "chrome/browser/ui/passwords/password_manager_presenter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/metrics/user_metrics_action.h" |
| 9 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 11 #include "base/values.h" | 13 #include "base/values.h" |
| 12 #include "chrome/browser/password_manager/password_manager_util.h" | 14 #include "chrome/browser/password_manager/password_manager_util.h" |
| 13 #include "chrome/browser/password_manager/password_store_factory.h" | 15 #include "chrome/browser/password_manager/password_store_factory.h" |
| 16 #include "chrome/browser/password_manager/sync_metrics.h" |
| 14 #include "chrome/browser/ui/passwords/password_ui_view.h" | 17 #include "chrome/browser/ui/passwords/password_ui_view.h" |
| 15 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 17 #include "components/autofill/core/common/password_form.h" | 20 #include "components/autofill/core/common/password_form.h" |
| 18 #include "components/password_manager/core/common/password_manager_pref_names.h" | 21 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 19 #include "content/public/browser/user_metrics.h" | 22 #include "content/public/browser/user_metrics.h" |
| 20 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "google_apis/gaia/gaia_auth_util.h" |
| 25 #include "google_apis/gaia/gaia_urls.h" |
| 21 | 26 |
| 22 using password_manager::PasswordStore; | 27 using password_manager::PasswordStore; |
| 23 | 28 |
| 24 PasswordManagerPresenter::PasswordManagerPresenter( | 29 PasswordManagerPresenter::PasswordManagerPresenter( |
| 25 PasswordUIView* password_view) | 30 PasswordUIView* password_view) |
| 26 : populater_(this), | 31 : populater_(this), |
| 27 exception_populater_(this), | 32 exception_populater_(this), |
| 28 password_view_(password_view) { | 33 password_view_(password_view) { |
| 29 DCHECK(password_view_); | 34 DCHECK(password_view_); |
| 30 require_reauthentication_ = !CommandLine::ForCurrentProcess()->HasSwitch( | 35 require_reauthentication_ = !CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 NOTREACHED(); | 123 NOTREACHED(); |
| 119 return; | 124 return; |
| 120 } | 125 } |
| 121 if (IsAuthenticationRequired()) { | 126 if (IsAuthenticationRequired()) { |
| 122 if (password_manager_util::AuthenticateUser( | 127 if (password_manager_util::AuthenticateUser( |
| 123 password_view_->GetNativeWindow())) | 128 password_view_->GetNativeWindow())) |
| 124 last_authentication_time_ = base::TimeTicks::Now(); | 129 last_authentication_time_ = base::TimeTicks::Now(); |
| 125 else | 130 else |
| 126 return; | 131 return; |
| 127 } | 132 } |
| 133 |
| 134 std::string sync_username; |
| 135 password_manager::SyncState sync_state; |
| 136 password_manager_sync_metrics::GetSyncUsernameAndState( |
| 137 password_view_->GetProfile(), &sync_username, &sync_state); |
| 138 |
| 139 if ((password_list_[index]->signon_realm == |
| 140 GaiaUrls::GetInstance()->gaia_url().GetOrigin().spec()) && |
| 141 gaia::AreEmailsSame(UTF16ToUTF8(password_list_[index]->username_value), |
| 142 sync_username)) { |
| 143 content::RecordAction( |
| 144 base::UserMetricsAction("PasswordManager_SyncCredentialShown")); |
| 145 } |
| 146 |
| 128 // Call back the front end to reveal the password. | 147 // Call back the front end to reveal the password. |
| 129 password_view_->ShowPassword(index, password_list_[index]->password_value); | 148 password_view_->ShowPassword(index, password_list_[index]->password_value); |
| 130 #endif | 149 #endif |
| 131 } | 150 } |
| 132 | 151 |
| 133 const autofill::PasswordForm* PasswordManagerPresenter::GetPassword( | 152 const autofill::PasswordForm* PasswordManagerPresenter::GetPassword( |
| 134 size_t index) { | 153 size_t index) { |
| 135 if (index >= password_list_.size()) { | 154 if (index >= password_list_.size()) { |
| 136 // |index| out of bounds might come from a compromised renderer, don't let | 155 // |index| out of bounds might come from a compromised renderer, don't let |
| 137 // it crash the browser. http://crbug.com/362054 | 156 // it crash the browser. http://crbug.com/362054 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 239 } |
| 221 | 240 |
| 222 void PasswordManagerPresenter::PasswordExceptionListPopulater:: | 241 void PasswordManagerPresenter::PasswordExceptionListPopulater:: |
| 223 OnGetPasswordStoreResults( | 242 OnGetPasswordStoreResults( |
| 224 const std::vector<autofill::PasswordForm*>& results) { | 243 const std::vector<autofill::PasswordForm*>& results) { |
| 225 page_->password_exception_list_.clear(); | 244 page_->password_exception_list_.clear(); |
| 226 page_->password_exception_list_.insert(page_->password_exception_list_.end(), | 245 page_->password_exception_list_.insert(page_->password_exception_list_.end(), |
| 227 results.begin(), results.end()); | 246 results.begin(), results.end()); |
| 228 page_->SetPasswordExceptionList(); | 247 page_->SetPasswordExceptionList(); |
| 229 } | 248 } |
| OLD | NEW |