Chromium Code Reviews| Index: chrome/browser/ui/webui/options/password_manager_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/password_manager_handler.cc b/chrome/browser/ui/webui/options/password_manager_handler.cc |
| index fe8443304f70371d99b422a227cfed15b7fa3099..d4abf491c5a2bfa153b3626da27b8aba19416bca 100644 |
| --- a/chrome/browser/ui/webui/options/password_manager_handler.cc |
| +++ b/chrome/browser/ui/webui/options/password_manager_handler.cc |
| @@ -13,6 +13,8 @@ |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| +#include "content/common/notification_details.h" |
| +#include "content/common/notification_source.h" |
| #include "grit/chromium_strings.h" |
| #include "grit/generated_resources.h" |
| #include "net/base/net_util.h" |
| @@ -69,6 +71,8 @@ void PasswordManagerHandler::GetLocalizedValues( |
| } |
| void PasswordManagerHandler::Initialize() { |
| + show_passwords_.Init(prefs::kPasswordManagerAllowShowPasswords, |
| + web_ui_->GetProfile()->GetPrefs(), this); |
| // We should not cache web_ui_->GetProfile(). See crosbug.com/6304. |
| GetPasswordStore()->AddObserver(this); |
| } |
| @@ -96,6 +100,19 @@ PasswordStore* PasswordManagerHandler::GetPasswordStore() { |
| return web_ui_->GetProfile()->GetPasswordStore(Profile::EXPLICIT_ACCESS); |
| } |
| +void PasswordManagerHandler::Observe(NotificationType type, |
| + const NotificationSource& source, |
| + const NotificationDetails& details) { |
| + if (type.value == NotificationType::PREF_CHANGED) { |
| + std::string* pref_name = Details<std::string>(details).ptr(); |
| + if (*pref_name == prefs::kPasswordManagerAllowShowPasswords) { |
| + UpdatePasswordLists(NULL); |
| + } |
| + } |
| + |
| + OptionsPageUIHandler::Observe(type, source, details); |
| +} |
| + |
| void PasswordManagerHandler::UpdatePasswordLists(const ListValue* args) { |
| // Reset the current lists. |
| password_list_.reset(); |
| @@ -141,12 +158,15 @@ void PasswordManagerHandler::RemoveAllPasswordExceptions( |
| void PasswordManagerHandler::SetPasswordList() { |
| ListValue entries; |
| + bool show_passwords = *show_passwords_; |
| + string16 empty; |
|
James Hawkins
2011/04/11 17:13:26
Why don't you just send the asterisks here? That w
stuartmorgan
2011/04/11 17:16:06
See my recent comment. The view already has to kno
|
| for (size_t i = 0; i < password_list_.size(); ++i) { |
| ListValue* entry = new ListValue(); |
| entry->Append(new StringValue(net::FormatUrl(password_list_[i]->origin, |
| languages_))); |
| entry->Append(new StringValue(password_list_[i]->username_value)); |
| - entry->Append(new StringValue(password_list_[i]->password_value)); |
| + entry->Append(new StringValue( |
| + show_passwords ? password_list_[i]->password_value : empty)); |
| entries.Append(entry); |
| } |