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

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

Issue 7031038: Protect against NULL PasswordStore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added NOTREACHED if no PasswordStore. Created 9 years, 7 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 | « no previous file | 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 d4abf491c5a2bfa153b3626da27b8aba19416bca..52e93857fc9417afda9b58c854cf2bbd2eef79a4 100644
--- a/chrome/browser/ui/webui/options/password_manager_handler.cc
+++ b/chrome/browser/ui/webui/options/password_manager_handler.cc
@@ -27,7 +27,9 @@ PasswordManagerHandler::PasswordManagerHandler()
}
PasswordManagerHandler::~PasswordManagerHandler() {
- GetPasswordStore()->RemoveObserver(this);
+ PasswordStore* store = GetPasswordStore();
+ if (store)
+ store->RemoveObserver(this);
}
void PasswordManagerHandler::GetLocalizedValues(
@@ -74,7 +76,11 @@ 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);
+ PasswordStore* store = GetPasswordStore();
+ if (store)
+ store->AddObserver(this);
+ else
+ NOTREACHED();
James Hawkins 2011/05/18 17:52:27 I'm not a fan of the NOTREACHEDs. This will not hi
}
void PasswordManagerHandler::RegisterMessages() {
@@ -125,19 +131,29 @@ void PasswordManagerHandler::UpdatePasswordLists(const ListValue* args) {
}
void PasswordManagerHandler::RemoveSavedPassword(const ListValue* args) {
+ PasswordStore* store = GetPasswordStore();
+ if (!store) {
+ NOTREACHED();
+ return;
+ }
std::string string_value = UTF16ToUTF8(ExtractStringValue(args));
int index;
base::StringToInt(string_value, &index);
- GetPasswordStore()->RemoveLogin(*password_list_[index]);
+ store->RemoveLogin(*password_list_[index]);
}
void PasswordManagerHandler::RemovePasswordException(
const ListValue* args) {
+ PasswordStore* store = GetPasswordStore();
+ if (!store) {
+ NOTREACHED();
+ return;
+ }
std::string string_value = UTF16ToUTF8(ExtractStringValue(args));
int index;
base::StringToInt(string_value, &index);
- GetPasswordStore()->RemoveLogin(*password_exception_list_[index]);
+ store->RemoveLogin(*password_exception_list_[index]);
}
void PasswordManagerHandler::RemoveAllSavedPasswords(
@@ -145,6 +161,10 @@ void PasswordManagerHandler::RemoveAllSavedPasswords(
// TODO(jhawkins): This will cause a list refresh for every password in the
// list. Add PasswordStore::RemoveAllLogins().
PasswordStore* store = GetPasswordStore();
+ if (!store) {
+ NOTREACHED();
+ return;
+ }
for (size_t i = 0; i < password_list_.size(); ++i)
store->RemoveLogin(*password_list_[i]);
}
@@ -152,6 +172,10 @@ void PasswordManagerHandler::RemoveAllSavedPasswords(
void PasswordManagerHandler::RemoveAllPasswordExceptions(
const ListValue* args) {
PasswordStore* store = GetPasswordStore();
+ if (!store) {
+ NOTREACHED();
+ return;
+ }
for (size_t i = 0; i < password_exception_list_.size(); ++i)
store->RemoveLogin(*password_exception_list_[i]);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698