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

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: Add comment; Check for NULL PasswordStore in TestingAutomationProvider. 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
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..03da07e73803aee14f5364b9e46f6a5dca8f4ca6 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,9 @@ 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);
}
void PasswordManagerHandler::RegisterMessages() {
@@ -125,19 +129,25 @@ void PasswordManagerHandler::UpdatePasswordLists(const ListValue* args) {
}
void PasswordManagerHandler::RemoveSavedPassword(const ListValue* args) {
+ PasswordStore* store = GetPasswordStore();
+ if (!store)
+ 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)
+ 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 +155,8 @@ 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)
+ return;
for (size_t i = 0; i < password_list_.size(); ++i)
store->RemoveLogin(*password_list_[i]);
}
@@ -152,6 +164,8 @@ void PasswordManagerHandler::RemoveAllSavedPasswords(
void PasswordManagerHandler::RemoveAllPasswordExceptions(
const ListValue* args) {
PasswordStore* store = GetPasswordStore();
+ if (!store)
+ return;
for (size_t i = 0; i < password_exception_list_.size(); ++i)
store->RemoveLogin(*password_exception_list_[i]);
}
« chrome/browser/automation/testing_automation_provider.cc ('K') | « chrome/browser/profiles/profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698