| 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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/password_manager/password_manager_util.h" | 12 #include "chrome/browser/password_manager/password_manager_util.h" |
| 13 #include "chrome/browser/password_manager/password_store_factory.h" | 13 #include "chrome/browser/password_manager/password_store_factory.h" |
| 14 #include "chrome/browser/ui/passwords/password_ui_view.h" | 14 #include "chrome/browser/ui/passwords/password_ui_view.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "components/autofill/core/common/password_form.h" | 18 #include "components/autofill/core/common/password_form.h" |
| 19 #include "content/public/browser/user_metrics.h" | 19 #include "content/public/browser/user_metrics.h" |
| 20 #include "content/public/browser/web_contents.h" |
| 20 | 21 |
| 21 PasswordManagerPresenter::PasswordManagerPresenter( | 22 PasswordManagerPresenter::PasswordManagerPresenter( |
| 22 PasswordUIView* password_view) | 23 PasswordUIView* password_view) |
| 23 : populater_(this), | 24 : populater_(this), |
| 24 exception_populater_(this), | 25 exception_populater_(this), |
| 25 password_view_(password_view) { | 26 password_view_(password_view) { |
| 26 DCHECK(password_view_); | 27 DCHECK(password_view_); |
| 27 require_reauthentication_ = CommandLine::ForCurrentProcess()->HasSwitch( | 28 require_reauthentication_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 28 switches::kEnablePasswordManagerReauthentication); | 29 switches::kEnablePasswordManagerReauthentication); |
| 29 } | 30 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 if (!store) | 89 if (!store) |
| 89 return; | 90 return; |
| 90 store->RemoveLogin(*password_exception_list_[index]); | 91 store->RemoveLogin(*password_exception_list_[index]); |
| 91 content::RecordAction( | 92 content::RecordAction( |
| 92 content::UserMetricsAction("PasswordManager_RemovePasswordException")); | 93 content::UserMetricsAction("PasswordManager_RemovePasswordException")); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void PasswordManagerPresenter::RequestShowPassword(size_t index) { | 96 void PasswordManagerPresenter::RequestShowPassword(size_t index) { |
| 96 DCHECK_LT(index, password_list_.size()); | 97 DCHECK_LT(index, password_list_.size()); |
| 97 if (IsAuthenticationRequired()) { | 98 if (IsAuthenticationRequired()) { |
| 98 if (password_manager_util::AuthenticateUser()) | 99 if (password_manager_util::AuthenticateUser( |
| 100 password_view_->GetWebContents())) |
| 99 last_authentication_time_ = base::TimeTicks::Now(); | 101 last_authentication_time_ = base::TimeTicks::Now(); |
| 100 else | 102 else |
| 101 return; | 103 return; |
| 102 } | 104 } |
| 103 // Call back the front end to reveal the password. | 105 // Call back the front end to reveal the password. |
| 104 password_view_->ShowPassword(index, password_list_[index]->password_value); | 106 password_view_->ShowPassword(index, password_list_[index]->password_value); |
| 105 } | 107 } |
| 106 | 108 |
| 107 const autofill::PasswordForm& PasswordManagerPresenter::GetPassword( | 109 const autofill::PasswordForm& PasswordManagerPresenter::GetPassword( |
| 108 size_t index) { | 110 size_t index) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 page_->SetPasswordExceptionList(); | 214 page_->SetPasswordExceptionList(); |
| 213 } | 215 } |
| 214 | 216 |
| 215 void PasswordManagerPresenter::PasswordExceptionListPopulater:: | 217 void PasswordManagerPresenter::PasswordExceptionListPopulater:: |
| 216 OnGetPasswordStoreResults( | 218 OnGetPasswordStoreResults( |
| 217 const std::vector<autofill::PasswordForm*>& results) { | 219 const std::vector<autofill::PasswordForm*>& results) { |
| 218 // TODO(kaiwang): Implement when I refactor | 220 // TODO(kaiwang): Implement when I refactor |
| 219 // PasswordStore::GetAutofillableLogins and PasswordStore::GetBlacklistLogins. | 221 // PasswordStore::GetAutofillableLogins and PasswordStore::GetBlacklistLogins. |
| 220 NOTIMPLEMENTED(); | 222 NOTIMPLEMENTED(); |
| 221 } | 223 } |
| OLD | NEW |