| 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/options2/password_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options2/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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (*pref_name == prefs::kPasswordManagerAllowShowPasswords) { | 118 if (*pref_name == prefs::kPasswordManagerAllowShowPasswords) { |
| 119 UpdatePasswordLists(NULL); | 119 UpdatePasswordLists(NULL); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 OptionsPageUIHandler::Observe(type, source, details); | 123 OptionsPageUIHandler::Observe(type, source, details); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void PasswordManagerHandler::UpdatePasswordLists(const ListValue* args) { | 126 void PasswordManagerHandler::UpdatePasswordLists(const ListValue* args) { |
| 127 // Reset the current lists. | 127 // Reset the current lists. |
| 128 password_list_.reset(); | 128 password_list_.clear(); |
| 129 password_exception_list_.reset(); | 129 password_exception_list_.clear(); |
| 130 | 130 |
| 131 languages_ = Profile::FromWebUI(web_ui())->GetPrefs()-> | 131 languages_ = Profile::FromWebUI(web_ui())->GetPrefs()-> |
| 132 GetString(prefs::kAcceptLanguages); | 132 GetString(prefs::kAcceptLanguages); |
| 133 populater_.Populate(); | 133 populater_.Populate(); |
| 134 exception_populater_.Populate(); | 134 exception_populater_.Populate(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void PasswordManagerHandler::RemoveSavedPassword(const ListValue* args) { | 137 void PasswordManagerHandler::RemoveSavedPassword(const ListValue* args) { |
| 138 PasswordStore* store = GetPasswordStore(); | 138 PasswordStore* store = GetPasswordStore(); |
| 139 if (!store) | 139 if (!store) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 LOG(ERROR) << "No password store! Cannot display passwords."; | 237 LOG(ERROR) << "No password store! Cannot display passwords."; |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 | 240 |
| 241 void PasswordManagerHandler::PasswordListPopulater:: | 241 void PasswordManagerHandler::PasswordListPopulater:: |
| 242 OnPasswordStoreRequestDone( | 242 OnPasswordStoreRequestDone( |
| 243 CancelableRequestProvider::Handle handle, | 243 CancelableRequestProvider::Handle handle, |
| 244 const std::vector<webkit::forms::PasswordForm*>& result) { | 244 const std::vector<webkit::forms::PasswordForm*>& result) { |
| 245 DCHECK_EQ(pending_login_query_, handle); | 245 DCHECK_EQ(pending_login_query_, handle); |
| 246 pending_login_query_ = 0; | 246 pending_login_query_ = 0; |
| 247 page_->password_list_.reset(); | 247 page_->password_list_.clear(); |
| 248 page_->password_list_.insert(page_->password_list_.end(), | 248 page_->password_list_.insert(page_->password_list_.end(), |
| 249 result.begin(), result.end()); | 249 result.begin(), result.end()); |
| 250 page_->SetPasswordList(); | 250 page_->SetPasswordList(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 PasswordManagerHandler::PasswordExceptionListPopulater:: | 253 PasswordManagerHandler::PasswordExceptionListPopulater:: |
| 254 PasswordExceptionListPopulater(PasswordManagerHandler* page) | 254 PasswordExceptionListPopulater(PasswordManagerHandler* page) |
| 255 : ListPopulater(page) { | 255 : ListPopulater(page) { |
| 256 } | 256 } |
| 257 | 257 |
| 258 void PasswordManagerHandler::PasswordExceptionListPopulater::Populate() { | 258 void PasswordManagerHandler::PasswordExceptionListPopulater::Populate() { |
| 259 PasswordStore* store = page_->GetPasswordStore(); | 259 PasswordStore* store = page_->GetPasswordStore(); |
| 260 if (store != NULL) { | 260 if (store != NULL) { |
| 261 if (pending_login_query_) | 261 if (pending_login_query_) |
| 262 store->CancelRequest(pending_login_query_); | 262 store->CancelRequest(pending_login_query_); |
| 263 | 263 |
| 264 pending_login_query_ = store->GetBlacklistLogins(this); | 264 pending_login_query_ = store->GetBlacklistLogins(this); |
| 265 } else { | 265 } else { |
| 266 LOG(ERROR) << "No password store! Cannot display exceptions."; | 266 LOG(ERROR) << "No password store! Cannot display exceptions."; |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 void PasswordManagerHandler::PasswordExceptionListPopulater:: | 270 void PasswordManagerHandler::PasswordExceptionListPopulater:: |
| 271 OnPasswordStoreRequestDone( | 271 OnPasswordStoreRequestDone( |
| 272 CancelableRequestProvider::Handle handle, | 272 CancelableRequestProvider::Handle handle, |
| 273 const std::vector<webkit::forms::PasswordForm*>& result) { | 273 const std::vector<webkit::forms::PasswordForm*>& result) { |
| 274 DCHECK_EQ(pending_login_query_, handle); | 274 DCHECK_EQ(pending_login_query_, handle); |
| 275 pending_login_query_ = 0; | 275 pending_login_query_ = 0; |
| 276 page_->password_exception_list_.reset(); | 276 page_->password_exception_list_.clear(); |
| 277 page_->password_exception_list_.insert(page_->password_exception_list_.end(), | 277 page_->password_exception_list_.insert(page_->password_exception_list_.end(), |
| 278 result.begin(), result.end()); | 278 result.begin(), result.end()); |
| 279 page_->SetPasswordExceptionList(); | 279 page_->SetPasswordExceptionList(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace options2 | 282 } // namespace options2 |
| OLD | NEW |