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

Side by Side Diff: chrome/browser/ui/webui/options/password_manager_handler.cc

Issue 11421029: Remove PrefObserver usages, batch 13. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix - rebase Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
67 67
68 void PasswordManagerHandler::InitializeHandler() { 68 void PasswordManagerHandler::InitializeHandler() {
69 // Due to the way that handlers are (re)initialized under certain types of 69 // Due to the way that handlers are (re)initialized under certain types of
70 // navigation, we may already be initialized. (See bugs 88986 and 86448.) 70 // navigation, we may already be initialized. (See bugs 88986 and 86448.)
71 // If this is the case, return immediately. This is a hack. 71 // If this is the case, return immediately. This is a hack.
72 // TODO(mdm): remove this hack once it is no longer necessary. 72 // TODO(mdm): remove this hack once it is no longer necessary.
73 if (!show_passwords_.GetPrefName().empty()) 73 if (!show_passwords_.GetPrefName().empty())
74 return; 74 return;
75 75
76 show_passwords_.Init(prefs::kPasswordManagerAllowShowPasswords, 76 show_passwords_.Init(prefs::kPasswordManagerAllowShowPasswords,
77 Profile::FromWebUI(web_ui())->GetPrefs(), this); 77 Profile::FromWebUI(web_ui())->GetPrefs(),
78 base::Bind(&PasswordManagerHandler::UpdatePasswordLists,
79 base::Unretained(this),
80 static_cast<base::ListValue*>(NULL)));
78 // We should not cache web_ui()->GetProfile(). See crosbug.com/6304. 81 // We should not cache web_ui()->GetProfile(). See crosbug.com/6304.
79 PasswordStore* store = GetPasswordStore(); 82 PasswordStore* store = GetPasswordStore();
80 if (store) 83 if (store)
81 store->AddObserver(this); 84 store->AddObserver(this);
82 } 85 }
83 86
84 void PasswordManagerHandler::RegisterMessages() { 87 void PasswordManagerHandler::RegisterMessages() {
85 web_ui()->RegisterMessageCallback("updatePasswordLists", 88 web_ui()->RegisterMessageCallback("updatePasswordLists",
86 base::Bind(&PasswordManagerHandler::UpdatePasswordLists, 89 base::Bind(&PasswordManagerHandler::UpdatePasswordLists,
87 base::Unretained(this))); 90 base::Unretained(this)));
88 web_ui()->RegisterMessageCallback("removeSavedPassword", 91 web_ui()->RegisterMessageCallback("removeSavedPassword",
89 base::Bind(&PasswordManagerHandler::RemoveSavedPassword, 92 base::Bind(&PasswordManagerHandler::RemoveSavedPassword,
90 base::Unretained(this))); 93 base::Unretained(this)));
91 web_ui()->RegisterMessageCallback("removePasswordException", 94 web_ui()->RegisterMessageCallback("removePasswordException",
92 base::Bind(&PasswordManagerHandler::RemovePasswordException, 95 base::Bind(&PasswordManagerHandler::RemovePasswordException,
93 base::Unretained(this))); 96 base::Unretained(this)));
94 web_ui()->RegisterMessageCallback("removeAllSavedPasswords", 97 web_ui()->RegisterMessageCallback("removeAllSavedPasswords",
95 base::Bind(&PasswordManagerHandler::RemoveAllSavedPasswords, 98 base::Bind(&PasswordManagerHandler::RemoveAllSavedPasswords,
96 base::Unretained(this))); 99 base::Unretained(this)));
97 web_ui()->RegisterMessageCallback("removeAllPasswordExceptions", 100 web_ui()->RegisterMessageCallback("removeAllPasswordExceptions",
98 base::Bind(&PasswordManagerHandler::RemoveAllPasswordExceptions, 101 base::Bind(&PasswordManagerHandler::RemoveAllPasswordExceptions,
99 base::Unretained(this))); 102 base::Unretained(this)));
100 } 103 }
101 104
102 void PasswordManagerHandler::OnLoginsChanged() { 105 void PasswordManagerHandler::OnLoginsChanged() {
103 UpdatePasswordLists(NULL); 106 UpdatePasswordLists(NULL);
104 } 107 }
105 108
106 PasswordStore* PasswordManagerHandler::GetPasswordStore() { 109 PasswordStore* PasswordManagerHandler::GetPasswordStore() {
107 return PasswordStoreFactory::GetForProfile( 110 return PasswordStoreFactory::GetForProfile(Profile::FromWebUI(web_ui()),
108 Profile::FromWebUI(web_ui()), 111 Profile::EXPLICIT_ACCESS);
109 Profile::EXPLICIT_ACCESS);
110 }
111
112 void PasswordManagerHandler::OnPreferenceChanged(PrefServiceBase* service,
113 const std::string& pref_name) {
114 DCHECK_EQ(std::string(prefs::kPasswordManagerAllowShowPasswords), pref_name);
115 UpdatePasswordLists(NULL);
116 } 112 }
117 113
118 void PasswordManagerHandler::UpdatePasswordLists(const ListValue* args) { 114 void PasswordManagerHandler::UpdatePasswordLists(const ListValue* args) {
119 // Reset the current lists. 115 // Reset the current lists.
120 password_list_.clear(); 116 password_list_.clear();
121 password_exception_list_.clear(); 117 password_exception_list_.clear();
122 118
123 languages_ = Profile::FromWebUI(web_ui())->GetPrefs()-> 119 languages_ = Profile::FromWebUI(web_ui())->GetPrefs()->
124 GetString(prefs::kAcceptLanguages); 120 GetString(prefs::kAcceptLanguages);
125 populater_.Populate(); 121 populater_.Populate();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 const std::vector<content::PasswordForm*>& result) { 261 const std::vector<content::PasswordForm*>& result) {
266 DCHECK_EQ(pending_login_query_, handle); 262 DCHECK_EQ(pending_login_query_, handle);
267 pending_login_query_ = 0; 263 pending_login_query_ = 0;
268 page_->password_exception_list_.clear(); 264 page_->password_exception_list_.clear();
269 page_->password_exception_list_.insert(page_->password_exception_list_.end(), 265 page_->password_exception_list_.insert(page_->password_exception_list_.end(),
270 result.begin(), result.end()); 266 result.begin(), result.end());
271 page_->SetPasswordExceptionList(); 267 page_->SetPasswordExceptionList();
272 } 268 }
273 269
274 } // namespace options 270 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/password_manager_handler.h ('k') | chrome/browser/ui/webui/options/startup_pages_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698