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/tab_contents/confirm_infobar_delegate.h" | 10 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
10 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" | 11 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_dialogs.h" | 13 #include "chrome/browser/ui/browser_dialogs.h" |
13 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
15 #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" |
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
17 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
18 #include "chrome/common/extensions/extension_action.h" | 19 #include "chrome/common/extensions/extension_action.h" |
(...skipping 17 matching lines...) Expand all Loading... |
36 | 37 |
37 string16 extension_name = UTF8ToUTF16(new_extension->name()); | 38 string16 extension_name = UTF8ToUTF16(new_extension->name()); |
38 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 39 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
39 string16 msg = | 40 string16 msg = |
40 l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, | 41 l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, |
41 extension_name) + | 42 extension_name) + |
42 UTF8ToUTF16(" ") + | 43 UTF8ToUTF16(" ") + |
43 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); | 44 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); |
44 InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( | 45 InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( |
45 wrapper->tab_contents(), new gfx::Image(new SkBitmap(icon)), msg, true); | 46 wrapper->tab_contents(), new gfx::Image(new SkBitmap(icon)), msg, true); |
46 wrapper->AddInfoBar(delegate); | 47 wrapper->infobar_tab_helper()->AddInfoBar(delegate); |
47 } | 48 } |
48 | 49 |
49 namespace browser { | 50 namespace browser { |
50 | 51 |
51 void ShowExtensionInstalledBubble( | 52 void ShowExtensionInstalledBubble( |
52 const Extension* extension, | 53 const Extension* extension, |
53 Browser* browser, | 54 Browser* browser, |
54 const SkBitmap& icon, | 55 const SkBitmap& icon, |
55 Profile* profile) { | 56 Profile* profile) { |
56 if ((extension->browser_action()) || !extension->omnibox_keyword().empty() || | 57 if ((extension->browser_action()) || !extension->omnibox_keyword().empty() || |
57 (extension->page_action() && | 58 (extension->page_action() && |
58 !extension->page_action()->default_icon_path().empty())) { | 59 !extension->page_action()->default_icon_path().empty())) { |
59 // The controller is deallocated when the window is closed, so no need to | 60 // The controller is deallocated when the window is closed, so no need to |
60 // worry about it here. | 61 // worry about it here. |
61 [[ExtensionInstalledBubbleController alloc] | 62 [[ExtensionInstalledBubbleController alloc] |
62 initWithParentWindow:browser->window()->GetNativeHandle() | 63 initWithParentWindow:browser->window()->GetNativeHandle() |
63 extension:extension | 64 extension:extension |
64 browser:browser | 65 browser:browser |
65 icon:icon]; | 66 icon:icon]; |
66 } else { | 67 } else { |
67 // If the extension is of type GENERIC, meaning it doesn't have a UI | 68 // If the extension is of type GENERIC, meaning it doesn't have a UI |
68 // surface to display for this window, launch infobar instead of popup | 69 // surface to display for this window, launch infobar instead of popup |
69 // bubble, because we have no guaranteed wrench menu button to point to. | 70 // bubble, because we have no guaranteed wrench menu button to point to. |
70 ShowGenericExtensionInstalledInfoBar(extension, icon, profile); | 71 ShowGenericExtensionInstalledInfoBar(extension, icon, profile); |
71 } | 72 } |
72 } | 73 } |
73 | 74 |
74 } // namespace browser | 75 } // namespace browser |
OLD | NEW |