Commit 882898c6 authored by mazda@chromium.org's avatar mazda@chromium.org

Fix a crash when trying to input phone number in the autofill settings page...

Fix a crash when trying to input phone number in the autofill settings page while running as guest mode.

BUG=123346
TEST=Login as guest mode, open chrome://setting/autofillEditAddress, input some number in the Phone input field, hit tab, check that didn't cause a crash.


Review URL: http://codereview.chromium.org/10081023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132511 0039d316-1c4b-4281-b951-d872f2087c98
parent 08b81726
...@@ -405,7 +405,7 @@ void AutofillOptionsHandler::SetCreditCardOverlayStrings( ...@@ -405,7 +405,7 @@ void AutofillOptionsHandler::SetCreditCardOverlayStrings(
} }
void AutofillOptionsHandler::LoadAutofillData() { void AutofillOptionsHandler::LoadAutofillData() {
if (!personal_data_->IsDataLoaded()) if (!IsPersonalDataLoaded())
return; return;
ListValue addresses; ListValue addresses;
...@@ -439,7 +439,7 @@ void AutofillOptionsHandler::LoadAutofillData() { ...@@ -439,7 +439,7 @@ void AutofillOptionsHandler::LoadAutofillData() {
} }
void AutofillOptionsHandler::RemoveAddress(const ListValue* args) { void AutofillOptionsHandler::RemoveAddress(const ListValue* args) {
DCHECK(personal_data_->IsDataLoaded()); DCHECK(IsPersonalDataLoaded());
std::string guid; std::string guid;
if (!args->GetString(0, &guid)) { if (!args->GetString(0, &guid)) {
...@@ -451,7 +451,7 @@ void AutofillOptionsHandler::RemoveAddress(const ListValue* args) { ...@@ -451,7 +451,7 @@ void AutofillOptionsHandler::RemoveAddress(const ListValue* args) {
} }
void AutofillOptionsHandler::RemoveCreditCard(const ListValue* args) { void AutofillOptionsHandler::RemoveCreditCard(const ListValue* args) {
DCHECK(personal_data_->IsDataLoaded()); DCHECK(IsPersonalDataLoaded());
std::string guid; std::string guid;
if (!args->GetString(0, &guid)) { if (!args->GetString(0, &guid)) {
...@@ -463,7 +463,7 @@ void AutofillOptionsHandler::RemoveCreditCard(const ListValue* args) { ...@@ -463,7 +463,7 @@ void AutofillOptionsHandler::RemoveCreditCard(const ListValue* args) {
} }
void AutofillOptionsHandler::LoadAddressEditor(const ListValue* args) { void AutofillOptionsHandler::LoadAddressEditor(const ListValue* args) {
DCHECK(personal_data_->IsDataLoaded()); DCHECK(IsPersonalDataLoaded());
std::string guid; std::string guid;
if (!args->GetString(0, &guid)) { if (!args->GetString(0, &guid)) {
...@@ -502,7 +502,7 @@ void AutofillOptionsHandler::LoadAddressEditor(const ListValue* args) { ...@@ -502,7 +502,7 @@ void AutofillOptionsHandler::LoadAddressEditor(const ListValue* args) {
} }
void AutofillOptionsHandler::LoadCreditCardEditor(const ListValue* args) { void AutofillOptionsHandler::LoadCreditCardEditor(const ListValue* args) {
DCHECK(personal_data_->IsDataLoaded()); DCHECK(IsPersonalDataLoaded());
std::string guid; std::string guid;
if (!args->GetString(0, &guid)) { if (!args->GetString(0, &guid)) {
...@@ -537,7 +537,7 @@ void AutofillOptionsHandler::LoadCreditCardEditor(const ListValue* args) { ...@@ -537,7 +537,7 @@ void AutofillOptionsHandler::LoadCreditCardEditor(const ListValue* args) {
} }
void AutofillOptionsHandler::SetAddress(const ListValue* args) { void AutofillOptionsHandler::SetAddress(const ListValue* args) {
if (!personal_data_->IsDataLoaded()) if (!IsPersonalDataLoaded())
return; return;
std::string guid; std::string guid;
...@@ -581,7 +581,7 @@ void AutofillOptionsHandler::SetAddress(const ListValue* args) { ...@@ -581,7 +581,7 @@ void AutofillOptionsHandler::SetAddress(const ListValue* args) {
} }
void AutofillOptionsHandler::SetCreditCard(const ListValue* args) { void AutofillOptionsHandler::SetCreditCard(const ListValue* args) {
if (!personal_data_->IsDataLoaded()) if (!IsPersonalDataLoaded())
return; return;
std::string guid; std::string guid;
...@@ -611,7 +611,7 @@ void AutofillOptionsHandler::SetCreditCard(const ListValue* args) { ...@@ -611,7 +611,7 @@ void AutofillOptionsHandler::SetCreditCard(const ListValue* args) {
} }
void AutofillOptionsHandler::ValidatePhoneNumbers(const ListValue* args) { void AutofillOptionsHandler::ValidatePhoneNumbers(const ListValue* args) {
if (!personal_data_->IsDataLoaded()) if (!IsPersonalDataLoaded())
return; return;
ListValue* list_value = NULL; ListValue* list_value = NULL;
...@@ -621,4 +621,8 @@ void AutofillOptionsHandler::ValidatePhoneNumbers(const ListValue* args) { ...@@ -621,4 +621,8 @@ void AutofillOptionsHandler::ValidatePhoneNumbers(const ListValue* args) {
"AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value);
} }
bool AutofillOptionsHandler::IsPersonalDataLoaded() const {
return personal_data_ && personal_data_->IsDataLoaded();
}
} // namespace options2 } // namespace options2
...@@ -82,6 +82,9 @@ class AutofillOptionsHandler : public OptionsPageUIHandler, ...@@ -82,6 +82,9 @@ class AutofillOptionsHandler : public OptionsPageUIHandler,
// array of numbers, and the country code string set on the profile. // array of numbers, and the country code string set on the profile.
void ValidatePhoneNumbers(const base::ListValue* args); void ValidatePhoneNumbers(const base::ListValue* args);
// Returns true if |personal_data_| is non-null and loaded.
bool IsPersonalDataLoaded() const;
// The personal data manager, used to load Autofill profiles and credit cards. // The personal data manager, used to load Autofill profiles and credit cards.
// Unowned pointer, may not be NULL. // Unowned pointer, may not be NULL.
PersonalDataManager* personal_data_; PersonalDataManager* personal_data_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment