OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_handler.h" | 5 #include "chrome/browser/ui/webui/options/password_manager_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | |
8 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.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" |
14 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/common/chrome_switches.h" | |
15 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.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 "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
19 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
20 #include "content/public/browser/user_metrics.h" | 23 #include "content/public/browser/user_metrics.h" |
21 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
22 #include "grit/chromium_strings.h" | 25 #include "grit/chromium_strings.h" |
23 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
24 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
25 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
26 | 29 |
27 namespace options { | 30 namespace options { |
28 | 31 |
29 PasswordManagerHandler::PasswordManagerHandler() | 32 PasswordManagerHandler::PasswordManagerHandler() |
30 : populater_(this), | 33 : populater_(this), |
31 exception_populater_(this), | 34 exception_populater_(this), |
32 is_user_authenticated_(false) { | 35 is_user_authenticated_(false) { |
36 CommandLine* cl = CommandLine::ForCurrentProcess(); | |
37 require_reauthentication_ = | |
38 cl->HasSwitch(switches::kEnablePasswordManagerReauthentication) && | |
39 !(cl->HasSwitch(switches::kDisablePasswordManagerReauthentication)); | |
33 } | 40 } |
34 | 41 |
35 PasswordManagerHandler::~PasswordManagerHandler() { | 42 PasswordManagerHandler::~PasswordManagerHandler() { |
36 PasswordStore* store = GetPasswordStore(); | 43 PasswordStore* store = GetPasswordStore(); |
37 if (store) | 44 if (store) |
38 store->RemoveObserver(this); | 45 store->RemoveObserver(this); |
39 } | 46 } |
40 | 47 |
41 void PasswordManagerHandler::GetLocalizedValues( | 48 void PasswordManagerHandler::GetLocalizedValues( |
42 DictionaryValue* localized_strings) { | 49 DictionaryValue* localized_strings) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 } | 157 } |
151 } | 158 } |
152 | 159 |
153 void PasswordManagerHandler::RequestShowPassword(const ListValue* args) { | 160 void PasswordManagerHandler::RequestShowPassword(const ListValue* args) { |
154 int index; | 161 int index; |
155 if (!ExtractIntegerValue(args, &index)) { | 162 if (!ExtractIntegerValue(args, &index)) { |
156 NOTREACHED(); | 163 NOTREACHED(); |
157 return; | 164 return; |
158 } | 165 } |
159 | 166 |
160 if (!is_user_authenticated_) { | 167 if (require_reauthentication_ && !is_user_authenticated_) { |
Will Harris
2013/10/18 11:56:52
for users who leave their browser open for several
Patrick Dubroy
2013/10/18 13:15:54
Yeah. For some reason I was thinking I'd leave tha
| |
161 // TODO(dubroy): Insert actual authentication code here. | 168 // If reauthentication fails, do nothing. |
162 is_user_authenticated_ = true; | 169 if (!(is_user_authenticated_ = password_manager_util::AuthenticateUser())) |
170 return; | |
163 } | 171 } |
164 | 172 |
165 // Call back the front end to reveal the password. | 173 // Call back the front end to reveal the password. |
166 web_ui()->CallJavascriptFunction( | 174 web_ui()->CallJavascriptFunction( |
167 "PasswordManager.showPassword", | 175 "PasswordManager.showPassword", |
168 base::FundamentalValue(index), | 176 base::FundamentalValue(index), |
169 StringValue(password_list_[index]->password_value)); | 177 StringValue(password_list_[index]->password_value)); |
170 } | 178 } |
171 | 179 |
172 void PasswordManagerHandler::SetPasswordList() { | 180 void PasswordManagerHandler::SetPasswordList() { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 | 293 |
286 void PasswordManagerHandler::PasswordExceptionListPopulater:: | 294 void PasswordManagerHandler::PasswordExceptionListPopulater:: |
287 OnGetPasswordStoreResults( | 295 OnGetPasswordStoreResults( |
288 const std::vector<autofill::PasswordForm*>& results) { | 296 const std::vector<autofill::PasswordForm*>& results) { |
289 // TODO(kaiwang): Implement when I refactor | 297 // TODO(kaiwang): Implement when I refactor |
290 // PasswordStore::GetAutofillableLogins and PasswordStore::GetBlacklistLogins. | 298 // PasswordStore::GetAutofillableLogins and PasswordStore::GetBlacklistLogins. |
291 NOTIMPLEMENTED(); | 299 NOTIMPLEMENTED(); |
292 } | 300 } |
293 | 301 |
294 } // namespace options | 302 } // namespace options |
OLD | NEW |