Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_main_container.mm

Issue 23546007: [rAC, OSX] Namespaced constants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Once more merge to HEAD Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return YES; 97 return YES;
98 } 98 }
99 99
100 - (NSSize)preferredSize { 100 - (NSSize)preferredSize {
101 // Overall width is determined by |detailsContainer_|. 101 // Overall width is determined by |detailsContainer_|.
102 NSSize buttonSize = [buttonContainer_ frame].size; 102 NSSize buttonSize = [buttonContainer_ frame].size;
103 NSSize detailsSize = [detailsContainer_ preferredSize]; 103 NSSize detailsSize = [detailsContainer_ preferredSize];
104 104
105 NSSize size = NSMakeSize(std::max(buttonSize.width, detailsSize.width), 105 NSSize size = NSMakeSize(std::max(buttonSize.width, detailsSize.width),
106 buttonSize.height + detailsSize.height); 106 buttonSize.height + detailsSize.height);
107 size.height += kDetailBottomPadding; 107 size.height += autofill::kDetailBottomPadding;
108 108
109 if (![legalDocumentsView_ isHidden]) { 109 if (![legalDocumentsView_ isHidden]) {
110 NSSize legalDocumentSize = 110 NSSize legalDocumentSize =
111 [self preferredLegalDocumentSizeForWidth:detailsSize.width]; 111 [self preferredLegalDocumentSizeForWidth:detailsSize.width];
112 size.height += legalDocumentSize.height + kVerticalSpacing; 112 size.height += legalDocumentSize.height + autofill::kVerticalSpacing;
113 } 113 }
114 114
115 NSSize notificationSize = 115 NSSize notificationSize =
116 [notificationContainer_ preferredSizeForWidth:detailsSize.width]; 116 [notificationContainer_ preferredSizeForWidth:detailsSize.width];
117 size.height += notificationSize.height; 117 size.height += notificationSize.height;
118 return size; 118 return size;
119 } 119 }
120 120
121 - (void)performLayout { 121 - (void)performLayout {
122 NSRect bounds = [[self view] bounds]; 122 NSRect bounds = [[self view] bounds];
123 123
124 CGFloat currentY = 0.0; 124 CGFloat currentY = 0.0;
125 if (![legalDocumentsView_ isHidden]) { 125 if (![legalDocumentsView_ isHidden]) {
126 [legalDocumentsView_ setFrameSize: 126 [legalDocumentsView_ setFrameSize:
127 [self preferredLegalDocumentSizeForWidth:NSWidth(bounds)]]; 127 [self preferredLegalDocumentSizeForWidth:NSWidth(bounds)]];
128 currentY = NSMaxY([legalDocumentsView_ frame]) + kVerticalSpacing; 128 currentY = NSMaxY([legalDocumentsView_ frame]) +
129 autofill::kVerticalSpacing;
129 } 130 }
130 131
131 NSRect buttonFrame = [buttonContainer_ frame]; 132 NSRect buttonFrame = [buttonContainer_ frame];
132 buttonFrame.origin.y = currentY; 133 buttonFrame.origin.y = currentY;
133 [buttonContainer_ setFrameOrigin:buttonFrame.origin]; 134 [buttonContainer_ setFrameOrigin:buttonFrame.origin];
134 135
135 NSRect checkboxFrame = [saveInChromeCheckbox_ frame]; 136 NSRect checkboxFrame = [saveInChromeCheckbox_ frame];
136 checkboxFrame.origin.y = NSMidY(buttonFrame) - NSHeight(checkboxFrame) / 2.0; 137 checkboxFrame.origin.y = NSMidY(buttonFrame) - NSHeight(checkboxFrame) / 2.0;
137 [saveInChromeCheckbox_ setFrameOrigin:checkboxFrame.origin]; 138 [saveInChromeCheckbox_ setFrameOrigin:checkboxFrame.origin];
138 139
139 currentY = NSMaxY(buttonFrame) + kDetailBottomPadding; 140 currentY = NSMaxY(buttonFrame) + autofill::kDetailBottomPadding;
140 141
141 NSRect notificationFrame = NSZeroRect; 142 NSRect notificationFrame = NSZeroRect;
142 notificationFrame.size = [notificationContainer_ preferredSizeForWidth: 143 notificationFrame.size = [notificationContainer_ preferredSizeForWidth:
143 NSWidth(bounds)]; 144 NSWidth(bounds)];
144 145
145 // Buttons/checkbox/legal take up lower part of view, notifications the 146 // Buttons/checkbox/legal take up lower part of view, notifications the
146 // upper part. Adjust the detailsContainer to take up the remainder. 147 // upper part. Adjust the detailsContainer to take up the remainder.
147 CGFloat remainingHeight = 148 CGFloat remainingHeight =
148 NSHeight(bounds) - currentY - NSHeight(notificationFrame); 149 NSHeight(bounds) - currentY - NSHeight(notificationFrame);
149 NSRect containerFrame = 150 NSRect containerFrame =
150 NSMakeRect(0, currentY, NSWidth(bounds), remainingHeight); 151 NSMakeRect(0, currentY, NSWidth(bounds), remainingHeight);
151 [[detailsContainer_ view] setFrame:containerFrame]; 152 [[detailsContainer_ view] setFrame:containerFrame];
152 [detailsContainer_ performLayout]; 153 [detailsContainer_ performLayout];
153 154
154 notificationFrame.origin = 155 notificationFrame.origin =
155 NSMakePoint(0, NSMaxY(containerFrame) + kDetailTopPadding); 156 NSMakePoint(0, NSMaxY(containerFrame) + autofill::kDetailTopPadding);
156 [[notificationContainer_ view] setFrame:notificationFrame]; 157 [[notificationContainer_ view] setFrame:notificationFrame];
157 [notificationContainer_ performLayout]; 158 [notificationContainer_ performLayout];
158 } 159 }
159 160
160 - (void)buildWindowButtonsForFrame:(NSRect)frame { 161 - (void)buildWindowButtonsForFrame:(NSRect)frame {
161 if (buttonContainer_.get()) 162 if (buttonContainer_.get())
162 return; 163 return;
163 164
164 buttonContainer_.reset([[GTMWidthBasedTweaker alloc] initWithFrame: 165 buttonContainer_.reset([[GTMWidthBasedTweaker alloc] initWithFrame:
165 ui::kWindowSizeDeterminedLater]); 166 ui::kWindowSizeDeterminedLater]);
166 [buttonContainer_ 167 [buttonContainer_
167 setAutoresizingMask:(NSViewMinXMargin | NSViewMaxYMargin)]; 168 setAutoresizingMask:(NSViewMinXMargin | NSViewMaxYMargin)];
168 169
169 base::scoped_nsobject<NSButton> button( 170 base::scoped_nsobject<NSButton> button(
170 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); 171 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
171 [button setTitle:l10n_util::GetNSStringWithFixup(IDS_CANCEL)]; 172 [button setTitle:l10n_util::GetNSStringWithFixup(IDS_CANCEL)];
172 [button setKeyEquivalent:kKeyEquivalentEscape]; 173 [button setKeyEquivalent:kKeyEquivalentEscape];
173 [button setTarget:target_]; 174 [button setTarget:target_];
174 [button setAction:@selector(cancel:)]; 175 [button setAction:@selector(cancel:)];
175 [button sizeToFit]; 176 [button sizeToFit];
176 [buttonContainer_ addSubview:button]; 177 [buttonContainer_ addSubview:button];
177 178
178 CGFloat nextX = NSMaxX([button frame]) + kButtonGap; 179 CGFloat nextX = NSMaxX([button frame]) + autofill::kButtonGap;
179 button.reset([[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); 180 button.reset([[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
180 [button setFrameOrigin:NSMakePoint(nextX, 0)]; 181 [button setFrameOrigin:NSMakePoint(nextX, 0)];
181 [button setTitle:l10n_util::GetNSStringWithFixup( 182 [button setTitle:l10n_util::GetNSStringWithFixup(
182 IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON)]; 183 IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON)];
183 [button setKeyEquivalent:kKeyEquivalentReturn]; 184 [button setKeyEquivalent:kKeyEquivalentReturn];
184 [button setTarget:target_]; 185 [button setTarget:target_];
185 [button setAction:@selector(accept:)]; 186 [button setAction:@selector(accept:)];
186 [button sizeToFit]; 187 [button sizeToFit];
187 [buttonContainer_ addSubview:button]; 188 [buttonContainer_ addSubview:button];
188 189
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 @end 284 @end
284 285
285 286
286 @implementation AutofillMainContainer (Testing) 287 @implementation AutofillMainContainer (Testing)
287 288
288 - (NSButton*)saveInChromeCheckboxForTesting { 289 - (NSButton*)saveInChromeCheckboxForTesting {
289 return saveInChromeCheckbox_.get(); 290 return saveInChromeCheckbox_.get();
290 } 291 }
291 292
292 @end 293 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698