OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_dialog_controller.
h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.
h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 delegate_ = delegate; | 85 delegate_ = delegate; |
86 | 86 |
87 title_.reset( | 87 title_.reset( |
88 [l10n_util::GetNSStringF(ExtensionInstallUI::kHeadingIds[type], | 88 [l10n_util::GetNSStringF(ExtensionInstallUI::kHeadingIds[type], |
89 UTF8ToUTF16(extension->name())) retain]); | 89 UTF8ToUTF16(extension->name())) retain]); |
90 subtitle_.reset( | 90 subtitle_.reset( |
91 [l10n_util::GetNSString(ExtensionInstallUI::kWarningIds[type]) | 91 [l10n_util::GetNSString(ExtensionInstallUI::kWarningIds[type]) |
92 retain]); | 92 retain]); |
93 button_.reset([l10n_util::GetNSString(ExtensionInstallUI::kButtonIds[type]) | 93 button_.reset([l10n_util::GetNSString(ExtensionInstallUI::kButtonIds[type]) |
94 retain]); | 94 retain]); |
| 95 int cancel_id = ExtensionInstallUI::kAbortButtonIds[type]; |
| 96 cancel_button_.reset([l10n_util::GetNSString( |
| 97 cancel_id > 0 ? cancel_id : IDS_CANCEL) retain]); |
95 | 98 |
96 // We display the warnings as a simple text string, separated by newlines. | 99 // We display the warnings as a simple text string, separated by newlines. |
97 if (!warnings.empty()) { | 100 if (!warnings.empty()) { |
98 string16 joined_warnings; | 101 string16 joined_warnings; |
99 for (size_t i = 0; i < warnings.size(); ++i) { | 102 for (size_t i = 0; i < warnings.size(); ++i) { |
100 if (i > 0) | 103 if (i > 0) |
101 joined_warnings += UTF8ToUTF16("\n\n"); | 104 joined_warnings += UTF8ToUTF16("\n\n"); |
102 | 105 |
103 joined_warnings += warnings[i]; | 106 joined_warnings += warnings[i]; |
104 } | 107 } |
(...skipping 20 matching lines...) Expand all Loading... |
125 | 128 |
126 - (IBAction)ok:(id)sender { | 129 - (IBAction)ok:(id)sender { |
127 delegate_->InstallUIProceed(); | 130 delegate_->InstallUIProceed(); |
128 [NSApp endSheet:[self window]]; | 131 [NSApp endSheet:[self window]]; |
129 } | 132 } |
130 | 133 |
131 - (void)awakeFromNib { | 134 - (void)awakeFromNib { |
132 [titleField_ setStringValue:title_.get()]; | 135 [titleField_ setStringValue:title_.get()]; |
133 [subtitleField_ setStringValue:subtitle_.get()]; | 136 [subtitleField_ setStringValue:subtitle_.get()]; |
134 [okButton_ setTitle:button_.get()]; | 137 [okButton_ setTitle:button_.get()]; |
| 138 [cancelButton_ setTitle:cancel_button_.get()]; |
135 | 139 |
136 NSImage* image = gfx::SkBitmapToNSImage(icon_); | 140 NSImage* image = gfx::SkBitmapToNSImage(icon_); |
137 [iconView_ setImage:image]; | 141 [iconView_ setImage:image]; |
138 | 142 |
139 // Reisze |titleField_| to fit title | 143 // Reisze |titleField_| to fit title |
140 CGFloat originalTitleWidth = [titleField_ frame].size.width; | 144 CGFloat originalTitleWidth = [titleField_ frame].size.width; |
141 [titleField_ sizeToFit]; | 145 [titleField_ sizeToFit]; |
142 CGFloat newTitleWidth = [titleField_ frame].size.width; | 146 CGFloat newTitleWidth = [titleField_ frame].size.width; |
143 if (newTitleWidth > originalTitleWidth) { | 147 if (newTitleWidth > originalTitleWidth) { |
144 NSRect frame = [[self window] frame]; | 148 NSRect frame = [[self window] frame]; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 initWithParentWindow:native_window | 232 initWithParentWindow:native_window |
229 profile:profile | 233 profile:profile |
230 extension:extension | 234 extension:extension |
231 delegate:delegate | 235 delegate:delegate |
232 icon:icon | 236 icon:icon |
233 warnings:warnings | 237 warnings:warnings |
234 type:type]; | 238 type:type]; |
235 | 239 |
236 [controller runAsModalSheet]; | 240 [controller runAsModalSheet]; |
237 } | 241 } |
OLD | NEW |