OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_install_view_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 delegate_->InstallUIAbort(/*user_initiated=*/true); | 179 delegate_->InstallUIAbort(/*user_initiated=*/true); |
180 } | 180 } |
181 | 181 |
182 - (IBAction)ok:(id)sender { | 182 - (IBAction)ok:(id)sender { |
183 delegate_->InstallUIProceed(); | 183 delegate_->InstallUIProceed(); |
184 } | 184 } |
185 | 185 |
186 - (void)awakeFromNib { | 186 - (void)awakeFromNib { |
187 // Set control labels. | 187 // Set control labels. |
188 [titleField_ setStringValue:base::SysUTF16ToNSString(prompt_->GetHeading())]; | 188 [titleField_ setStringValue:base::SysUTF16ToNSString(prompt_->GetHeading())]; |
189 [okButton_ setTitle:base::SysUTF16ToNSString( | 189 NSRect okButtonRect; |
190 prompt_->GetAcceptButtonLabel())]; | 190 if (prompt_->HasAcceptButtonLabel()) { |
| 191 [okButton_ setTitle:base::SysUTF16ToNSString( |
| 192 prompt_->GetAcceptButtonLabel())]; |
| 193 } else { |
| 194 [okButton_ removeFromSuperview]; |
| 195 okButtonRect = [okButton_ frame]; |
| 196 okButton_ = nil; |
| 197 } |
191 [cancelButton_ setTitle:prompt_->HasAbortButtonLabel() ? | 198 [cancelButton_ setTitle:prompt_->HasAbortButtonLabel() ? |
192 base::SysUTF16ToNSString(prompt_->GetAbortButtonLabel()) : | 199 base::SysUTF16ToNSString(prompt_->GetAbortButtonLabel()) : |
193 l10n_util::GetNSString(IDS_CANCEL)]; | 200 l10n_util::GetNSString(IDS_CANCEL)]; |
194 if ([self isInlineInstall]) { | 201 if ([self isInlineInstall]) { |
195 prompt_->AppendRatingStars(AppendRatingStarsShim, self); | 202 prompt_->AppendRatingStars(AppendRatingStarsShim, self); |
196 [ratingCountField_ setStringValue:base::SysUTF16ToNSString( | 203 [ratingCountField_ setStringValue:base::SysUTF16ToNSString( |
197 prompt_->GetRatingCount())]; | 204 prompt_->GetRatingCount())]; |
198 [userCountField_ setStringValue:base::SysUTF16ToNSString( | 205 [userCountField_ setStringValue:base::SysUTF16ToNSString( |
199 prompt_->GetUserCount())]; | 206 prompt_->GetUserCount())]; |
200 [[storeLinkButton_ cell] setUnderlineOnHover:YES]; | 207 [[storeLinkButton_ cell] setUnderlineOnHover:YES]; |
(...skipping 10 matching lines...) Expand all Loading... |
211 // wrapping onto multiple lines. So we accumulate an offset by measuring how | 218 // wrapping onto multiple lines. So we accumulate an offset by measuring how |
212 // big each label wants to be, and comparing it to how big it actually is. | 219 // big each label wants to be, and comparing it to how big it actually is. |
213 // Then we shift each label down and resize by the appropriate amount, then | 220 // Then we shift each label down and resize by the appropriate amount, then |
214 // finally resize the window. | 221 // finally resize the window. |
215 CGFloat totalOffset = 0.0; | 222 CGFloat totalOffset = 0.0; |
216 | 223 |
217 OffsetControlVerticallyToFitContent(titleField_, &totalOffset); | 224 OffsetControlVerticallyToFitContent(titleField_, &totalOffset); |
218 | 225 |
219 // Resize |okButton_| and |cancelButton_| to fit the button labels, but keep | 226 // Resize |okButton_| and |cancelButton_| to fit the button labels, but keep |
220 // them right-aligned. | 227 // them right-aligned. |
221 NSSize buttonDelta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:okButton_]; | 228 NSSize buttonDelta; |
222 if (buttonDelta.width) { | 229 if (okButton_) { |
223 [okButton_ setFrame:NSOffsetRect([okButton_ frame], -buttonDelta.width, 0)]; | 230 buttonDelta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:okButton_]; |
224 [cancelButton_ setFrame:NSOffsetRect([cancelButton_ frame], | 231 if (buttonDelta.width) { |
225 -buttonDelta.width, 0)]; | 232 [okButton_ setFrame:NSOffsetRect([okButton_ frame], |
| 233 -buttonDelta.width, 0)]; |
| 234 [cancelButton_ setFrame:NSOffsetRect([cancelButton_ frame], |
| 235 -buttonDelta.width, 0)]; |
| 236 } |
| 237 } else { |
| 238 // Make |cancelButton_| right-aligned in the absence of |okButton_|. |
| 239 NSRect cancelButtonRect = [cancelButton_ frame]; |
| 240 cancelButtonRect.origin.x = |
| 241 NSMaxX(okButtonRect) - NSWidth(cancelButtonRect); |
| 242 [cancelButton_ setFrame:cancelButtonRect]; |
226 } | 243 } |
227 buttonDelta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:cancelButton_]; | 244 buttonDelta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:cancelButton_]; |
228 if (buttonDelta.width) { | 245 if (buttonDelta.width) { |
229 [cancelButton_ setFrame:NSOffsetRect([cancelButton_ frame], | 246 [cancelButton_ setFrame:NSOffsetRect([cancelButton_ frame], |
230 -buttonDelta.width, 0)]; | 247 -buttonDelta.width, 0)]; |
231 } | 248 } |
232 | 249 |
233 if ([self isBundleInstall]) { | 250 if ([self isBundleInstall]) { |
234 // We display the list of extension names as a simple text string, seperated | 251 // We display the list of extension names as a simple text string, seperated |
235 // by newlines. | 252 // by newlines. |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 return warnings; | 514 return warnings; |
498 } | 515 } |
499 | 516 |
500 - (void)updateViewFrame:(NSRect)frame { | 517 - (void)updateViewFrame:(NSRect)frame { |
501 NSWindow* window = [[self view] window]; | 518 NSWindow* window = [[self view] window]; |
502 [window setFrame:[window frameRectForContentRect:frame] display:YES]; | 519 [window setFrame:[window frameRectForContentRect:frame] display:YES]; |
503 [[self view] setFrame:frame]; | 520 [[self view] setFrame:frame]; |
504 } | 521 } |
505 | 522 |
506 @end | 523 @end |
OLD | NEW |