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..1a1c981b6fe8f939c6903a8928c4274d29c4d33c 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,21 @@ PasswordStore* PasswordManagerHandler::GetPasswordStore() { |
| return web_ui_->GetProfile()->GetPasswordStore(Profile::EXPLICIT_ACCESS); |
| } |
| +void PasswordManagerHandler::Observe(NotificationType type, |
| + const NotificationSource& source, |
|
stuartmorgan
2011/03/29 15:24:58
Alignment is wrong on the continuation lines.
Joao da Silva
2011/03/31 10:03:22
Done.
|
| + const NotificationDetails& details) { |
| + if (type.value == NotificationType::PREF_CHANGED) { |
| + std::string* pref_name = Details<std::string>(details).ptr(); |
| + if (*pref_name == prefs::kPasswordManagerAllowShowPasswords) { |
| + // Call UpdatePasswordLists() to update the password data model too. |
| + UpdatePasswordLists(NULL); |
| + return; |
|
stuartmorgan
2011/03/29 15:24:58
Why the early return?
Joao da Silva
2011/03/31 10:03:22
No reason for it, removed.
|
| + } |
| + } |
| + |
| + OptionsPageUIHandler::Observe(type, source, details); |
| +} |
| + |
| void PasswordManagerHandler::UpdatePasswordLists(const ListValue* args) { |
| // Reset the current lists. |
| password_list_.reset(); |
| @@ -141,17 +160,21 @@ void PasswordManagerHandler::RemoveAllPasswordExceptions( |
| void PasswordManagerHandler::SetPasswordList() { |
| ListValue entries; |
| + bool show_passwords = *show_passwords_; |
| 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 : string16())); |
| entries.Append(entry); |
| } |
| + scoped_ptr<Value> show_value(Value::CreateBooleanValue(*show_passwords_)); |
| + |
| web_ui_->CallJavascriptFunction("PasswordManager.setSavedPasswordsList", |
| - entries); |
| + entries, *show_value); |
| } |
| void PasswordManagerHandler::SetPasswordExceptionList() { |