Chromium Code Reviews| 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 // To make |cancelButton_| right-aligned in the absence of |okButton_|, | |
| 239 // update |cancelButton_|'s rect with that of |okButton_|. | |
| 240 [cancelButton_ setFrame:okButtonRect]; | |
|
sail
2013/02/13 23:56:37
I don't think this will work. For example, if the
Joe Thomas
2013/02/14 02:41:59
Done.
| |
| 226 } | 241 } |
| 227 buttonDelta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:cancelButton_]; | 242 buttonDelta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:cancelButton_]; |
| 228 if (buttonDelta.width) { | 243 if (buttonDelta.width) { |
| 229 [cancelButton_ setFrame:NSOffsetRect([cancelButton_ frame], | 244 [cancelButton_ setFrame:NSOffsetRect([cancelButton_ frame], |
| 230 -buttonDelta.width, 0)]; | 245 -buttonDelta.width, 0)]; |
| 231 } | 246 } |
| 232 | 247 |
| 233 if ([self isBundleInstall]) { | 248 if ([self isBundleInstall]) { |
| 234 // We display the list of extension names as a simple text string, seperated | 249 // We display the list of extension names as a simple text string, seperated |
| 235 // by newlines. | 250 // by newlines. |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 return warnings; | 512 return warnings; |
| 498 } | 513 } |
| 499 | 514 |
| 500 - (void)updateViewFrame:(NSRect)frame { | 515 - (void)updateViewFrame:(NSRect)frame { |
| 501 NSWindow* window = [[self view] window]; | 516 NSWindow* window = [[self view] window]; |
| 502 [window setFrame:[window frameRectForContentRect:frame] display:YES]; | 517 [window setFrame:[window frameRectForContentRect:frame] display:YES]; |
| 503 [[self view] setFrame:frame]; | 518 [[self view] setFrame:frame]; |
| 504 } | 519 } |
| 505 | 520 |
| 506 @end | 521 @end |
| OLD | NEW |