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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/bundle_installer.h" | 9 #include "chrome/browser/extensions/bundle_installer.h" |
10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/gfx/image/image.h" | 24 #include "ui/gfx/image/image.h" |
25 | 25 |
26 using extensions::BundleInstaller; | 26 using extensions::BundleInstaller; |
27 | 27 |
28 // When an extension is installed on Mac with neither browser action nor | 28 // When an extension is installed on Mac with neither browser action nor |
29 // page action icons, show an infobar instead of a popup bubble. | 29 // page action icons, show an infobar instead of a popup bubble. |
30 static void ShowGenericExtensionInstalledInfoBar( | 30 static void ShowGenericExtensionInstalledInfoBar( |
31 const Extension* new_extension, | 31 const extensions::Extension* new_extension, |
32 const SkBitmap& icon, | 32 const SkBitmap& icon, |
33 Profile* profile) { | 33 Profile* profile) { |
34 Browser* browser = browser::FindLastActiveWithProfile(profile); | 34 Browser* browser = browser::FindLastActiveWithProfile(profile); |
35 if (!browser) | 35 if (!browser) |
36 return; | 36 return; |
37 | 37 |
38 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); | 38 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); |
39 if (!wrapper) | 39 if (!wrapper) |
40 return; | 40 return; |
41 | 41 |
42 string16 extension_name = UTF8ToUTF16(new_extension->name()); | 42 string16 extension_name = UTF8ToUTF16(new_extension->name()); |
43 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 43 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
44 string16 msg = l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, | 44 string16 msg = l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, |
45 extension_name) | 45 extension_name) |
46 + UTF8ToUTF16(" ") | 46 + UTF8ToUTF16(" ") |
47 + l10n_util::GetStringUTF16( | 47 + l10n_util::GetStringUTF16( |
48 IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); | 48 IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); |
49 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); | 49 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); |
50 InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( | 50 InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( |
51 infobar_helper, new gfx::Image(icon), msg, true); | 51 infobar_helper, new gfx::Image(icon), msg, true); |
52 infobar_helper->AddInfoBar(delegate); | 52 infobar_helper->AddInfoBar(delegate); |
53 } | 53 } |
54 | 54 |
55 namespace browser { | 55 namespace browser { |
56 | 56 |
57 void ShowExtensionInstalledBubble( | 57 void ShowExtensionInstalledBubble( |
58 const Extension* extension, | 58 const extensions::Extension* extension, |
59 Browser* browser, | 59 Browser* browser, |
60 const SkBitmap& icon, | 60 const SkBitmap& icon, |
61 Profile* profile) { | 61 Profile* profile) { |
62 if ((extension->browser_action()) || !extension->omnibox_keyword().empty() || | 62 if ((extension->browser_action()) || !extension->omnibox_keyword().empty() || |
63 (extension->page_action() && | 63 (extension->page_action() && |
64 !extension->page_action()->default_icon_path().empty())) { | 64 !extension->page_action()->default_icon_path().empty())) { |
65 // The controller is deallocated when the window is closed, so no need to | 65 // The controller is deallocated when the window is closed, so no need to |
66 // worry about it here. | 66 // worry about it here. |
67 [[ExtensionInstalledBubbleController alloc] | 67 [[ExtensionInstalledBubbleController alloc] |
68 initWithParentWindow:browser->window()->GetNativeHandle() | 68 initWithParentWindow:browser->window()->GetNativeHandle() |
(...skipping 15 matching lines...) Expand all Loading... |
84 const BundleInstaller* bundle, Browser* browser) { | 84 const BundleInstaller* bundle, Browser* browser) { |
85 // The controller is deallocated when the window is closed, so no need to | 85 // The controller is deallocated when the window is closed, so no need to |
86 // worry about it here. | 86 // worry about it here. |
87 [[ExtensionInstalledBubbleController alloc] | 87 [[ExtensionInstalledBubbleController alloc] |
88 initWithParentWindow:browser->window()->GetNativeHandle() | 88 initWithParentWindow:browser->window()->GetNativeHandle() |
89 extension:NULL | 89 extension:NULL |
90 bundle:bundle | 90 bundle:bundle |
91 browser:browser | 91 browser:browser |
92 icon:SkBitmap()]; | 92 icon:SkBitmap()]; |
93 } | 93 } |
OLD | NEW |