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

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

Issue 7892048: Autofill: Remove fax number completely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix. Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autofill_options_handler.h" 5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 AutofillProfile* profile) { 110 AutofillProfile* profile) {
111 std::vector<string16> values(list->GetSize()); 111 std::vector<string16> values(list->GetSize());
112 for (size_t i = 0; i < list->GetSize(); ++i) { 112 for (size_t i = 0; i < list->GetSize(); ++i) {
113 string16 value; 113 string16 value;
114 if (list->GetString(i, &value)) 114 if (list->GetString(i, &value))
115 values[i] = value; 115 values[i] = value;
116 } 116 }
117 profile->SetMultiInfo(type, values); 117 profile->SetMultiInfo(type, values);
118 } 118 }
119 119
120 // Pulls the phone (or fax) number |index|, |phone_number_list|, and 120 // Pulls the phone number |index|, |phone_number_list|, and |country_code| from
121 // |country_code| from the |args| input. 121 // the |args| input.
122 void ExtractPhoneNumberInformation(const ListValue* args, 122 void ExtractPhoneNumberInformation(const ListValue* args,
123 size_t* index, 123 size_t* index,
124 ListValue** phone_number_list, 124 ListValue** phone_number_list,
125 std::string* country_code) { 125 std::string* country_code) {
126 // Retrieve index as a |double|, as that is how it comes across from 126 // Retrieve index as a |double|, as that is how it comes across from
127 // JavaScript. 127 // JavaScript.
128 double number = 0.0; 128 double number = 0.0;
129 if (!args->GetDouble(0, &number)) { 129 if (!args->GetDouble(0, &number)) {
130 NOTREACHED(); 130 NOTREACHED();
131 return; 131 return;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 NewCallback(this, &AutofillOptionsHandler::LoadCreditCardEditor)); 246 NewCallback(this, &AutofillOptionsHandler::LoadCreditCardEditor));
247 web_ui_->RegisterMessageCallback( 247 web_ui_->RegisterMessageCallback(
248 "setAddress", 248 "setAddress",
249 NewCallback(this, &AutofillOptionsHandler::SetAddress)); 249 NewCallback(this, &AutofillOptionsHandler::SetAddress));
250 web_ui_->RegisterMessageCallback( 250 web_ui_->RegisterMessageCallback(
251 "setCreditCard", 251 "setCreditCard",
252 NewCallback(this, &AutofillOptionsHandler::SetCreditCard)); 252 NewCallback(this, &AutofillOptionsHandler::SetCreditCard));
253 web_ui_->RegisterMessageCallback( 253 web_ui_->RegisterMessageCallback(
254 "validatePhoneNumbers", 254 "validatePhoneNumbers",
255 NewCallback(this, &AutofillOptionsHandler::ValidatePhoneNumbers)); 255 NewCallback(this, &AutofillOptionsHandler::ValidatePhoneNumbers));
256 web_ui_->RegisterMessageCallback(
257 "validateFaxNumbers",
258 NewCallback(this, &AutofillOptionsHandler::ValidateFaxNumbers));
259 } 256 }
260 257
261 ///////////////////////////////////////////////////////////////////////////// 258 /////////////////////////////////////////////////////////////////////////////
262 // PersonalDataManagerObserver implementation: 259 // PersonalDataManagerObserver implementation:
263 void AutofillOptionsHandler::OnPersonalDataChanged() { 260 void AutofillOptionsHandler::OnPersonalDataChanged() {
264 LoadAutofillData(); 261 LoadAutofillData();
265 } 262 }
266 263
267 void AutofillOptionsHandler::SetAddressOverlayStrings( 264 void AutofillOptionsHandler::SetAddressOverlayStrings(
268 DictionaryValue* localized_strings) { 265 DictionaryValue* localized_strings) {
269 localized_strings->SetString("autofillEditAddressTitle", 266 localized_strings->SetString("autofillEditAddressTitle",
270 l10n_util::GetStringUTF16(IDS_AUTOFILL_EDIT_ADDRESS_CAPTION)); 267 l10n_util::GetStringUTF16(IDS_AUTOFILL_EDIT_ADDRESS_CAPTION));
271 localized_strings->SetString("fullNameLabel", 268 localized_strings->SetString("fullNameLabel",
272 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_FULL_NAME)); 269 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_FULL_NAME));
273 localized_strings->SetString("companyNameLabel", 270 localized_strings->SetString("companyNameLabel",
274 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COMPANY_NAME)); 271 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COMPANY_NAME));
275 localized_strings->SetString("addrLine1Label", 272 localized_strings->SetString("addrLine1Label",
276 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADDRESS_LINE_1)); 273 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADDRESS_LINE_1));
277 localized_strings->SetString("addrLine2Label", 274 localized_strings->SetString("addrLine2Label",
278 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADDRESS_LINE_2)); 275 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADDRESS_LINE_2));
279 localized_strings->SetString("cityLabel", 276 localized_strings->SetString("cityLabel",
280 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_CITY)); 277 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_CITY));
281 localized_strings->SetString("countryLabel", 278 localized_strings->SetString("countryLabel",
282 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COUNTRY)); 279 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COUNTRY));
283 localized_strings->SetString("phoneLabel", 280 localized_strings->SetString("phoneLabel",
284 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PHONE)); 281 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PHONE));
285 localized_strings->SetString("faxLabel",
286 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_FAX));
287 localized_strings->SetString("emailLabel", 282 localized_strings->SetString("emailLabel",
288 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EMAIL)); 283 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EMAIL));
289 localized_strings->SetString("addNewNamePlaceholder", 284 localized_strings->SetString("addNewNamePlaceholder",
290 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_NEW_NAME)); 285 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_NEW_NAME));
291 localized_strings->SetString("addNewPhonePlaceholder", 286 localized_strings->SetString("addNewPhonePlaceholder",
292 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_NEW_PHONE)); 287 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_NEW_PHONE));
293 localized_strings->SetString("addNewFaxPlaceholder",
294 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_NEW_FAX));
295 localized_strings->SetString("addNewEmailPlaceholder", 288 localized_strings->SetString("addNewEmailPlaceholder",
296 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_NEW_EMAIL)); 289 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_NEW_EMAIL));
297 290
298 std::string app_locale = AutofillCountry::ApplicationLocale(); 291 std::string app_locale = AutofillCountry::ApplicationLocale();
299 std::string default_country_code = 292 std::string default_country_code =
300 AutofillCountry::CountryCodeForLocale(app_locale); 293 AutofillCountry::CountryCodeForLocale(app_locale);
301 localized_strings->SetString("defaultCountryCode", default_country_code); 294 localized_strings->SetString("defaultCountryCode", default_country_code);
302 localized_strings->Set("autofillCountryData", GetCountryData()); 295 localized_strings->Set("autofillCountryData", GetCountryData());
303 } 296 }
304 297
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 address.Set("fullName", list.release()); 391 address.Set("fullName", list.release());
399 address.SetString("companyName", profile->GetInfo(COMPANY_NAME)); 392 address.SetString("companyName", profile->GetInfo(COMPANY_NAME));
400 address.SetString("addrLine1", profile->GetInfo(ADDRESS_HOME_LINE1)); 393 address.SetString("addrLine1", profile->GetInfo(ADDRESS_HOME_LINE1));
401 address.SetString("addrLine2", profile->GetInfo(ADDRESS_HOME_LINE2)); 394 address.SetString("addrLine2", profile->GetInfo(ADDRESS_HOME_LINE2));
402 address.SetString("city", profile->GetInfo(ADDRESS_HOME_CITY)); 395 address.SetString("city", profile->GetInfo(ADDRESS_HOME_CITY));
403 address.SetString("state", profile->GetInfo(ADDRESS_HOME_STATE)); 396 address.SetString("state", profile->GetInfo(ADDRESS_HOME_STATE));
404 address.SetString("postalCode", profile->GetInfo(ADDRESS_HOME_ZIP)); 397 address.SetString("postalCode", profile->GetInfo(ADDRESS_HOME_ZIP));
405 address.SetString("country", profile->CountryCode()); 398 address.SetString("country", profile->CountryCode());
406 GetValueList(*profile, PHONE_HOME_WHOLE_NUMBER, &list); 399 GetValueList(*profile, PHONE_HOME_WHOLE_NUMBER, &list);
407 address.Set("phone", list.release()); 400 address.Set("phone", list.release());
408 GetValueList(*profile, PHONE_FAX_WHOLE_NUMBER, &list);
409 address.Set("fax", list.release());
410 GetValueList(*profile, EMAIL_ADDRESS, &list); 401 GetValueList(*profile, EMAIL_ADDRESS, &list);
411 address.Set("email", list.release()); 402 address.Set("email", list.release());
412 403
413 web_ui_->CallJavascriptFunction("AutofillOptions.editAddress", address); 404 web_ui_->CallJavascriptFunction("AutofillOptions.editAddress", address);
414 } 405 }
415 406
416 void AutofillOptionsHandler::LoadCreditCardEditor(const ListValue* args) { 407 void AutofillOptionsHandler::LoadCreditCardEditor(const ListValue* args) {
417 DCHECK(personal_data_->IsDataLoaded()); 408 DCHECK(personal_data_->IsDataLoaded());
418 409
419 std::string guid; 410 std::string guid;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 profile.SetInfo(ADDRESS_HOME_CITY, value); 466 profile.SetInfo(ADDRESS_HOME_CITY, value);
476 if (args->GetString(6, &value)) 467 if (args->GetString(6, &value))
477 profile.SetInfo(ADDRESS_HOME_STATE, value); 468 profile.SetInfo(ADDRESS_HOME_STATE, value);
478 if (args->GetString(7, &value)) 469 if (args->GetString(7, &value))
479 profile.SetInfo(ADDRESS_HOME_ZIP, value); 470 profile.SetInfo(ADDRESS_HOME_ZIP, value);
480 if (args->GetString(8, &country_code)) 471 if (args->GetString(8, &country_code))
481 profile.SetCountryCode(country_code); 472 profile.SetCountryCode(country_code);
482 if (args->GetList(9, &list_value)) 473 if (args->GetList(9, &list_value))
483 SetValueList(list_value, PHONE_HOME_WHOLE_NUMBER, &profile); 474 SetValueList(list_value, PHONE_HOME_WHOLE_NUMBER, &profile);
484 if (args->GetList(10, &list_value)) 475 if (args->GetList(10, &list_value))
485 SetValueList(list_value, PHONE_FAX_WHOLE_NUMBER, &profile);
486 if (args->GetList(11, &list_value))
487 SetValueList(list_value, EMAIL_ADDRESS, &profile); 476 SetValueList(list_value, EMAIL_ADDRESS, &profile);
488 477
489 if (!guid::IsValidGUID(profile.guid())) { 478 if (!guid::IsValidGUID(profile.guid())) {
490 profile.set_guid(guid::GenerateGUID()); 479 profile.set_guid(guid::GenerateGUID());
491 personal_data_->AddProfile(profile); 480 personal_data_->AddProfile(profile);
492 } else { 481 } else {
493 personal_data_->UpdateProfile(profile); 482 personal_data_->UpdateProfile(profile);
494 } 483 }
495 } 484 }
496 485
(...skipping 30 matching lines...) Expand all
527 void AutofillOptionsHandler::ValidatePhoneNumbers(const ListValue* args) { 516 void AutofillOptionsHandler::ValidatePhoneNumbers(const ListValue* args) {
528 if (!personal_data_->IsDataLoaded()) 517 if (!personal_data_->IsDataLoaded())
529 return; 518 return;
530 519
531 ListValue* list_value = NULL; 520 ListValue* list_value = NULL;
532 ValidatePhoneArguments(args, &list_value); 521 ValidatePhoneArguments(args, &list_value);
533 522
534 web_ui_->CallJavascriptFunction( 523 web_ui_->CallJavascriptFunction(
535 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); 524 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value);
536 } 525 }
537
538 void AutofillOptionsHandler::ValidateFaxNumbers(const ListValue* args) {
539 if (!personal_data_->IsDataLoaded())
540 return;
541
542 ListValue* list_value = NULL;
543 ValidatePhoneArguments(args, &list_value);
544
545 web_ui_->CallJavascriptFunction(
546 "AutofillEditAddressOverlay.setValidatedFaxNumbers", *list_value);
547 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/autofill_options_handler.h ('k') | chrome/browser/webdata/autofill_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698