| 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/webui/options/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/password/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 | 20 |
| 21 namespace options { | 21 namespace passwords_ui { |
| 22 | 22 |
| 23 PasswordManagerPresenter::PasswordManagerPresenter( | 23 PasswordManagerPresenter::PasswordManagerPresenter( |
| 24 passwords_ui::PasswordUIView* password_view) | 24 passwords_ui::PasswordUIView* password_view) |
| 25 : populater_(this), | 25 : populater_(this), |
| 26 exception_populater_(this), | 26 exception_populater_(this), |
| 27 password_view_(password_view) { | 27 password_view_(password_view) { |
| 28 DCHECK(password_view_); | 28 DCHECK(password_view_); |
| 29 require_reauthentication_ = CommandLine::ForCurrentProcess()->HasSwitch( | 29 require_reauthentication_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 30 switches::kEnablePasswordManagerReauthentication); | 30 switches::kEnablePasswordManagerReauthentication); |
| 31 } | 31 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 void PasswordManagerPresenter::UpdatePasswordLists() { | 68 void PasswordManagerPresenter::UpdatePasswordLists() { |
| 69 // Reset the current lists. | 69 // Reset the current lists. |
| 70 password_list_.clear(); | 70 password_list_.clear(); |
| 71 password_exception_list_.clear(); | 71 password_exception_list_.clear(); |
| 72 | 72 |
| 73 populater_.Populate(); | 73 populater_.Populate(); |
| 74 exception_populater_.Populate(); | 74 exception_populater_.Populate(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void PasswordManagerPresenter::HandleRemoveSavedPassword(size_t index) { | 77 void PasswordManagerPresenter::RemoveSavedPassword(size_t index) { |
| 78 DCHECK_LT(index, password_list_.size()); | 78 DCHECK_LT(index, password_list_.size()); |
| 79 PasswordStore* store = GetPasswordStore(); | 79 PasswordStore* store = GetPasswordStore(); |
| 80 if (!store) | 80 if (!store) |
| 81 return; | 81 return; |
| 82 store->RemoveLogin(*password_list_[index]); | 82 store->RemoveLogin(*password_list_[index]); |
| 83 content::RecordAction( | 83 content::RecordAction( |
| 84 content::UserMetricsAction("PasswordManager_HandleRemoveSavedPassword")); | 84 content::UserMetricsAction("PasswordManager_RemoveSavedPassword")); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void PasswordManagerPresenter::HandleRemovePasswordException(size_t index) { | 87 void PasswordManagerPresenter::RemovePasswordException(size_t index) { |
| 88 DCHECK_LT(index, password_exception_list_.size()); | 88 DCHECK_LT(index, password_exception_list_.size()); |
| 89 PasswordStore* store = GetPasswordStore(); | 89 PasswordStore* store = GetPasswordStore(); |
| 90 if (!store) | 90 if (!store) |
| 91 return; | 91 return; |
| 92 store->RemoveLogin(*password_exception_list_[index]); | 92 store->RemoveLogin(*password_exception_list_[index]); |
| 93 content::RecordAction( | 93 content::RecordAction( |
| 94 content::UserMetricsAction( | 94 content::UserMetricsAction( |
| 95 "PasswordManager_HandleRemovePasswordException")); | 95 "PasswordManager_RemovePasswordException")); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void PasswordManagerPresenter::HandleRequestShowPassword(size_t index) { | 98 void PasswordManagerPresenter::RequestShowPassword(size_t index) { |
| 99 DCHECK_LT(index, password_list_.size()); | 99 DCHECK_LT(index, password_list_.size()); |
| 100 if (IsAuthenticationRequired()) { | 100 if (IsAuthenticationRequired()) { |
| 101 if (password_manager_util::AuthenticateUser()) | 101 if (password_manager_util::AuthenticateUser()) |
| 102 last_authentication_time_ = base::TimeTicks::Now(); | 102 last_authentication_time_ = base::TimeTicks::Now(); |
| 103 else | 103 else |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 // Call back the front end to reveal the password. | 106 // Call back the front end to reveal the password. |
| 107 password_view_->ShowPassword(index, password_list_[index]->password_value); | 107 password_view_->ShowPassword(index, password_list_[index]->password_value); |
| 108 } | 108 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 216 } |
| 217 | 217 |
| 218 void PasswordManagerPresenter::PasswordExceptionListPopulater:: | 218 void PasswordManagerPresenter::PasswordExceptionListPopulater:: |
| 219 OnGetPasswordStoreResults( | 219 OnGetPasswordStoreResults( |
| 220 const std::vector<autofill::PasswordForm*>& results) { | 220 const std::vector<autofill::PasswordForm*>& results) { |
| 221 // TODO(kaiwang): Implement when I refactor | 221 // TODO(kaiwang): Implement when I refactor |
| 222 // PasswordStore::GetAutofillableLogins and PasswordStore::GetBlacklistLogins. | 222 // PasswordStore::GetAutofillableLogins and PasswordStore::GetBlacklistLogins. |
| 223 NOTIMPLEMENTED(); | 223 NOTIMPLEMENTED(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace options | 226 } // namespace passwords_ui |
| OLD | NEW |