Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_installed_bubble_bridge.mm

Issue 10872067: No more extension install infobars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
10 #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h"
11 #include "chrome/browser/extensions/bundle_installer.h" 7 #include "chrome/browser/extensions/bundle_installer.h"
12 #include "chrome/browser/infobars/infobar_tab_helper.h"
13 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_dialogs.h"
15 #include "chrome/browser/ui/browser_tabstrip.h"
16 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
17 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle r.h" 10 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle r.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents.h"
19 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_action.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
21 #include "grit/chromium_strings.h"
22 #include "grit/generated_resources.h"
23 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/gfx/image/image.h"
25 13
26 using extensions::BundleInstaller; 14 using extensions::BundleInstaller;
27 15
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.
30 static void ShowGenericExtensionInstalledInfoBar(
31 const extensions::Extension* new_extension,
32 Browser* browser,
33 const SkBitmap& icon) {
34 TabContents* tab_contents = chrome::GetActiveTabContents(browser);
35 if (!tab_contents)
36 return;
37
38 string16 extension_name = UTF8ToUTF16(new_extension->name());
39 base::i18n::AdjustStringForLocaleDirection(&extension_name);
40 string16 msg = l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING,
41 extension_name)
42 + UTF8ToUTF16(" ")
43 + l10n_util::GetStringUTF16(
44 IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC);
45 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
46 InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate(
47 infobar_helper, new gfx::Image(icon), msg, true);
48 infobar_helper->AddInfoBar(delegate);
49 }
50
51 namespace chrome { 16 namespace chrome {
52 17
53 void ShowExtensionInstalledBubble(const extensions::Extension* extension, 18 void ShowExtensionInstalledBubble(const extensions::Extension* extension,
54 Browser* browser, 19 Browser* browser,
55 const SkBitmap& icon) { 20 const SkBitmap& icon) {
56 if ((extension->browser_action()) || !extension->omnibox_keyword().empty() || 21 // The controller is deallocated when the window is closed, so no need to
57 (extension->page_action() && 22 // worry about it here.
58 !extension->page_action()->default_icon_path().empty())) { 23 [[ExtensionInstalledBubbleController alloc]
59 // The controller is deallocated when the window is closed, so no need to 24 initWithParentWindow:browser->window()->GetNativeWindow()
60 // worry about it here. 25 extension:extension
61 [[ExtensionInstalledBubbleController alloc] 26 bundle:NULL
62 initWithParentWindow:browser->window()->GetNativeWindow() 27 browser:browser
63 extension:extension 28 icon:icon];
64 bundle:NULL
65 browser:browser
66 icon:icon];
67 } else {
68 // If the extension is of type GENERIC, meaning it doesn't have a UI
69 // surface to display for this window, launch infobar instead of popup
70 // bubble, because we have no guaranteed wrench menu button to point to.
71 ShowGenericExtensionInstalledInfoBar(extension, browser, icon);
72 }
73 } 29 }
74 30
75 } // namespace chrome 31 } // namespace chrome
76 32
77 void extensions::BundleInstaller::ShowInstalledBubble( 33 void extensions::BundleInstaller::ShowInstalledBubble(
78 const BundleInstaller* bundle, Browser* browser) { 34 const BundleInstaller* bundle, Browser* browser) {
79 // The controller is deallocated when the window is closed, so no need to 35 // The controller is deallocated when the window is closed, so no need to
80 // worry about it here. 36 // worry about it here.
81 [[ExtensionInstalledBubbleController alloc] 37 [[ExtensionInstalledBubbleController alloc]
82 initWithParentWindow:browser->window()->GetNativeWindow() 38 initWithParentWindow:browser->window()->GetNativeWindow()
83 extension:NULL 39 extension:NULL
84 bundle:bundle 40 bundle:bundle
85 browser:browser 41 browser:browser
86 icon:SkBitmap()]; 42 icon:SkBitmap()];
87 } 43 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698