OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "chrome/browser/autofill/autofill_address_sheet_controller_mac.h" |
| 6 |
| 7 #include "app/l10n_util.h" |
| 8 #include "base/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" |
| 10 #import "chrome/browser/autofill/autofill_address_model_mac.h" |
| 11 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h" |
| 12 #include "chrome/browser/autofill/autofill_profile.h" |
| 13 #include "grit/generated_resources.h" |
| 14 |
| 15 @implementation AutoFillAddressSheetController |
| 16 |
| 17 @synthesize addressModel = addressModel_; |
| 18 |
| 19 - (id)initWithProfile:(const AutoFillProfile&)profile |
| 20 mode:(AutoFillAddressMode)mode { |
| 21 NSString* nibPath = [mac_util::MainAppBundle() |
| 22 pathForResource:@"AutoFillAddressSheet" |
| 23 ofType:@"nib"]; |
| 24 self = [super initWithWindowNibPath:nibPath owner:self]; |
| 25 if (self) { |
| 26 // Create the model. |
| 27 [self setAddressModel:[[[AutoFillAddressModel alloc] |
| 28 initWithProfile:profile] autorelease]]; |
| 29 |
| 30 mode_ = mode; |
| 31 } |
| 32 return self; |
| 33 } |
| 34 |
| 35 - (void)dealloc { |
| 36 [addressModel_ release]; |
| 37 [super dealloc]; |
| 38 } |
| 39 |
| 40 - (void)awakeFromNib { |
| 41 NSString* caption; |
| 42 if (mode_ == kAutoFillAddressAddMode) |
| 43 caption = l10n_util::GetNSString(IDS_AUTOFILL_ADD_ADDRESS_CAPTION); |
| 44 else if (mode_ == kAutoFillAddressEditMode) |
| 45 caption = l10n_util::GetNSString(IDS_AUTOFILL_EDIT_ADDRESS_CAPTION); |
| 46 else |
| 47 NOTREACHED(); |
| 48 [caption_ setStringValue:caption]; |
| 49 } |
| 50 |
| 51 - (IBAction)save:(id)sender { |
| 52 // Call |makeFirstResponder:| to commit pending text field edits. |
| 53 [[self window] makeFirstResponder:[self window]]; |
| 54 |
| 55 [NSApp endSheet:[self window] returnCode:1]; |
| 56 } |
| 57 |
| 58 - (IBAction)cancel:(id)sender { |
| 59 [NSApp endSheet:[self window] returnCode:0]; |
| 60 } |
| 61 |
| 62 - (void)copyModelToProfile:(AutoFillProfile*)profile { |
| 63 [addressModel_ copyModelToProfile:profile]; |
| 64 } |
| 65 |
| 66 @end |
OLD | NEW |