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/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 }; | 67 }; |
68 | 68 |
69 RegisterStrings(localized_strings, resources, arraysize(resources)); | 69 RegisterStrings(localized_strings, resources, arraysize(resources)); |
70 RegisterTitle(localized_strings, "passwordsPage", | 70 RegisterTitle(localized_strings, "passwordsPage", |
71 IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE); | 71 IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE); |
72 | 72 |
73 localized_strings->SetString("passwordManagerLearnMoreURL", | 73 localized_strings->SetString("passwordManagerLearnMoreURL", |
74 chrome::kPasswordManagerLearnMoreURL); | 74 chrome::kPasswordManagerLearnMoreURL); |
75 } | 75 } |
76 | 76 |
77 void PasswordManagerHandler::Initialize() { | 77 void PasswordManagerHandler::InitializeHandler() { |
78 // Due to the way that handlers are (re)initialized under certain types of | 78 // Due to the way that handlers are (re)initialized under certain types of |
79 // navigation, we may already be initialized. (See bugs 88986 and 86448.) | 79 // navigation, we may already be initialized. (See bugs 88986 and 86448.) |
80 // If this is the case, return immediately. This is a hack. | 80 // If this is the case, return immediately. This is a hack. |
81 // TODO(mdm): remove this hack once it is no longer necessary. | 81 // TODO(mdm): remove this hack once it is no longer necessary. |
82 if (!show_passwords_.GetPrefName().empty()) | 82 if (!show_passwords_.GetPrefName().empty()) |
83 return; | 83 return; |
84 | 84 |
85 show_passwords_.Init(prefs::kPasswordManagerAllowShowPasswords, | 85 show_passwords_.Init(prefs::kPasswordManagerAllowShowPasswords, |
86 Profile::FromWebUI(web_ui())->GetPrefs(), this); | 86 Profile::FromWebUI(web_ui())->GetPrefs(), this); |
87 // We should not cache web_ui()->GetProfile(). See crosbug.com/6304. | 87 // We should not cache web_ui()->GetProfile(). See crosbug.com/6304. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 for (size_t i = 0; i < password_exception_list_.size(); ++i) | 184 for (size_t i = 0; i < password_exception_list_.size(); ++i) |
185 store->RemoveLogin(*password_exception_list_[i]); | 185 store->RemoveLogin(*password_exception_list_[i]); |
186 } | 186 } |
187 | 187 |
188 void PasswordManagerHandler::SetPasswordList() { | 188 void PasswordManagerHandler::SetPasswordList() { |
189 // Due to the way that handlers are (re)initialized under certain types of | 189 // Due to the way that handlers are (re)initialized under certain types of |
190 // navigation, we may not be initialized yet. (See bugs 88986 and 86448.) | 190 // navigation, we may not be initialized yet. (See bugs 88986 and 86448.) |
191 // If this is the case, initialize on demand. This is a hack. | 191 // If this is the case, initialize on demand. This is a hack. |
192 // TODO(mdm): remove this hack once it is no longer necessary. | 192 // TODO(mdm): remove this hack once it is no longer necessary. |
193 if (show_passwords_.GetPrefName().empty()) | 193 if (show_passwords_.GetPrefName().empty()) |
194 Initialize(); | 194 InitializeHandler(); |
195 | 195 |
196 ListValue entries; | 196 ListValue entries; |
197 bool show_passwords = *show_passwords_; | 197 bool show_passwords = *show_passwords_; |
198 string16 empty; | 198 string16 empty; |
199 for (size_t i = 0; i < password_list_.size(); ++i) { | 199 for (size_t i = 0; i < password_list_.size(); ++i) { |
200 ListValue* entry = new ListValue(); | 200 ListValue* entry = new ListValue(); |
201 entry->Append(new StringValue(net::FormatUrl(password_list_[i]->origin, | 201 entry->Append(new StringValue(net::FormatUrl(password_list_[i]->origin, |
202 languages_))); | 202 languages_))); |
203 entry->Append(new StringValue(password_list_[i]->username_value)); | 203 entry->Append(new StringValue(password_list_[i]->username_value)); |
204 entry->Append(new StringValue( | 204 entry->Append(new StringValue( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 OnPasswordStoreRequestDone( | 279 OnPasswordStoreRequestDone( |
280 CancelableRequestProvider::Handle handle, | 280 CancelableRequestProvider::Handle handle, |
281 const std::vector<webkit::forms::PasswordForm*>& result) { | 281 const std::vector<webkit::forms::PasswordForm*>& result) { |
282 DCHECK_EQ(pending_login_query_, handle); | 282 DCHECK_EQ(pending_login_query_, handle); |
283 pending_login_query_ = 0; | 283 pending_login_query_ = 0; |
284 page_->password_exception_list_.reset(); | 284 page_->password_exception_list_.reset(); |
285 page_->password_exception_list_.insert(page_->password_exception_list_.end(), | 285 page_->password_exception_list_.insert(page_->password_exception_list_.end(), |
286 result.begin(), result.end()); | 286 result.begin(), result.end()); |
287 page_->SetPasswordExceptionList(); | 287 page_->SetPasswordExceptionList(); |
288 } | 288 } |
OLD | NEW |