From dd856dfd5ce52bf74131726882c30bf3eb0de3c3 Mon Sep 17 00:00:00 2001 From: "isherman@chromium.org" Date: Sat, 23 Oct 2010 00:52:41 +0000 Subject: Remove billing address handling from Autofill preferences. Removes the billing address drop down from the Autofill preferences "Add credit card" dialog. Nib changes: remove the billing address label and drop down from AutoFillCreditCardSheet.xib. BUG=57976 TEST=compiles, no billing address drop down visible in any Autofill preferences UI. Review URL: http://codereview.chromium.org/3964003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63605 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/generated_resources.grd | 15 -- chrome/app/nibs/AutoFillCreditCardSheet.xib | 251 +++------------------ chrome/app/resources/locale_settings.grd | 8 +- chrome/browser/autofill/auto_fill_editor_gtk.cc | 115 +--------- .../autofill/autofill_credit_card_model_mac.h | 2 - .../autofill/autofill_credit_card_model_mac.mm | 3 - .../autofill_credit_card_model_mac_unittest.mm | 7 +- .../autofill_credit_card_sheet_controller_mac.h | 19 +- .../autofill_credit_card_sheet_controller_mac.mm | 52 +---- ...ll_credit_card_sheet_controller_mac_unittest.mm | 3 +- .../autofill/autofill_dialog_controller_mac.mm | 6 +- .../autofill_dialog_controller_mac_unittest.mm | 7 +- .../dom_ui/options/autofill_options_handler.cc | 17 +- .../options/autofill_edit_creditcard_overlay.html | 7 - .../options/autofill_edit_creditcard_overlay.js | 87 +------ .../browser/resources/options/autofill_options.js | 1 - chrome/browser/views/autofill_profiles_view_win.cc | 116 +--------- chrome/browser/views/autofill_profiles_view_win.h | 47 ---- 18 files changed, 65 insertions(+), 698 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 8b2af54..c0e6778 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6745,9 +6745,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Expiration date: - - Billing address: - @@ -6798,9 +6795,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Expiration date - - Billing address - @@ -6812,15 +6806,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Last name - - Shipping - - - Choose existing address - - - same as billing - Save diff --git a/chrome/app/nibs/AutoFillCreditCardSheet.xib b/chrome/app/nibs/AutoFillCreditCardSheet.xib index 23c4b12..0ff59ee 100644 --- a/chrome/app/nibs/AutoFillCreditCardSheet.xib +++ b/chrome/app/nibs/AutoFillCreditCardSheet.xib @@ -47,7 +47,7 @@ 1 2 - {{100, 165}, {400, 225}} + {{100, 205}, {400, 185}} 603979776 Window NSWindow @@ -61,7 +61,7 @@ 268 - {{17, 188}, {196, 17}} + {{17, 148}, {196, 17}} YES @@ -117,7 +117,7 @@ 268 - {{17, 159}, {146, 17}} + {{17, 119}, {146, 17}} YES @@ -165,93 +165,6 @@ - - - 268 - {{17, 131}, {146, 17}} - - YES - - 68288064 - 71435264 - ^IDS_AUTOFILL_DIALOG_BILLING_ADDRESS - - - - - - - - - 268 - {{165, 126}, {196, 26}} - - YES - - -2076049856 - 2048 - - - 109199615 - 129 - - - 400 - 75 - - - - - 1048576 - 2147483647 - 1 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - - _popUpItemAction: - - - YES - - OtherViews - - YES - - - - Item 2 - - 1048576 - 2147483647 - - - _popUpItemAction: - - - - - Item 3 - - 1048576 - 2147483647 - - - _popUpItemAction: - - - - - 1 - YES - YES - 2 - - 268 @@ -271,7 +184,7 @@ 268 - {{168, 158}, {190, 22}} + {{168, 118}, {190, 22}} YES @@ -350,8 +263,14 @@ 1048576 2147483647 1 - - + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + _popUpItemAction: @@ -367,8 +286,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -378,8 +297,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -415,8 +334,8 @@ 1048576 2147483647 1 - - + + _popUpItemAction: @@ -432,8 +351,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -443,8 +362,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -457,7 +376,7 @@ - {400, 225} + {400, 185} {{0, 0}, {1680, 1028}} @@ -469,14 +388,6 @@ YES - billingAddressPopup_ - - - - 152 - - - owner_ @@ -516,22 +427,6 @@ 177 - - contentValues: billingAddressContents - - - - - - contentValues: billingAddressContents - contentValues - billingAddressContents - 2 - - - 188 - - window @@ -706,13 +601,11 @@ YES - + + - - - @@ -763,64 +656,6 @@ - 54 - - - YES - - - - - - 57 - - - - - 102 - - - YES - - - - - - 103 - - - YES - - - - - - 104 - - - YES - - - - - - - - 105 - - - - - 106 - - - - - 107 - - - - 21 @@ -985,13 +820,6 @@ YES -3.IBPluginDependency - 102.IBPluginDependency - 103.IBPluginDependency - 104.IBEditorWindowLastContentRect - 104.IBPluginDependency - 105.IBPluginDependency - 106.IBPluginDependency - 107.IBPluginDependency 17.IBPluginDependency 18.CustomClassName 18.IBPluginDependency @@ -1028,20 +856,11 @@ 241.IBPluginDependency 25.IBPluginDependency 28.IBPluginDependency - 54.IBPluginDependency - 57.IBPluginDependency YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{549, 708}, {196, 63}} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin AutoFillTextField com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1052,9 +871,9 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{413, 619}, {400, 225}} + {{162, 701}, {400, 185}} com.apple.InterfaceBuilder.CocoaPlugin - {{413, 619}, {400, 225}} + {{162, 701}, {400, 185}} com.apple.InterfaceBuilder.CocoaPlugin AutoFillTextField @@ -1077,8 +896,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin @@ -1141,7 +958,6 @@ YES YES - billingAddressPopup_ caption_ creditCardNumberField_ expirationMonthPopup_ @@ -1149,7 +965,6 @@ YES - NSPopUpButton NSTextField NSTextField NSPopUpButton @@ -1160,7 +975,6 @@ YES YES - billingAddressPopup_ caption_ creditCardNumberField_ expirationMonthPopup_ @@ -1169,10 +983,6 @@ YES - billingAddressPopup_ - NSPopUpButton - - caption_ NSTextField @@ -1311,6 +1121,13 @@ NSWindow IBProjectSource + browser/cocoa/nswindow_additions.h + + + + NSWindow + + IBProjectSource browser/cocoa/themed_window.h diff --git a/chrome/app/resources/locale_settings.grd b/chrome/app/resources/locale_settings.grd index ed25b39..484bf4e 100644 --- a/chrome/app/resources/locale_settings.grd +++ b/chrome/app/resources/locale_settings.grd @@ -373,8 +373,8 @@ http://www.google.com/support/chrome/bin/answer.py?hl=[GRITLANGCODE]&answer=95617 - - + + 50 @@ -545,7 +545,7 @@ - http://www.google.com/support/chrome/bin/answer.py?answer=95697&topic=14687 + http://www.google.com/support/chrome/bin/answer.py?answer=95697&topic=14687 @@ -675,7 +675,7 @@ - 13 + 9 diff --git a/chrome/browser/autofill/auto_fill_editor_gtk.cc b/chrome/browser/autofill/auto_fill_editor_gtk.cc index 09442d7..05675ec 100644 --- a/chrome/browser/autofill/auto_fill_editor_gtk.cc +++ b/chrome/browser/autofill/auto_fill_editor_gtk.cc @@ -530,25 +530,8 @@ class AutoFillCreditCardEditor { private: friend class DeleteTask; - // Types of columns in the address_store_. - enum ColumnTypes { - // Unique if of the CreditCard. - COL_ID, - - // Title of the column. - COL_TITLE, - - COL_COUNT - }; - virtual ~AutoFillCreditCardEditor() {} - // Creates the GtkListStore used to show the billing addresses. - GtkListStore* CreateAddressStore(); - - // Creates the combobox used to show the billing addresses. - GtkWidget* CreateAddressWidget(); - // Creates the combobox for choosing the month. GtkWidget* CreateMonthWidget(); @@ -601,14 +584,11 @@ class AutoFillCreditCardEditor { GtkWidget* dialog_; GtkWidget* name_; - GtkWidget* address_; GtkWidget* number_; GtkWidget* month_; GtkWidget* year_; GtkWidget* ok_button_; - GtkListStore* address_store_; - DISALLOW_COPY_AND_ASSIGN(AutoFillCreditCardEditor); }; @@ -631,11 +611,7 @@ AutoFillCreditCardEditor::AutoFillCreditCardEditor( if (credit_card) { SetWidgetValues(credit_card); } else { - // We're creating a new credit card. Select a default billing address (if - // there are any) and select January of next year. - PersonalDataManager* data_manager = profile_->GetPersonalDataManager(); - if (!data_manager->profiles().empty()) - gtk_combo_box_set_active(GTK_COMBO_BOX(address_), 0); + // We're creating a new credit card. Select January of next year by default. gtk_combo_box_set_active(GTK_COMBO_BOX(month_), 0); gtk_combo_box_set_active(GTK_COMBO_BOX(year_), 1); } @@ -652,54 +628,6 @@ AutoFillCreditCardEditor::AutoFillCreditCardEditor( gtk_util::PresentWindow(dialog_, gtk_get_current_event_time()); } -GtkListStore* AutoFillCreditCardEditor::CreateAddressStore() { - GtkListStore* store = - gtk_list_store_new(COL_COUNT, G_TYPE_INT, G_TYPE_STRING); - - GtkTreeIter iter; - - PersonalDataManager* data_manager = profile_->GetPersonalDataManager(); - for (std::vector::const_iterator i = - data_manager->profiles().begin(); - i != data_manager->profiles().end(); ++i) { - FieldTypeSet fields; - (*i)->GetAvailableFieldTypes(&fields); - if (fields.find(ADDRESS_HOME_LINE1) == fields.end() && - fields.find(ADDRESS_HOME_LINE2) == fields.end() && - fields.find(ADDRESS_HOME_APT_NUM) == fields.end() && - fields.find(ADDRESS_HOME_CITY) == fields.end() && - fields.find(ADDRESS_HOME_STATE) == fields.end() && - fields.find(ADDRESS_HOME_ZIP) == fields.end() && - fields.find(ADDRESS_HOME_COUNTRY) == fields.end()) { - // No address information in this profile; it's useless as a billing - // address. - continue; - } - - gtk_list_store_append(store, &iter); - gtk_list_store_set( - store, &iter, - COL_ID, (*i)->unique_id(), - COL_TITLE, UTF16ToUTF8((*i)->PreviewSummary()).c_str(), - -1); - } - return store; -} - -GtkWidget* AutoFillCreditCardEditor::CreateAddressWidget() { - address_store_ = CreateAddressStore(); - - GtkWidget* widget = gtk_combo_box_new_with_model( - GTK_TREE_MODEL(address_store_)); - g_object_unref(address_store_); - - GtkCellRenderer* cell = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), cell, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), cell, - "text", COL_TITLE, NULL); - return widget; -} - GtkWidget* AutoFillCreditCardEditor::CreateMonthWidget() { GtkWidget* combobox = gtk_combo_box_new_text(); for (int i = 1; i <= 12; ++i) { @@ -723,16 +651,12 @@ GtkWidget* AutoFillCreditCardEditor::CreateYearWidget() { } void AutoFillCreditCardEditor::Init() { - TableBuilder main_table_builder(8, 2); + TableBuilder main_table_builder(6, 2); main_table_builder.AddWidget( CreateLabel(IDS_AUTOFILL_DIALOG_NAME_ON_CARD), 2); name_ = main_table_builder.AddWidget(gtk_entry_new(), 2); - main_table_builder.AddWidget(CreateLabel(IDS_AUTOFILL_DIALOG_BILLING_ADDRESS), - 2); - address_ = main_table_builder.AddWidget(CreateAddressWidget(), 2); - main_table_builder.AddWidget( CreateLabel(IDS_AUTOFILL_DIALOG_CREDIT_CARD_NUMBER), 2); number_ = main_table_builder.AddWidget(gtk_entry_new(), 1); @@ -785,17 +709,6 @@ void AutoFillCreditCardEditor::RegisterForTextChanged() { void AutoFillCreditCardEditor::SetWidgetValues(CreditCard* card) { SetEntryText(name_, card, CREDIT_CARD_NAME); - PersonalDataManager* data_manager = profile_->GetPersonalDataManager(); - for (std::vector::const_iterator i = - data_manager->profiles().begin(); - i != data_manager->profiles().end(); ++i) { - if ((*i)->unique_id() == card->billing_address_id()) { - int index = static_cast(i - data_manager->profiles().begin()); - gtk_combo_box_set_active(GTK_COMBO_BOX(address_), index); - break; - } - } - gtk_entry_set_text(GTK_ENTRY(number_), UTF16ToUTF8(card->ObfuscatedNumber()).c_str()); @@ -857,32 +770,8 @@ void AutoFillCreditCardEditor::ApplyEdits() { void AutoFillCreditCardEditor::SetCreditCardValuesFromWidgets( CreditCard* card) { - PersonalDataManager* data_manager = profile_->GetPersonalDataManager(); - SetFormValue(name_, card, CREDIT_CARD_NAME); - card->set_billing_address_id(0); - int selected_address_index = - gtk_combo_box_get_active(GTK_COMBO_BOX(address_)); - if (selected_address_index != -1) { - GtkTreeIter iter; - gtk_tree_model_iter_nth_child( - GTK_TREE_MODEL(address_store_), &iter, NULL, selected_address_index); - GValue value = { 0 }; - gtk_tree_model_get_value( - GTK_TREE_MODEL(address_store_), &iter, COL_ID, &value); - int id = g_value_get_int(&value); - for (std::vector::const_iterator i = - data_manager->profiles().begin(); - i != data_manager->profiles().end(); ++i) { - if ((*i)->unique_id() == id) { - card->set_billing_address_id(id); - break; - } - } - g_value_unset(&value); - } - if (edited_number_) SetFormValue(number_, card, CREDIT_CARD_NUMBER); diff --git a/chrome/browser/autofill/autofill_credit_card_model_mac.h b/chrome/browser/autofill/autofill_credit_card_model_mac.h index 277ff555..093e7cb 100644 --- a/chrome/browser/autofill/autofill_credit_card_model_mac.h +++ b/chrome/browser/autofill/autofill_credit_card_model_mac.h @@ -25,14 +25,12 @@ class CreditCard; NSString* creditCardNumber_; NSString* expirationMonth_; NSString* expirationYear_; - NSInteger billingAddressID_; } @property (nonatomic, copy) NSString* nameOnCard; @property (nonatomic, copy) NSString* creditCardNumber; @property (nonatomic, copy) NSString* expirationMonth; @property (nonatomic, copy) NSString* expirationYear; -@property (nonatomic) NSInteger billingAddressID; // Designated initializer. Initializes the property strings to values retrieved // from the |creditCard| object. diff --git a/chrome/browser/autofill/autofill_credit_card_model_mac.mm b/chrome/browser/autofill/autofill_credit_card_model_mac.mm index 5c49ab2..1eec96f 100644 --- a/chrome/browser/autofill/autofill_credit_card_model_mac.mm +++ b/chrome/browser/autofill/autofill_credit_card_model_mac.mm @@ -15,7 +15,6 @@ @synthesize creditCardNumber = creditCardNumber_; @synthesize expirationMonth = expirationMonth_; @synthesize expirationYear = expirationYear_; -@synthesize billingAddressID = billingAddressID_; - (id)initWithCreditCard:(const CreditCard&)creditCard { if ((self = [super init])) { @@ -27,7 +26,6 @@ creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_MONTH)))]; [self setExpirationYear:SysUTF16ToNSString( creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)))]; - [self setBillingAddressID:creditCard.billing_address_id()]; } return self; } @@ -50,7 +48,6 @@ base::SysNSStringToUTF16([self expirationMonth])); creditCard->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), base::SysNSStringToUTF16([self expirationYear])); - creditCard->set_billing_address_id([self billingAddressID]); } @end diff --git a/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm b/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm index f90f7d1..d239f9e 100644 --- a/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm +++ b/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm @@ -27,7 +27,7 @@ TEST(AutoFillCreditCardModelTest, Basic) { TEST(AutoFillCreditCardModelTest, InitializationFromCreditCard) { CreditCard credit_card(string16(), 0); autofill_test::SetCreditCardInfo(&credit_card, "Corporate", - "John Dillinger", "Visa", "123456789012", "01", "2010", 1); + "John Dillinger", "Visa", "123456789012", "01", "2010", 0); scoped_nsobject model( [[AutoFillCreditCardModel alloc] initWithCreditCard:credit_card]); EXPECT_TRUE(model.get()); @@ -36,13 +36,12 @@ TEST(AutoFillCreditCardModelTest, InitializationFromCreditCard) { EXPECT_TRUE([[model creditCardNumber] isEqualToString:@"123456789012"]); EXPECT_TRUE([[model expirationMonth] isEqualToString:@"01"]); EXPECT_TRUE([[model expirationYear] isEqualToString:@"2010"]); - EXPECT_EQ(1, [model billingAddressID]); } TEST(AutoFillCreditCardModelTest, CopyModelToCreditCard) { CreditCard credit_card(string16(), 0); autofill_test::SetCreditCardInfo(&credit_card, "Corporate", - "John Dillinger", "Visa", "123456789012", "01", "2010", 1); + "John Dillinger", "Visa", "123456789012", "01", "2010", 0); scoped_nsobject model( [[AutoFillCreditCardModel alloc] initWithCreditCard:credit_card]); EXPECT_TRUE(model.get()); @@ -51,7 +50,6 @@ TEST(AutoFillCreditCardModelTest, CopyModelToCreditCard) { [model setCreditCardNumber:@"223456789012"]; [model setExpirationMonth:@"11"]; [model setExpirationYear:@"2011"]; - [model setBillingAddressID:2]; [model copyModelToCreditCard:&credit_card]; @@ -64,7 +62,6 @@ TEST(AutoFillCreditCardModelTest, CopyModelToCreditCard) { EXPECT_EQ(ASCIIToUTF16("2011"), credit_card.GetFieldText( AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR))); - EXPECT_EQ(2, credit_card.billing_address_id()); } } // namespace diff --git a/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.h b/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.h index 76fa2ad..650fb1c 100644 --- a/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.h +++ b/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.h @@ -27,7 +27,6 @@ typedef NSInteger AutoFillCreditCardMode; // and transcribes it to |creditCardModel| to which the view is bound. @interface AutoFillCreditCardSheetController : NSWindowController { @private - IBOutlet NSPopUpButton* billingAddressPopup_; IBOutlet NSPopUpButton* expirationMonthPopup_; IBOutlet NSPopUpButton* expirationYearPopup_; @@ -44,40 +43,24 @@ typedef NSInteger AutoFillCreditCardMode; // because it is exposed as a KVO compliant property. AutoFillCreditCardModel* creditCardModel_; - // Array of strings that populate the |billingAddressPopup_| control. We - // do not hold this as scoped_nsobject because it is exposed as a KVO - // compliant property. The values of this array may change as the list - // of addresses change in the |parentController_|. - NSArray* billingAddressContents_; - - // Array of IDs corresponding to the strings in |billingAddressContents_|. - std::vector billingAddressIDs_; - // Contents of the expiration month and year popups. Strongly owned. We do // not hold them as scoped_nsobjects because they are exposed as KVO compliant // properties. NSArray* expirationMonthContents_; NSArray* expirationYearContents_; - // A reference to our parent controller. Used for fetching billing address - // labels. May be not be nil. - // Weak reference, owns us. - AutoFillDialogController* parentController_; - // Either "Add" or "Edit" mode of sheet. AutoFillCreditCardMode mode_; } @property (nonatomic, retain) AutoFillCreditCardModel* creditCardModel; -@property (nonatomic, retain) NSArray* billingAddressContents; @property (nonatomic, retain) NSArray* expirationMonthContents; @property (nonatomic, retain) NSArray* expirationYearContents; // Designated initializer. Takes a copy of the data in |creditCard|, // it is not held as a reference. - (id)initWithCreditCard:(const CreditCard&)creditCard - mode:(AutoFillCreditCardMode)mode - controller:(AutoFillDialogController*)parentController; + mode:(AutoFillCreditCardMode)mode; // IBActions for save and cancel buttons. Both invoke |endSheet:|. - (IBAction)save:(id)sender; diff --git a/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.mm b/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.mm index 31fbff0..95eb140 100644 --- a/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.mm +++ b/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.mm @@ -21,7 +21,6 @@ // Private methods for the |AutoFillCreditCardSheetController| class. @interface AutoFillCreditCardSheetController (PrivateMethods) -- (void)buildBillingAddressContents; - (void)buildExpirationMonthContents; - (void)buildExpirationYearContents; @end @@ -29,13 +28,11 @@ @implementation AutoFillCreditCardSheetController @synthesize creditCardModel = creditCardModel_; -@synthesize billingAddressContents = billingAddressContents_; @synthesize expirationMonthContents = expirationMonthContents_; @synthesize expirationYearContents = expirationYearContents_; - (id)initWithCreditCard:(const CreditCard&)creditCard - mode:(AutoFillCreditCardMode)mode - controller:(AutoFillDialogController*)parentController { + mode:(AutoFillCreditCardMode)mode { NSString* nibPath = [mac_util::MainAppBundle() pathForResource:@"AutoFillCreditCardSheet" ofType:@"nib"]; @@ -45,9 +42,6 @@ [self setCreditCardModel:[[[AutoFillCreditCardModel alloc] initWithCreditCard:creditCard] autorelease]]; - // We keep track of our parent controller for model-update purposes. - parentController_ = parentController; - mode_ = mode; } return self; @@ -55,7 +49,6 @@ - (void)dealloc { [creditCardModel_ release]; - [billingAddressContents_ release]; [expirationMonthContents_ release]; [expirationYearContents_ release]; [super dealloc]; @@ -63,12 +56,10 @@ - (void)awakeFromNib { // Setup initial state of popups. - [self buildBillingAddressContents]; [self buildExpirationMonthContents]; [self buildExpirationYearContents]; // Turn menu autoenable off. We manually govern this. - [billingAddressPopup_ setAutoenablesItems:NO]; [expirationMonthPopup_ setAutoenablesItems:NO]; [expirationYearPopup_ setAutoenablesItems:NO]; @@ -97,55 +88,14 @@ - (void)copyModelToCreditCard:(CreditCard*)creditCard { // The model copies the popup values blindly. We need to clear the strings // in the case that our special menus are in effect. - if ([billingAddressPopup_ indexOfSelectedItem] <= 0) - [creditCardModel_ setBillingAddressID:0]; if ([expirationMonthPopup_ indexOfSelectedItem] <= 0) [creditCardModel_ setExpirationMonth:@""]; if ([expirationYearPopup_ indexOfSelectedItem] <= 0) [creditCardModel_ setExpirationYear:@""]; - // The view does not set the billing address directly. It relies on - // the controller to translate between popup index and the billing address - // ID. Note the -1 offset. This is due to the empty menu item in the popup. - if ([billingAddressPopup_ indexOfSelectedItem] > 0) { - [creditCardModel_ setBillingAddressID: - billingAddressIDs_[[billingAddressPopup_ indexOfSelectedItem]-1]]; - } [creditCardModel_ copyModelToCreditCard:creditCard]; } -// Builds the |billingAddressContents_| array of strings from the list of -// addresses returned by the |parentController_| and additional UI string. -// Ensures that current selection is valid. If not, reset it. -- (void)buildBillingAddressContents { - NSString* menuString = l10n_util::GetNSString( - IDS_AUTOFILL_DIALOG_CHOOSE_EXISTING_ADDRESS); - - // Build the menu array and set it. - NSArray* addressStrings = nil; - [parentController_ addressLabels:&addressStrings - addressIDs:&billingAddressIDs_]; - NSArray* newArray = [[NSArray arrayWithObject:menuString] - arrayByAddingObjectsFromArray:addressStrings]; - [self setBillingAddressContents:newArray]; - - // If the addresses no longer contain our billing address then reset the - // selection. - int distance = std::distance(billingAddressIDs_.begin(), - std::find(billingAddressIDs_.begin(), - billingAddressIDs_.end(), - [creditCardModel_ billingAddressID])); - if (distance >= static_cast(billingAddressIDs_.size())) { - [billingAddressPopup_ selectItemAtIndex:0]; - } else { - [billingAddressPopup_ selectItemAtIndex:distance+1]; - } - - - // Disable first item in menu. "Choose existing address" is a non-item. - [[billingAddressPopup_ itemAtIndex:0] setEnabled:NO]; -} - // Builds array of valid months. Uses special @" " to indicate no selection. - (void)buildExpirationMonthContents { NSArray* newArray = [NSArray arrayWithObjects:@" ", diff --git a/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac_unittest.mm b/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac_unittest.mm index 9058070..f6c01d5 100644 --- a/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac_unittest.mm +++ b/chrome/browser/autofill/autofill_credit_card_sheet_controller_mac_unittest.mm @@ -21,8 +21,7 @@ TEST(AutoFillCreditCardSheetControllerTest, Basic) { scoped_nsobject controller( [[AutoFillCreditCardSheetController alloc] initWithCreditCard:credit_card - mode:kAutoFillCreditCardAddMode - controller:nil]); + mode:kAutoFillCreditCardAddMode]); EXPECT_TRUE(controller.get()); } diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac.mm b/chrome/browser/autofill/autofill_dialog_controller_mac.mm index f48f952..46acdab 100644 --- a/chrome/browser/autofill/autofill_dialog_controller_mac.mm +++ b/chrome/browser/autofill/autofill_dialog_controller_mac.mm @@ -325,8 +325,7 @@ class PreferenceObserver : public NotificationObserver { creditCardSheetController.reset( [[AutoFillCreditCardSheetController alloc] initWithCreditCard:newCreditCard - mode:kAutoFillCreditCardAddMode - controller:self]); + mode:kAutoFillCreditCardAddMode]); // Show the sheet. [NSApp beginSheet:[creditCardSheetController window] @@ -458,8 +457,7 @@ class PreferenceObserver : public NotificationObserver { creditCardSheetController.reset( [[AutoFillCreditCardSheetController alloc] initWithCreditCard:creditCards_[i] - mode:kAutoFillCreditCardEditMode - controller:self]); + mode:kAutoFillCreditCardEditMode]); // Show the sheet. [NSApp beginSheet:[creditCardSheetController window] diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm index e8c7dab..0e6eeab 100644 --- a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm +++ b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm @@ -114,9 +114,8 @@ class AutoFillDialogObserverMock : public AutoFillDialogObserver { : hit_(false) {} virtual ~AutoFillDialogObserverMock() {} - virtual void OnAutoFillDialogApply( - std::vector* profiles, - std::vector* credit_cards) { + virtual void OnAutoFillDialogApply(std::vector* profiles, + std::vector* credit_cards) { hit_ = true; std::vector::iterator i; @@ -265,7 +264,6 @@ TEST_F(AutoFillDialogControllerTest, CreditCardDataMutation) { credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01")); credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), ASCIIToUTF16("2012")); - credit_card.set_billing_address_id(0); credit_cards().push_back(&credit_card); LoadDialog(); @@ -402,7 +400,6 @@ TEST_F(AutoFillDialogControllerTest, AddNewCreditCard) { // New credit card should match. Don't compare labels. CreditCard new_credit_card; new_credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Don")); - new_credit_card.set_billing_address_id(0); observer_.credit_cards_[1].set_label(string16()); ASSERT_EQ(observer_.credit_cards_[1], new_credit_card); } diff --git a/chrome/browser/dom_ui/options/autofill_options_handler.cc b/chrome/browser/dom_ui/options/autofill_options_handler.cc index 808353b..62cc760 100644 --- a/chrome/browser/dom_ui/options/autofill_options_handler.cc +++ b/chrome/browser/dom_ui/options/autofill_options_handler.cc @@ -142,10 +142,6 @@ void AutoFillOptionsHandler::SetCreditCardOverlayStrings( l10n_util::GetStringUTF16(IDS_AUTOFILL_EDIT_CREDITCARD_CAPTION)); localized_strings->SetString("nameOnCardLabel", l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_NAME_ON_CARD)); - localized_strings->SetString("billingAddressLabel", - l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_BILLING_ADDRESS)); - localized_strings->SetString("chooseExistingAddress", - l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_CHOOSE_EXISTING_ADDRESS)); localized_strings->SetString("creditCardNumberLabel", l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_CREDIT_CARD_NUMBER)); localized_strings->SetString("creditCardExpirationDateLabel", @@ -306,16 +302,11 @@ void AutoFillOptionsHandler::UpdateCreditCard(const ListValue* args) { string16 value; if (args->GetString(1, &value)) credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), value); - if (args->GetString(2, &value)) { - int id = 0; - base::StringToInt(value, &id); - credit_card.set_billing_address_id(id); - } - if (args->GetString(3, &value)) + if (args->GetString(2, &value)) credit_card.SetInfo(AutoFillType(CREDIT_CARD_NUMBER), value); - if (args->GetString(4, &value)) + if (args->GetString(3, &value)) credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), value); - if (args->GetString(5, &value)) + if (args->GetString(4, &value)) credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), value); if (unique_id == 0) @@ -358,8 +349,6 @@ void AutoFillOptionsHandler::EditCreditCard(const ListValue* args) { credit_card_data->SetString( "nameOnCard", credit_card->GetFieldText(AutoFillType(CREDIT_CARD_NAME))); - credit_card_data->SetInteger( - "billingAddress", credit_card->billing_address_id()); credit_card_data->SetString( "creditCardNumber", credit_card->GetFieldText(AutoFillType(CREDIT_CARD_NUMBER))); diff --git a/chrome/browser/resources/options/autofill_edit_creditcard_overlay.html b/chrome/browser/resources/options/autofill_edit_creditcard_overlay.html index a4aef34..32d2aba 100644 --- a/chrome/browser/resources/options/autofill_edit_creditcard_overlay.html +++ b/chrome/browser/resources/options/autofill_edit_creditcard_overlay.html @@ -9,13 +9,6 @@
- -
- -