Index: chrome/browser/ui/cocoa/autofill/autofill_main_container.mm |
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm |
index 82908757fcfbda0ff93eea11c1c5c6df9957c92a..4a9492adde58493e26c9715af410858274f7d204 100644 |
--- a/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm |
+++ b/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm |
@@ -50,6 +50,15 @@ |
[self layoutButtons]; |
+ // Set up "Save in Chrome" checkbox. |
+ saveInChromeCheckbox_.reset([[NSButton alloc] initWithFrame:NSZeroRect]); |
+ [saveInChromeCheckbox_ setButtonType:NSSwitchButton]; |
+ [saveInChromeCheckbox_ setTitle: |
+ base::SysUTF16ToNSString(controller_->SaveLocallyText())]; |
+ [saveInChromeCheckbox_ setState:NSOnState]; |
+ [saveInChromeCheckbox_ sizeToFit]; |
+ [[self view] addSubview:saveInChromeCheckbox_]; |
+ |
detailsContainer_.reset( |
[[AutofillDetailsContainer alloc] initWithController:controller_]); |
NSSize frameSize = [[detailsContainer_ view] frame].size; |
@@ -122,6 +131,10 @@ |
buttonFrame.origin.y = currentY; |
[buttonContainer_ setFrameOrigin:buttonFrame.origin]; |
+ NSRect checkboxFrame = [saveInChromeCheckbox_ frame]; |
+ checkboxFrame.origin.y = NSMidY(buttonFrame) - NSHeight(checkboxFrame) / 2.0; |
+ [saveInChromeCheckbox_ setFrameOrigin:checkboxFrame.origin]; |
+ |
[detailsContainer_ performLayout]; |
NSRect containerFrame = [[detailsContainer_ view] frame]; |
containerFrame.origin.y = NSMaxY(buttonFrame); |
@@ -208,9 +221,14 @@ |
} |
- (void)modelChanged { |
+ [saveInChromeCheckbox_ setHidden:!controller_->ShouldOfferToSaveInChrome()]; |
[detailsContainer_ modelChanged]; |
} |
+- (BOOL)saveDetailsLocally { |
+ return [saveInChromeCheckbox_ state] == NSOnState; |
+} |
+ |
- (void)updateLegalDocuments { |
NSString* text = base::SysUTF16ToNSString(controller_->LegalDocumentsText()); |
@@ -254,3 +272,12 @@ |
} |
@end |
+ |
+ |
+@implementation AutofillMainContainer (Testing) |
+ |
+- (NSButton*)saveInChromeCheckboxForTesting { |
+ return saveInChromeCheckbox_.get(); |
+} |
+ |
+@end |