diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 17:19:57 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 17:19:57 +0000 |
commit | cff83feff679cf3f593f1c591ac91fc3b47277bd (patch) | |
tree | 052429411724e60429b6b4c5905fd4e469e283d4 /chrome/browser/autofill/autofill_credit_card_view_controller_mac.mm | |
parent | ba4874ea3edd4142f1f56d533dad25274e484edb (diff) | |
download | chromium_src-cff83feff679cf3f593f1c591ac91fc3b47277bd.zip chromium_src-cff83feff679cf3f593f1c591ac91fc3b47277bd.tar.gz chromium_src-cff83feff679cf3f593f1c591ac91fc3b47277bd.tar.bz2 |
AutoFill Profiles dialog implemented according to new mocks on Mac
New mocks are attached to bug 44622. These changes replace the in-place editing of address and credit card records with a table of records and separate sheets for manipulating the record data. Changes to the layout of fields on the sheets has been done also.
AutoFillDialog.xib changes: Replaced disclosure based list of address and credit cards with an NSTableView of the same data. Added buttons for "Add", "Edit", and "Remove".
Replaced AutoFillAddressViewController.xib with sheet-based AutoFillAddressSheetController.xib.
Replaced AutoFillCreditCardViewController.xib with sheet-based AutoFillCreditCardSheetController.xib.
BUG=44621
TEST=AutoFillAddressModelTest,AutoFillAddressSheetControllerTest,AutoFillCreditCardModelTest,AutoFillCreditCardSheetControllerTest,AutoFillDialogControllerTest
Review URL: http://codereview.chromium.org/2673006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_credit_card_view_controller_mac.mm')
-rw-r--r-- | chrome/browser/autofill/autofill_credit_card_view_controller_mac.mm | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/chrome/browser/autofill/autofill_credit_card_view_controller_mac.mm b/chrome/browser/autofill/autofill_credit_card_view_controller_mac.mm deleted file mode 100644 index 8e7b29c..0000000 --- a/chrome/browser/autofill/autofill_credit_card_view_controller_mac.mm +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import "chrome/browser/autofill/autofill_credit_card_view_controller_mac.h" -#include "app/l10n_util.h" -#include "base/mac_util.h" -#include "base/sys_string_conversions.h" -#import "chrome/browser/autofill/autofill_credit_card_model_mac.h" -#import "chrome/browser/autofill/autofill_dialog_controller_mac.h" -#include "chrome/browser/autofill/credit_card.h" -#include "grit/generated_resources.h" - -// Private methods for the |AutoFillCreditCardViewController| class. -@interface AutoFillCreditCardViewController (PrivateMethods) -- (void)rebuildBillingAddressContents; -- (void)rebuildShippingAddressContents; -@end - -@implementation AutoFillCreditCardViewController - -@synthesize creditCardModel = creditCardModel_; -@synthesize billingAddressContents = billingAddressContents_; -@synthesize shippingAddressContents = shippingAddressContents_; - -- (id)initWithCreditCard:(const CreditCard&)creditCard - disclosure:(NSCellStateValue)disclosureState - controller:(AutoFillDialogController*)parentController { - self = [super initWithNibName:@"AutoFillCreditCardFormView" - bundle:mac_util::MainAppBundle() - disclosure:disclosureState]; - if (self) { - // Pull in the view for initialization. - [self view]; - - // Create the model. We use setter here for KVO. - [self setCreditCardModel:[[[AutoFillCreditCardModel alloc] - initWithCreditCard:creditCard] autorelease]]; - - // We keep track of our parent controller for model-update purposes. - parentController_ = parentController; - - // Setup initial state of popups. - [self onAddressesChanged:self]; - } - return self; -} - -- (void)dealloc { - [creditCardModel_ release]; - [billingAddressContents_ release]; - [shippingAddressContents_ release]; - [super dealloc]; -} - -- (void)awakeFromNib { - [super awakeFromNib]; - - // Turn menu autoenable off. We manually govern this. - [billingAddressPopup_ setAutoenablesItems:NO]; - [shippingAddressPopup_ setAutoenablesItems:NO]; -} - -- (IBAction)deleteCreditCard:(id)sender { - [parentController_ deleteCreditCard:self]; -} - -- (IBAction)onAddressesChanged:(id)sender { - [self rebuildBillingAddressContents]; - [self rebuildShippingAddressContents]; -} - -- (void)copyModelToCreditCard:(CreditCard*)creditCard { - [creditCardModel_ copyModelToCreditCard:creditCard]; - - // The model copies the shipping and billing addresses blindly. We need - // to clear the strings in the case that our special menus are in effect. - if ([billingAddressPopup_ indexOfSelectedItem] <= 0) - creditCard->set_billing_address(string16()); - if ([shippingAddressPopup_ indexOfSelectedItem] <= 0) - creditCard->set_shipping_address(string16()); -} - -// 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)rebuildBillingAddressContents { - NSString* menuString = l10n_util::GetNSString( - IDS_AUTOFILL_DIALOG_CHOOSE_EXISTING_ADDRESS); - - // Build the menu array and set it. - NSArray* addressStrings = [parentController_ addressLabels]; - NSArray* newArray = [[NSArray arrayWithObject:menuString] - arrayByAddingObjectsFromArray:addressStrings]; - [self setBillingAddressContents:newArray]; - - // If the addresses no longer contain our selected item, reset the selection. - if ([addressStrings - indexOfObject:[creditCardModel_ billingAddress]] == NSNotFound) { - [creditCardModel_ setBillingAddress:menuString]; - } - - // Disable first item in menu. "Choose existing address" is a non-item. - [[billingAddressPopup_ itemAtIndex:0] setEnabled:NO]; -} - -// Builds the |shippingAddressContents_| 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)rebuildShippingAddressContents { - NSString* menuString = l10n_util::GetNSString( - IDS_AUTOFILL_DIALOG_SAME_AS_BILLING); - - // Build the menu array and set it. - NSArray* addressStrings = [parentController_ addressLabels]; - NSArray* newArray = [[NSArray arrayWithObject:menuString] - arrayByAddingObjectsFromArray:addressStrings]; - [self setShippingAddressContents:newArray]; - - // If the addresses no longer contain our selected item, reset the selection. - if ([addressStrings - indexOfObject:[creditCardModel_ shippingAddress]] == NSNotFound) { - [creditCardModel_ setShippingAddress:menuString]; - } -} - -@end - |