| 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::kDisablePasswordManagerReauthentication); | 29 switches::kDisablePasswordManagerReauthentication); |
| 29 } | 30 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 DCHECK_LT(index, password_exception_list_.size()); | 87 DCHECK_LT(index, password_exception_list_.size()); |
| 87 PasswordStore* store = GetPasswordStore(); | 88 PasswordStore* store = GetPasswordStore(); |
| 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) { |
| 97 #if !defined(OS_ANDROID) // This is never called on Android. |
| 96 DCHECK_LT(index, password_list_.size()); | 98 DCHECK_LT(index, password_list_.size()); |
| 97 if (IsAuthenticationRequired()) { | 99 if (IsAuthenticationRequired()) { |
| 98 if (password_manager_util::AuthenticateUser()) | 100 if (password_manager_util::AuthenticateUser( |
| 101 password_view_->GetNativeWindow())) |
| 99 last_authentication_time_ = base::TimeTicks::Now(); | 102 last_authentication_time_ = base::TimeTicks::Now(); |
| 100 else | 103 else |
| 101 return; | 104 return; |
| 102 } | 105 } |
| 103 // Call back the front end to reveal the password. | 106 // Call back the front end to reveal the password. |
| 104 password_view_->ShowPassword(index, password_list_[index]->password_value); | 107 password_view_->ShowPassword(index, password_list_[index]->password_value); |
| 108 #endif |
| 105 } | 109 } |
| 106 | 110 |
| 107 const autofill::PasswordForm& PasswordManagerPresenter::GetPassword( | 111 const autofill::PasswordForm& PasswordManagerPresenter::GetPassword( |
| 108 size_t index) { | 112 size_t index) { |
| 109 DCHECK_LT(index, password_list_.size()); | 113 DCHECK_LT(index, password_list_.size()); |
| 110 return *password_list_[index]; | 114 return *password_list_[index]; |
| 111 } | 115 } |
| 112 | 116 |
| 113 const autofill::PasswordForm& PasswordManagerPresenter::GetPasswordException( | 117 const autofill::PasswordForm& PasswordManagerPresenter::GetPasswordException( |
| 114 size_t index) { | 118 size_t index) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 page_->SetPasswordExceptionList(); | 216 page_->SetPasswordExceptionList(); |
| 213 } | 217 } |
| 214 | 218 |
| 215 void PasswordManagerPresenter::PasswordExceptionListPopulater:: | 219 void PasswordManagerPresenter::PasswordExceptionListPopulater:: |
| 216 OnGetPasswordStoreResults( | 220 OnGetPasswordStoreResults( |
| 217 const std::vector<autofill::PasswordForm*>& results) { | 221 const std::vector<autofill::PasswordForm*>& results) { |
| 218 // TODO(kaiwang): Implement when I refactor | 222 // TODO(kaiwang): Implement when I refactor |
| 219 // PasswordStore::GetAutofillableLogins and PasswordStore::GetBlacklistLogins. | 223 // PasswordStore::GetAutofillableLogins and PasswordStore::GetBlacklistLogins. |
| 220 NOTIMPLEMENTED(); | 224 NOTIMPLEMENTED(); |
| 221 } | 225 } |
| OLD | NEW |