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 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_CONTROLLER
_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_CONTROLLER
_H_ |
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_CONTROLLER
_H_ | 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_CONTROLLER
_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
11 #import "base/mac/cocoa_protocols.h" | 11 #import "base/mac/cocoa_protocols.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
15 | 15 |
16 class Browser; | 16 class Browser; |
17 class Extension; | 17 class Extension; |
18 class ExtensionLoadedNotificationObserver; | 18 class ExtensionLoadedNotificationObserver; |
19 @class HoverCloseButton; | 19 @class HoverCloseButton; |
20 @class InfoBubbleView; | 20 @class InfoBubbleView; |
21 | 21 |
| 22 namespace extensions { |
| 23 class BundleInstaller; |
| 24 } |
| 25 |
22 namespace extension_installed_bubble { | 26 namespace extension_installed_bubble { |
23 | 27 |
24 // Maximum height or width of extension's icon (corresponds to Windows & GTK). | 28 // Maximum height or width of extension's icon (corresponds to Windows & GTK). |
25 const int kIconSize = 43; | 29 const int kIconSize = 43; |
26 | 30 |
27 // Outer vertical margin for text, icon, and closing x. | 31 // Outer vertical margin for text, icon, and closing x. |
28 const int kOuterVerticalMargin = 15; | 32 const int kOuterVerticalMargin = 15; |
29 | 33 |
30 // Inner vertical margin for text messages. | 34 // Inner vertical margin for text messages. |
31 const int kInnerVerticalMargin = 10; | 35 const int kInnerVerticalMargin = 10; |
32 | 36 |
33 // We use a different kind of notification for each of these extension types. | 37 // We use a different kind of notification for each of these extension types. |
34 typedef enum { | 38 typedef enum { |
35 kBrowserAction, | 39 kBrowserAction, |
36 kGeneric, | 40 kGeneric, |
37 kOmniboxKeyword, | 41 kOmniboxKeyword, |
38 kPageAction | 42 kPageAction, |
| 43 kBundle, |
39 } ExtensionType; | 44 } ExtensionType; |
40 | 45 |
41 } | 46 } |
42 | 47 |
43 // Controller for the extension installed bubble. This bubble pops up after | 48 // Controller for the extension installed bubble. This bubble pops up after |
44 // an extension has been installed to inform the user that the install happened | 49 // an extension has been installed to inform the user that the install happened |
45 // properly, and to let the user know how to manage this extension in the | 50 // properly, and to let the user know how to manage this extension in the |
46 // future. | 51 // future. |
47 @interface ExtensionInstalledBubbleController : | 52 @interface ExtensionInstalledBubbleController : |
48 NSWindowController<NSWindowDelegate> { | 53 NSWindowController<NSWindowDelegate> { |
49 @private | 54 @private |
50 NSWindow* parentWindow_; // weak | 55 NSWindow* parentWindow_; // weak |
51 const Extension* extension_; // weak | 56 const Extension* extension_; // weak |
| 57 const extensions::BundleInstaller* bundle_; // weak |
52 Browser* browser_; // weak | 58 Browser* browser_; // weak |
53 scoped_nsobject<NSImage> icon_; | 59 scoped_nsobject<NSImage> icon_; |
54 | 60 |
55 extension_installed_bubble::ExtensionType type_; | 61 extension_installed_bubble::ExtensionType type_; |
56 | 62 |
57 // We need to remove the page action immediately when the browser window | 63 // We need to remove the page action immediately when the browser window |
58 // closes while this bubble is still open, so the bubble's closing animation | 64 // closes while this bubble is still open, so the bubble's closing animation |
59 // doesn't overlap browser destruction. | 65 // doesn't overlap browser destruction. |
60 BOOL pageActionRemoved_; | 66 BOOL pageActionRemoved_; |
61 | 67 |
62 // Lets us register for EXTENSION_LOADED notifications. The actual | 68 // Lets us register for EXTENSION_LOADED notifications. The actual |
63 // notifications are sent to the observer object, which proxies them | 69 // notifications are sent to the observer object, which proxies them |
64 // back to the controller. | 70 // back to the controller. |
65 scoped_ptr<ExtensionLoadedNotificationObserver> extensionObserver_; | 71 scoped_ptr<ExtensionLoadedNotificationObserver> extensionObserver_; |
66 | 72 |
67 // References below are weak, being obtained from the nib. | 73 // References below are weak, being obtained from the nib. |
68 IBOutlet InfoBubbleView* infoBubbleView_; | 74 IBOutlet InfoBubbleView* infoBubbleView_; |
69 IBOutlet HoverCloseButton* closeButton_; | 75 IBOutlet HoverCloseButton* closeButton_; |
70 IBOutlet NSImageView* iconImage_; | 76 IBOutlet NSImageView* iconImage_; |
71 IBOutlet NSTextField* extensionInstalledMsg_; | 77 IBOutlet NSTextField* extensionInstalledMsg_; |
72 // Only shown for page actions and omnibox keywords. | 78 // Only shown for page actions and omnibox keywords. |
73 IBOutlet NSTextField* extraInfoMsg_; | 79 IBOutlet NSTextField* extraInfoMsg_; |
74 IBOutlet NSTextField* extensionInstalledInfoMsg_; | 80 IBOutlet NSTextField* extensionInstalledInfoMsg_; |
| 81 // Only shown for bundle installs. |
| 82 IBOutlet NSTextField* installedHeadingMsg_; |
| 83 IBOutlet NSTextField* installedItemsMsg_; |
| 84 IBOutlet NSTextField* failedHeadingMsg_; |
| 85 IBOutlet NSTextField* failedItemsMsg_; |
75 } | 86 } |
76 | 87 |
77 @property(nonatomic, readonly) const Extension* extension; | 88 @property(nonatomic, readonly) const Extension* extension; |
| 89 @property(nonatomic, readonly) const extensions::BundleInstaller* bundle; |
78 @property(nonatomic) BOOL pageActionRemoved; | 90 @property(nonatomic) BOOL pageActionRemoved; |
79 | 91 |
80 // Initialize the window, and then create observers to wait for the extension | 92 // Initialize the window, and then create observers to wait for the extension |
81 // to complete loading, or the browser window to close. | 93 // to complete loading, or the browser window to close. |
82 - (id)initWithParentWindow:(NSWindow*)parentWindow | 94 - (id)initWithParentWindow:(NSWindow*)parentWindow |
83 extension:(const Extension*)extension | 95 extension:(const Extension*)extension |
| 96 bundle:(const extensions::BundleInstaller*)bundle |
84 browser:(Browser*)browser | 97 browser:(Browser*)browser |
85 icon:(SkBitmap)icon; | 98 icon:(SkBitmap)icon; |
86 | 99 |
87 // Action for close button. | 100 // Action for close button. |
88 - (IBAction)closeWindow:(id)sender; | 101 - (IBAction)closeWindow:(id)sender; |
89 | 102 |
90 // Displays the extension installed bubble. This callback is triggered by | 103 // Displays the extension installed bubble. This callback is triggered by |
91 // the extensionObserver when the extension has completed loading. | 104 // the extensionObserver when the extension has completed loading. |
92 - (void)showWindow:(id)sender; | 105 - (void)showWindow:(id)sender; |
93 | 106 |
94 // Clears our weak pointer to the Extension. This callback is triggered by | 107 // Clears our weak pointer to the Extension. This callback is triggered by |
95 // the extensionObserver when the extension is unloaded. | 108 // the extensionObserver when the extension is unloaded. |
96 - (void)extensionUnloaded:(id)sender; | 109 - (void)extensionUnloaded:(id)sender; |
97 | 110 |
98 @end | 111 @end |
99 | 112 |
100 @interface ExtensionInstalledBubbleController(ExposedForTesting) | 113 @interface ExtensionInstalledBubbleController(ExposedForTesting) |
101 | 114 |
102 - (void)removePageActionPreviewIfNecessary; | 115 - (void)removePageActionPreviewIfNecessary; |
103 - (NSWindow*)initializeWindow; | 116 - (NSWindow*)initializeWindow; |
104 - (int)calculateWindowHeight; | 117 - (int)calculateWindowHeight; |
105 - (void)setMessageFrames:(int)newWindowHeight; | 118 - (void)setMessageFrames:(int)newWindowHeight; |
106 - (NSRect)getExtensionInstalledMsgFrame; | 119 - (NSRect)getExtensionInstalledMsgFrame; |
107 - (NSRect)getExtraInfoMsgFrame; | 120 - (NSRect)getExtraInfoMsgFrame; |
108 - (NSRect)getExtensionInstalledInfoMsgFrame; | 121 - (NSRect)getExtensionInstalledInfoMsgFrame; |
109 | 122 |
110 @end // ExtensionInstalledBubbleController(ExposedForTesting) | 123 @end // ExtensionInstalledBubbleController(ExposedForTesting) |
111 | 124 |
112 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_CONTROL
LER_H_ | 125 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_CONTROL
LER_H_ |
OLD | NEW |