Index: chrome/browser/autofill/autofill_address_sheet_controller_mac.mm |
diff --git a/chrome/browser/autofill/autofill_address_sheet_controller_mac.mm b/chrome/browser/autofill/autofill_address_sheet_controller_mac.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1a6305dcdf28edfee96f591977c5053fda162567 |
--- /dev/null |
+++ b/chrome/browser/autofill/autofill_address_sheet_controller_mac.mm |
@@ -0,0 +1,66 @@ |
+// 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_address_sheet_controller_mac.h" |
+ |
+#include "app/l10n_util.h" |
+#include "base/mac_util.h" |
+#include "base/sys_string_conversions.h" |
+#import "chrome/browser/autofill/autofill_address_model_mac.h" |
+#import "chrome/browser/autofill/autofill_dialog_controller_mac.h" |
+#include "chrome/browser/autofill/autofill_profile.h" |
+#include "grit/generated_resources.h" |
+ |
+@implementation AutoFillAddressSheetController |
+ |
+@synthesize addressModel = addressModel_; |
+ |
+- (id)initWithProfile:(const AutoFillProfile&)profile |
+ mode:(AutoFillAddressMode)mode { |
+ NSString* nibPath = [mac_util::MainAppBundle() |
+ pathForResource:@"AutoFillAddressSheet" |
+ ofType:@"nib"]; |
+ self = [super initWithWindowNibPath:nibPath owner:self]; |
+ if (self) { |
+ // Create the model. |
+ [self setAddressModel:[[[AutoFillAddressModel alloc] |
+ initWithProfile:profile] autorelease]]; |
+ |
+ mode_ = mode; |
+ } |
+ return self; |
+} |
+ |
+- (void)dealloc { |
+ [addressModel_ release]; |
+ [super dealloc]; |
+} |
+ |
+- (void)awakeFromNib { |
+ NSString* caption; |
+ if (mode_ == kAutoFillAddressAddMode) |
+ caption = l10n_util::GetNSString(IDS_AUTOFILL_ADD_ADDRESS_CAPTION); |
+ else if (mode_ == kAutoFillAddressEditMode) |
+ caption = l10n_util::GetNSString(IDS_AUTOFILL_EDIT_ADDRESS_CAPTION); |
+ else |
+ NOTREACHED(); |
+ [caption_ setStringValue:caption]; |
+} |
+ |
+- (IBAction)save:(id)sender { |
+ // Call |makeFirstResponder:| to commit pending text field edits. |
+ [[self window] makeFirstResponder:[self window]]; |
+ |
+ [NSApp endSheet:[self window] returnCode:1]; |
+} |
+ |
+- (IBAction)cancel:(id)sender { |
+ [NSApp endSheet:[self window] returnCode:0]; |
+} |
+ |
+- (void)copyModelToProfile:(AutoFillProfile*)profile { |
+ [addressModel_ copyModelToProfile:profile]; |
+} |
+ |
+@end |