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_installed_bubble_controlle
r.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle
r.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_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" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
13 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 13 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
14 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 14 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
15 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | 15 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
16 #include "chrome/browser/ui/cocoa/hover_close_button.h" | 16 #include "chrome/browser/ui/cocoa/hover_close_button.h" |
17 #include "chrome/browser/ui/cocoa/info_bubble_view.h" | 17 #include "chrome/browser/ui/cocoa/info_bubble_view.h" |
18 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 18 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
19 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 19 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
21 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/extensions/extension_action.h" | 22 #include "chrome/common/extensions/extension_action.h" |
23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
26 #include "grit/chromium_strings.h" | |
27 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
28 #import "skia/ext/skia_utils_mac.h" | 27 #import "skia/ext/skia_utils_mac.h" |
29 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 28 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
30 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
31 | 30 |
32 using content::BrowserThread; | 31 using content::BrowserThread; |
33 | 32 |
34 // C++ class that receives EXTENSION_LOADED notifications and proxies them back | 33 // C++ class that receives EXTENSION_LOADED notifications and proxies them back |
35 // to |controller|. | 34 // to |controller|. |
36 class ExtensionLoadedNotificationObserver | 35 class ExtensionLoadedNotificationObserver |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // total of all message heights. | 297 // total of all message heights. |
299 - (int)calculateWindowHeight { | 298 - (int)calculateWindowHeight { |
300 // Adjust the window height to reflect the sum height of all messages | 299 // Adjust the window height to reflect the sum height of all messages |
301 // and vertical padding. | 300 // and vertical padding. |
302 int newWindowHeight = 2 * extension_installed_bubble::kOuterVerticalMargin; | 301 int newWindowHeight = 2 * extension_installed_bubble::kOuterVerticalMargin; |
303 | 302 |
304 // First part of extension installed message. | 303 // First part of extension installed message. |
305 string16 extension_name = UTF8ToUTF16(extension_->name().c_str()); | 304 string16 extension_name = UTF8ToUTF16(extension_->name().c_str()); |
306 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 305 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
307 [extensionInstalledMsg_ setStringValue:l10n_util::GetNSStringF( | 306 [extensionInstalledMsg_ setStringValue:l10n_util::GetNSStringF( |
308 IDS_EXTENSION_INSTALLED_HEADING, extension_name, | 307 IDS_EXTENSION_INSTALLED_HEADING, extension_name)]; |
309 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))]; | |
310 [GTMUILocalizerAndLayoutTweaker | 308 [GTMUILocalizerAndLayoutTweaker |
311 sizeToFitFixedWidthTextField:extensionInstalledMsg_]; | 309 sizeToFitFixedWidthTextField:extensionInstalledMsg_]; |
312 newWindowHeight += [extensionInstalledMsg_ frame].size.height + | 310 newWindowHeight += [extensionInstalledMsg_ frame].size.height + |
313 extension_installed_bubble::kInnerVerticalMargin; | 311 extension_installed_bubble::kInnerVerticalMargin; |
314 | 312 |
315 // If type is page action, include a special message about page actions. | 313 // If type is page action, include a special message about page actions. |
316 if (type_ == extension_installed_bubble::kPageAction) { | 314 if (type_ == extension_installed_bubble::kPageAction) { |
317 [extraInfoMsg_ setHidden:NO]; | 315 [extraInfoMsg_ setHidden:NO]; |
318 [[extraInfoMsg_ cell] | 316 [[extraInfoMsg_ cell] |
319 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; | 317 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 385 |
388 - (NSRect)getExtensionInstalledInfoMsgFrame { | 386 - (NSRect)getExtensionInstalledInfoMsgFrame { |
389 return [extensionInstalledInfoMsg_ frame]; | 387 return [extensionInstalledInfoMsg_ frame]; |
390 } | 388 } |
391 | 389 |
392 - (void)extensionUnloaded:(id)sender { | 390 - (void)extensionUnloaded:(id)sender { |
393 extension_ = NULL; | 391 extension_ = NULL; |
394 } | 392 } |
395 | 393 |
396 @end | 394 @end |
OLD | NEW |