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 <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/infobars/infobar_tab_helper.h" | 9 #include "chrome/browser/infobars/infobar_tab_helper.h" |
10 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 10 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
11 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" | 11 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_dialogs.h" | 13 #include "chrome/browser/ui/browser_dialogs.h" |
14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
16 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle
r.h" | 16 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle
r.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/common/extensions/extension_action.h" | 19 #include "chrome/common/extensions/extension_action.h" |
| 20 #include "grit/chromium_strings.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
23 | 24 |
24 // When an extension is installed on Mac with neither browser action nor | 25 // When an extension is installed on Mac with neither browser action nor |
25 // page action icons, show an infobar instead of a popup bubble. | 26 // page action icons, show an infobar instead of a popup bubble. |
26 static void ShowGenericExtensionInstalledInfoBar( | 27 static void ShowGenericExtensionInstalledInfoBar( |
27 const Extension* new_extension, | 28 const Extension* new_extension, |
28 const SkBitmap& icon, | 29 const SkBitmap& icon, |
29 Profile* profile) { | 30 Profile* profile) { |
30 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); | 31 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
31 if (!browser) | 32 if (!browser) |
32 return; | 33 return; |
33 | 34 |
34 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); | 35 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); |
35 if (!wrapper) | 36 if (!wrapper) |
36 return; | 37 return; |
37 | 38 |
38 string16 extension_name = UTF8ToUTF16(new_extension->name()); | 39 string16 extension_name = UTF8ToUTF16(new_extension->name()); |
39 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 40 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
40 string16 msg = | 41 string16 msg = l10n_util::GetStringFUTF16( |
41 l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, | 42 IDS_EXTENSION_INSTALLED_HEADING, |
42 extension_name) + | 43 extension_name, |
| 44 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)) + |
43 UTF8ToUTF16(" ") + | 45 UTF8ToUTF16(" ") + |
44 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); | 46 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); |
45 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); | 47 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); |
46 InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( | 48 InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( |
47 infobar_helper, new gfx::Image(new SkBitmap(icon)), msg, true); | 49 infobar_helper, new gfx::Image(new SkBitmap(icon)), msg, true); |
48 infobar_helper->AddInfoBar(delegate); | 50 infobar_helper->AddInfoBar(delegate); |
49 } | 51 } |
50 | 52 |
51 namespace browser { | 53 namespace browser { |
52 | 54 |
(...skipping 14 matching lines...) Expand all Loading... |
67 icon:icon]; | 69 icon:icon]; |
68 } else { | 70 } else { |
69 // If the extension is of type GENERIC, meaning it doesn't have a UI | 71 // If the extension is of type GENERIC, meaning it doesn't have a UI |
70 // surface to display for this window, launch infobar instead of popup | 72 // surface to display for this window, launch infobar instead of popup |
71 // bubble, because we have no guaranteed wrench menu button to point to. | 73 // bubble, because we have no guaranteed wrench menu button to point to. |
72 ShowGenericExtensionInstalledInfoBar(extension, icon, profile); | 74 ShowGenericExtensionInstalledInfoBar(extension, icon, profile); |
73 } | 75 } |
74 } | 76 } |
75 | 77 |
76 } // namespace browser | 78 } // namespace browser |
OLD | NEW |