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:NSOnState]; | 58 [saveInChromeCheckbox_ setState: |
59 (delegate_->ShouldSaveInChrome() ? NSOnState : NSOffState)]; | |
Avi (use Gerrit)
2013/10/01 02:06:09
Indentation is still wrong. That's three spaces, n
groby-ooo-7-16
2013/10/01 02:12:02
Done.
| |
59 [saveInChromeCheckbox_ sizeToFit]; | 60 [saveInChromeCheckbox_ sizeToFit]; |
60 [[self view] addSubview:saveInChromeCheckbox_]; | 61 [[self view] addSubview:saveInChromeCheckbox_]; |
61 | 62 |
62 detailsContainer_.reset( | 63 detailsContainer_.reset( |
63 [[AutofillDetailsContainer alloc] initWithDelegate:delegate_]); | 64 [[AutofillDetailsContainer alloc] initWithDelegate:delegate_]); |
64 NSSize frameSize = [[detailsContainer_ view] frame].size; | 65 NSSize frameSize = [[detailsContainer_ view] frame].size; |
65 [[detailsContainer_ view] setFrameOrigin: | 66 [[detailsContainer_ view] setFrameOrigin: |
66 NSMakePoint(0, NSHeight([buttonContainer_ frame]))]; | 67 NSMakePoint(0, NSHeight([buttonContainer_ frame]))]; |
67 frameSize.height += NSHeight([buttonContainer_ frame]); | 68 frameSize.height += NSHeight([buttonContainer_ frame]); |
68 [[self view] setFrameSize:frameSize]; | 69 [[self view] setFrameSize:frameSize]; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 legalDocumentsSizeDirty_ = NO; | 225 legalDocumentsSizeDirty_ = NO; |
225 legalDocumentsSize_ = newFrame.size; | 226 legalDocumentsSize_ = newFrame.size; |
226 return legalDocumentsSize_; | 227 return legalDocumentsSize_; |
227 } | 228 } |
228 | 229 |
229 - (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section { | 230 - (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section { |
230 return [detailsContainer_ sectionForId:section]; | 231 return [detailsContainer_ sectionForId:section]; |
231 } | 232 } |
232 | 233 |
233 - (void)modelChanged { | 234 - (void)modelChanged { |
234 [saveInChromeCheckbox_ setHidden:!delegate_->ShouldOfferToSaveInChrome()]; | 235 [self updateSaveInChrome]; |
235 [detailsContainer_ modelChanged]; | 236 [detailsContainer_ modelChanged]; |
236 } | 237 } |
237 | 238 |
238 - (BOOL)saveDetailsLocally { | 239 - (BOOL)saveDetailsLocally { |
239 return [saveInChromeCheckbox_ state] == NSOnState; | 240 return [saveInChromeCheckbox_ state] == NSOnState; |
240 } | 241 } |
241 | 242 |
242 - (void)updateLegalDocuments { | 243 - (void)updateLegalDocuments { |
243 NSString* text = base::SysUTF16ToNSString(delegate_->LegalDocumentsText()); | 244 NSString* text = base::SysUTF16ToNSString(delegate_->LegalDocumentsText()); |
244 | 245 |
(...skipping 29 matching lines...) Expand all Loading... | |
274 } | 275 } |
275 | 276 |
276 - (void)setAnchorView:(NSView*)anchorView { | 277 - (void)setAnchorView:(NSView*)anchorView { |
277 [notificationContainer_ setAnchorView:anchorView]; | 278 [notificationContainer_ setAnchorView:anchorView]; |
278 } | 279 } |
279 | 280 |
280 - (BOOL)validate { | 281 - (BOOL)validate { |
281 return [detailsContainer_ validate]; | 282 return [detailsContainer_ validate]; |
282 } | 283 } |
283 | 284 |
285 - (void)updateSaveInChrome { | |
286 [saveInChromeCheckbox_ setHidden:!delegate_->ShouldOfferToSaveInChrome()]; | |
287 } | |
288 | |
284 @end | 289 @end |
285 | 290 |
286 | 291 |
287 @implementation AutofillMainContainer (Testing) | 292 @implementation AutofillMainContainer (Testing) |
288 | 293 |
289 - (NSButton*)saveInChromeCheckboxForTesting { | 294 - (NSButton*)saveInChromeCheckboxForTesting { |
290 return saveInChromeCheckbox_.get(); | 295 return saveInChromeCheckbox_.get(); |
291 } | 296 } |
292 | 297 |
293 @end | 298 @end |
OLD | NEW |