Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1347)

Unified Diff: chrome/browser/ui/webui/options/password_manager_handler.cc

Issue 6770012: Handle the PasswordManagerAllowShowPasswords preference in the options webui. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/password_manager_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
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);
}
« no previous file with comments | « chrome/browser/ui/webui/options/password_manager_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698