| 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" |
| 21 | 24 |
| 22 using password_manager::PasswordStore; | 25 using password_manager::PasswordStore; |
| 23 | 26 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 NOTREACHED(); | 121 NOTREACHED(); |
| 119 return; | 122 return; |
| 120 } | 123 } |
| 121 if (IsAuthenticationRequired()) { | 124 if (IsAuthenticationRequired()) { |
| 122 if (password_manager_util::AuthenticateUser( | 125 if (password_manager_util::AuthenticateUser( |
| 123 password_view_->GetNativeWindow())) | 126 password_view_->GetNativeWindow())) |
| 124 last_authentication_time_ = base::TimeTicks::Now(); | 127 last_authentication_time_ = base::TimeTicks::Now(); |
| 125 else | 128 else |
| 126 return; | 129 return; |
| 127 } | 130 } |
| 131 |
| 132 if (password_manager_sync_metrics::IsPasswordSyncAccountCredential( |
| 133 password_view_->GetProfile(), |
| 134 UTF16ToUTF8(password_list_[index]->username_value), |
| 135 password_list_[index]->signon_realm)) { |
| 136 content::RecordAction( |
| 137 base::UserMetricsAction("PasswordManager_SyncCredentialShown")); |
| 138 } |
| 139 |
| 128 // Call back the front end to reveal the password. | 140 // Call back the front end to reveal the password. |
| 129 password_view_->ShowPassword(index, password_list_[index]->password_value); | 141 password_view_->ShowPassword(index, password_list_[index]->password_value); |
| 130 #endif | 142 #endif |
| 131 } | 143 } |
| 132 | 144 |
| 133 const autofill::PasswordForm* PasswordManagerPresenter::GetPassword( | 145 const autofill::PasswordForm* PasswordManagerPresenter::GetPassword( |
| 134 size_t index) { | 146 size_t index) { |
| 135 if (index >= password_list_.size()) { | 147 if (index >= password_list_.size()) { |
| 136 // |index| out of bounds might come from a compromised renderer, don't let | 148 // |index| out of bounds might come from a compromised renderer, don't let |
| 137 // it crash the browser. http://crbug.com/362054 | 149 // it crash the browser. http://crbug.com/362054 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 232 } |
| 221 | 233 |
| 222 void PasswordManagerPresenter::PasswordExceptionListPopulater:: | 234 void PasswordManagerPresenter::PasswordExceptionListPopulater:: |
| 223 OnGetPasswordStoreResults( | 235 OnGetPasswordStoreResults( |
| 224 const std::vector<autofill::PasswordForm*>& results) { | 236 const std::vector<autofill::PasswordForm*>& results) { |
| 225 page_->password_exception_list_.clear(); | 237 page_->password_exception_list_.clear(); |
| 226 page_->password_exception_list_.insert(page_->password_exception_list_.end(), | 238 page_->password_exception_list_.insert(page_->password_exception_list_.end(), |
| 227 results.begin(), results.end()); | 239 results.begin(), results.end()); |
| 228 page_->SetPasswordExceptionList(); | 240 page_->SetPasswordExceptionList(); |
| 229 } | 241 } |
| OLD | NEW |