| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_ | 6 #define CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #import "base/scoped_nsobject.h" | 10 #import "base/scoped_nsobject.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 | 12 |
| 13 class Browser; | 13 class Browser; |
| 14 @class BrowserActionButton; | 14 @class BrowserActionButton; |
| 15 class Extension; | 15 class Extension; |
| 16 @class ExtensionPopupController; |
| 16 class ExtensionsServiceObserverBridge; | 17 class ExtensionsServiceObserverBridge; |
| 17 class Profile; | 18 class Profile; |
| 18 | 19 |
| 19 extern const CGFloat kBrowserActionButtonPadding; | 20 extern const CGFloat kBrowserActionButtonPadding; |
| 20 extern const CGFloat kBrowserActionWidth; | 21 extern const CGFloat kBrowserActionWidth; |
| 21 | 22 |
| 22 extern NSString* const kBrowserActionsChangedNotification; | 23 extern NSString* const kBrowserActionsChangedNotification; |
| 23 | 24 |
| 24 @interface BrowserActionsController : NSObject { | 25 @interface BrowserActionsController : NSObject { |
| 25 @private | 26 @private |
| 26 // Reference to the current browser. Weak. | 27 // Reference to the current browser. Weak. |
| 27 Browser* browser_; | 28 Browser* browser_; |
| 28 | 29 |
| 29 // The view from Toolbar.xib we'll be rendering our browser actions in. Weak. | 30 // The view from Toolbar.xib we'll be rendering our browser actions in. Weak. |
| 30 NSView* containerView_; | 31 NSView* containerView_; |
| 31 | 32 |
| 32 // The current profile. Weak. | 33 // The current profile. Weak. |
| 33 Profile* profile_; | 34 Profile* profile_; |
| 34 | 35 |
| 35 // The observer for the ExtensionsService we're getting events from. | 36 // The observer for the ExtensionsService we're getting events from. |
| 36 scoped_ptr<ExtensionsServiceObserverBridge> observer_; | 37 scoped_ptr<ExtensionsServiceObserverBridge> observer_; |
| 37 | 38 |
| 38 // A dictionary of Extension ID -> BrowserActionButton pairs representing the | 39 // A dictionary of Extension ID -> BrowserActionButton pairs representing the |
| 39 // buttons present in the container view. The ID is a string unique to each | 40 // buttons present in the container view. The ID is a string unique to each |
| 40 // extension. | 41 // extension. |
| 41 scoped_nsobject<NSMutableDictionary> buttons_; | 42 scoped_nsobject<NSMutableDictionary> buttons_; |
| 42 | 43 |
| 43 // The order of the BrowserActionButton objects within the dictionary. | 44 // The order of the BrowserActionButton objects within the dictionary. |
| 44 scoped_nsobject<NSMutableArray> buttonOrder_; | 45 scoped_nsobject<NSMutableArray> buttonOrder_; |
| 46 |
| 47 // The controller for the popup displayed if a browser action has one. Weak. |
| 48 ExtensionPopupController* popupController_; |
| 45 } | 49 } |
| 46 | 50 |
| 47 // Initializes the controller given the current browser and container view that | 51 // Initializes the controller given the current browser and container view that |
| 48 // will hold the browser action buttons. | 52 // will hold the browser action buttons. |
| 49 - (id)initWithBrowser:(Browser*)browser | 53 - (id)initWithBrowser:(Browser*)browser |
| 50 containerView:(NSView*)container; | 54 containerView:(NSView*)container; |
| 51 | 55 |
| 52 // Creates and appends any existing browser action buttons present within the | 56 // Creates and appends any existing browser action buttons present within the |
| 53 // extensions service to the toolbar. | 57 // extensions service to the toolbar. |
| 54 - (void)createButtons; | 58 - (void)createButtons; |
| 55 | 59 |
| 56 // Hides the browser action's popup menu (if one is present and visible). | 60 // Hides the browser action's popup menu (if one is present and visible). |
| 57 - (void)hidePopup; | 61 - (void)hidePopup; |
| 58 | 62 |
| 63 // Returns the controller used to display the popup being shown. If no popup is |
| 64 // currently open, then nil is returned. |
| 65 - (ExtensionPopupController*)popup; |
| 66 |
| 59 // Marks the container view for redraw. Called by the extension service | 67 // Marks the container view for redraw. Called by the extension service |
| 60 // notification bridge. | 68 // notification bridge. |
| 61 - (void)browserActionVisibilityHasChanged; | 69 - (void)browserActionVisibilityHasChanged; |
| 62 | 70 |
| 63 // Returns the current number of browser action buttons displayed in the | 71 // Returns the current number of browser action buttons displayed in the |
| 64 // container. | 72 // container. |
| 65 - (int)buttonCount; | 73 - (int)buttonCount; |
| 66 | 74 |
| 67 // Executes the action designated by the extension. | 75 // Executes the action designated by the extension. |
| 68 - (void)browserActionClicked:(BrowserActionButton*)sender; | 76 - (void)browserActionClicked:(BrowserActionButton*)sender; |
| 69 | 77 |
| 70 // Returns the current ID of the active tab, -1 in the case where the user is in | 78 // Returns the current ID of the active tab, -1 in the case where the user is in |
| 71 // incognito mode. | 79 // incognito mode. |
| 72 - (int)currentTabId; | 80 - (int)currentTabId; |
| 73 | 81 |
| 74 @end // @interface BrowserActionsController | 82 @end // @interface BrowserActionsController |
| 75 | 83 |
| 76 #endif // CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_ | 84 #endif // CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_ |
| OLD | NEW |