Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/browser/ui/passwords/password_manager_presenter.cc

Issue 1846623002: Remove password-manager-reauthentication flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just rebased Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 26 matching lines...) Expand all
37 #elif defined(OS_MACOSX) 37 #elif defined(OS_MACOSX)
38 #include "chrome/browser/password_manager/password_manager_util_mac.h" 38 #include "chrome/browser/password_manager/password_manager_util_mac.h"
39 #endif 39 #endif
40 40
41 using password_manager::PasswordStore; 41 using password_manager::PasswordStore;
42 42
43 PasswordManagerPresenter::PasswordManagerPresenter( 43 PasswordManagerPresenter::PasswordManagerPresenter(
44 PasswordUIView* password_view) 44 PasswordUIView* password_view)
45 : populater_(this), 45 : populater_(this),
46 exception_populater_(this), 46 exception_populater_(this),
47 require_reauthentication_(
48 !base::CommandLine::ForCurrentProcess()->HasSwitch(
49 switches::kDisablePasswordManagerReauthentication)),
50 password_view_(password_view) { 47 password_view_(password_view) {
51 DCHECK(password_view_); 48 DCHECK(password_view_);
52 } 49 }
53 50
54 PasswordManagerPresenter::~PasswordManagerPresenter() { 51 PasswordManagerPresenter::~PasswordManagerPresenter() {
55 PasswordStore* store = GetPasswordStore(); 52 PasswordStore* store = GetPasswordStore();
56 if (store) 53 if (store)
57 store->RemoveObserver(this); 54 store->RemoveObserver(this);
58 } 55 }
59 56
60 void PasswordManagerPresenter::Initialize() { 57 void PasswordManagerPresenter::Initialize() {
61 // Due to the way that handlers are (re)initialized under certain types of
62 // navigation, the presenter may already be initialized. (See bugs 88986
63 // and 86448). If this is the case, return immediately. This is a hack.
64 // TODO(mdm): remove this hack once it is no longer necessary.
vasilii 2016/03/31 15:34:38 Not true anymore?
vabr (Chromium) 2016/03/31 15:47:20 Not relevant any more -- we no longer care about t
65 if (!show_passwords_.GetPrefName().empty())
66 return;
67
68 show_passwords_.Init(
69 password_manager::prefs::kPasswordManagerAllowShowPasswords,
70 password_view_->GetProfile()->GetPrefs(),
71 base::Bind(&PasswordManagerPresenter::UpdatePasswordLists,
72 base::Unretained(this)));
73 // TODO(jhawkins) We should not cache web_ui()->GetProfile().See
74 // crosbug.com/6304.
75 PasswordStore* store = GetPasswordStore(); 58 PasswordStore* store = GetPasswordStore();
76 if (store) 59 if (store)
77 store->AddObserver(this); 60 store->AddObserver(this);
78 61
79 languages_ = password_view_->GetProfile()->GetPrefs()-> 62 languages_ = password_view_->GetProfile()->GetPrefs()->
80 GetString(prefs::kAcceptLanguages); 63 GetString(prefs::kAcceptLanguages);
81 } 64 }
82 65
83 void PasswordManagerPresenter::OnLoginsChanged( 66 void PasswordManagerPresenter::OnLoginsChanged(
84 const password_manager::PasswordStoreChangeList& changes) { 67 const password_manager::PasswordStoreChangeList& changes) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 118 }
136 119
137 void PasswordManagerPresenter::RequestShowPassword(size_t index) { 120 void PasswordManagerPresenter::RequestShowPassword(size_t index) {
138 #if !defined(OS_ANDROID) // This is never called on Android. 121 #if !defined(OS_ANDROID) // This is never called on Android.
139 if (index >= password_list_.size()) { 122 if (index >= password_list_.size()) {
140 // |index| out of bounds might come from a compromised renderer, don't let 123 // |index| out of bounds might come from a compromised renderer, don't let
141 // it crash the browser. http://crbug.com/362054 124 // it crash the browser. http://crbug.com/362054
142 NOTREACHED(); 125 NOTREACHED();
143 return; 126 return;
144 } 127 }
145 if (require_reauthentication_ && 128 if ((base::TimeTicks::Now() - last_authentication_time_) >
146 (base::TimeTicks::Now() - last_authentication_time_) > 129 base::TimeDelta::FromSeconds(60)) {
147 base::TimeDelta::FromSeconds(60)) {
148 bool authenticated = true; 130 bool authenticated = true;
149 #if defined(OS_WIN) 131 #if defined(OS_WIN)
150 authenticated = password_manager_util_win::AuthenticateUser( 132 authenticated = password_manager_util_win::AuthenticateUser(
151 password_view_->GetNativeWindow()); 133 password_view_->GetNativeWindow());
152 #elif defined(OS_MACOSX) 134 #elif defined(OS_MACOSX)
153 authenticated = password_manager_util_mac::AuthenticateUser(); 135 authenticated = password_manager_util_mac::AuthenticateUser();
154 #endif 136 #endif
155 if (authenticated) 137 if (authenticated)
156 last_authentication_time_ = base::TimeTicks::Now(); 138 last_authentication_time_ = base::TimeTicks::Now();
157 else 139 else
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (index >= password_exception_list_.size()) { 180 if (index >= password_exception_list_.size()) {
199 // |index| out of bounds might come from a compromised renderer, don't let 181 // |index| out of bounds might come from a compromised renderer, don't let
200 // it crash the browser. http://crbug.com/362054 182 // it crash the browser. http://crbug.com/362054
201 NOTREACHED(); 183 NOTREACHED();
202 return NULL; 184 return NULL;
203 } 185 }
204 return password_exception_list_[index].get(); 186 return password_exception_list_[index].get();
205 } 187 }
206 188
207 void PasswordManagerPresenter::SetPasswordList() { 189 void PasswordManagerPresenter::SetPasswordList() {
208 // Due to the way that handlers are (re)initialized under certain types of 190 password_view_->SetPasswordList(password_list_);
209 // navigation, the presenter may already be initialized. (See bugs 88986
210 // and 86448). If this is the case, return immediately. This is a hack.
211 // If this is the case, initialize on demand. This is a hack.
212 // TODO(mdm): remove this hack once it is no longer necessary.
213 if (show_passwords_.GetPrefName().empty())
214 Initialize();
215
216 bool show_passwords = *show_passwords_ && !require_reauthentication_;
217 password_view_->SetPasswordList(password_list_, show_passwords);
218 } 191 }
219 192
220 void PasswordManagerPresenter::SetPasswordExceptionList() { 193 void PasswordManagerPresenter::SetPasswordExceptionList() {
221 password_view_->SetPasswordExceptionList(password_exception_list_); 194 password_view_->SetPasswordExceptionList(password_exception_list_);
222 } 195 }
223 196
224 PasswordManagerPresenter::ListPopulater::ListPopulater( 197 PasswordManagerPresenter::ListPopulater::ListPopulater(
225 PasswordManagerPresenter* page) : page_(page) { 198 PasswordManagerPresenter* page) : page_(page) {
226 } 199 }
227 200
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 LOG(ERROR) << "No password store! Cannot display exceptions."; 236 LOG(ERROR) << "No password store! Cannot display exceptions.";
264 } 237 }
265 } 238 }
266 239
267 void PasswordManagerPresenter::PasswordExceptionListPopulater:: 240 void PasswordManagerPresenter::PasswordExceptionListPopulater::
268 OnGetPasswordStoreResults(ScopedVector<autofill::PasswordForm> results) { 241 OnGetPasswordStoreResults(ScopedVector<autofill::PasswordForm> results) {
269 page_->password_exception_list_ = 242 page_->password_exception_list_ =
270 password_manager_util::ConvertScopedVector(std::move(results)); 243 password_manager_util::ConvertScopedVector(std::move(results));
271 page_->SetPasswordExceptionList(); 244 page_->SetPasswordExceptionList();
272 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698