OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 [view setSubviews:@[buttonContainer_]]; | 48 [view setSubviews:@[buttonContainer_]]; |
49 [self setView:view]; | 49 [self setView:view]; |
50 | 50 |
51 [self layoutButtons]; | 51 [self layoutButtons]; |
52 | 52 |
53 // Set up "Save in Chrome" checkbox. | 53 // Set up "Save in Chrome" checkbox. |
54 saveInChromeCheckbox_.reset([[NSButton alloc] initWithFrame:NSZeroRect]); | 54 saveInChromeCheckbox_.reset([[NSButton alloc] initWithFrame:NSZeroRect]); |
55 [saveInChromeCheckbox_ setButtonType:NSSwitchButton]; | 55 [saveInChromeCheckbox_ setButtonType:NSSwitchButton]; |
56 [saveInChromeCheckbox_ setTitle: | 56 [saveInChromeCheckbox_ setTitle: |
57 base::SysUTF16ToNSString(delegate_->SaveLocallyText())]; | 57 base::SysUTF16ToNSString(delegate_->SaveLocallyText())]; |
58 [saveInChromeCheckbox_ setState: | 58 [saveInChromeCheckbox_ setState:NSOnState]; |
59 (delegate_->ShouldSaveInChrome() ? NSOnState : NSOffState)]; | |
60 [saveInChromeCheckbox_ sizeToFit]; | 59 [saveInChromeCheckbox_ sizeToFit]; |
61 [[self view] addSubview:saveInChromeCheckbox_]; | 60 [[self view] addSubview:saveInChromeCheckbox_]; |
62 | 61 |
63 detailsContainer_.reset( | 62 detailsContainer_.reset( |
64 [[AutofillDetailsContainer alloc] initWithDelegate:delegate_]); | 63 [[AutofillDetailsContainer alloc] initWithDelegate:delegate_]); |
65 NSSize frameSize = [[detailsContainer_ view] frame].size; | 64 NSSize frameSize = [[detailsContainer_ view] frame].size; |
66 [[detailsContainer_ view] setFrameOrigin: | 65 [[detailsContainer_ view] setFrameOrigin: |
67 NSMakePoint(0, NSHeight([buttonContainer_ frame]))]; | 66 NSMakePoint(0, NSHeight([buttonContainer_ frame]))]; |
68 frameSize.height += NSHeight([buttonContainer_ frame]); | 67 frameSize.height += NSHeight([buttonContainer_ frame]); |
69 [[self view] setFrameSize:frameSize]; | 68 [[self view] setFrameSize:frameSize]; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 legalDocumentsSizeDirty_ = NO; | 224 legalDocumentsSizeDirty_ = NO; |
226 legalDocumentsSize_ = newFrame.size; | 225 legalDocumentsSize_ = newFrame.size; |
227 return legalDocumentsSize_; | 226 return legalDocumentsSize_; |
228 } | 227 } |
229 | 228 |
230 - (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section { | 229 - (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section { |
231 return [detailsContainer_ sectionForId:section]; | 230 return [detailsContainer_ sectionForId:section]; |
232 } | 231 } |
233 | 232 |
234 - (void)modelChanged { | 233 - (void)modelChanged { |
235 [self updateSaveInChrome]; | 234 [saveInChromeCheckbox_ setHidden:!delegate_->ShouldOfferToSaveInChrome()]; |
236 [detailsContainer_ modelChanged]; | 235 [detailsContainer_ modelChanged]; |
237 } | 236 } |
238 | 237 |
239 - (BOOL)saveDetailsLocally { | 238 - (BOOL)saveDetailsLocally { |
240 return [saveInChromeCheckbox_ state] == NSOnState; | 239 return [saveInChromeCheckbox_ state] == NSOnState; |
241 } | 240 } |
242 | 241 |
243 - (void)updateLegalDocuments { | 242 - (void)updateLegalDocuments { |
244 NSString* text = base::SysUTF16ToNSString(delegate_->LegalDocumentsText()); | 243 NSString* text = base::SysUTF16ToNSString(delegate_->LegalDocumentsText()); |
245 | 244 |
(...skipping 29 matching lines...) Expand all Loading... |
275 } | 274 } |
276 | 275 |
277 - (void)setAnchorView:(NSView*)anchorView { | 276 - (void)setAnchorView:(NSView*)anchorView { |
278 [notificationContainer_ setAnchorView:anchorView]; | 277 [notificationContainer_ setAnchorView:anchorView]; |
279 } | 278 } |
280 | 279 |
281 - (BOOL)validate { | 280 - (BOOL)validate { |
282 return [detailsContainer_ validate]; | 281 return [detailsContainer_ validate]; |
283 } | 282 } |
284 | 283 |
285 - (void)updateSaveInChrome { | |
286 [saveInChromeCheckbox_ setHidden:!delegate_->ShouldOfferToSaveInChrome()]; | |
287 } | |
288 | |
289 @end | 284 @end |
290 | 285 |
291 | 286 |
292 @implementation AutofillMainContainer (Testing) | 287 @implementation AutofillMainContainer (Testing) |
293 | 288 |
294 - (NSButton*)saveInChromeCheckboxForTesting { | 289 - (NSButton*)saveInChromeCheckboxForTesting { |
295 return saveInChromeCheckbox_.get(); | 290 return saveInChromeCheckbox_.get(); |
296 } | 291 } |
297 | 292 |
298 @end | 293 @end |
OLD | NEW |