| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 BrowserActionsContainerView; | 15 @class BrowserActionsContainerView; |
| 16 class Extension; | 16 class Extension; |
| 17 @class ExtensionPopupController; | 17 @class ExtensionPopupController; |
| 18 class ExtensionToolbarModel; |
| 18 class ExtensionsServiceObserverBridge; | 19 class ExtensionsServiceObserverBridge; |
| 19 class Profile; | 20 class Profile; |
| 20 | 21 |
| 21 extern const CGFloat kBrowserActionButtonPadding; | 22 extern const CGFloat kBrowserActionButtonPadding; |
| 22 | 23 |
| 23 extern NSString* const kBrowserActionsChangedNotification; | 24 extern NSString* const kBrowserActionsChangedNotification; |
| 24 | 25 |
| 25 @interface BrowserActionsController : NSObject { | 26 @interface BrowserActionsController : NSObject { |
| 26 @private | 27 @private |
| 27 // Reference to the current browser. Weak. | 28 // Reference to the current browser. Weak. |
| 28 Browser* browser_; | 29 Browser* browser_; |
| 29 | 30 |
| 30 // The view from Toolbar.xib we'll be rendering our browser actions in. Weak. | 31 // The view from Toolbar.xib we'll be rendering our browser actions in. Weak. |
| 31 BrowserActionsContainerView* containerView_; | 32 BrowserActionsContainerView* containerView_; |
| 32 | 33 |
| 33 // The current profile. Weak. | 34 // The current profile. Weak. |
| 34 Profile* profile_; | 35 Profile* profile_; |
| 35 | 36 |
| 37 // The model that tracks the order of the toolbar icons. Weak. |
| 38 ExtensionToolbarModel* toolbarModel_; |
| 39 |
| 36 // The observer for the ExtensionsService we're getting events from. | 40 // The observer for the ExtensionsService we're getting events from. |
| 37 scoped_ptr<ExtensionsServiceObserverBridge> observer_; | 41 scoped_ptr<ExtensionsServiceObserverBridge> observer_; |
| 38 | 42 |
| 39 // A dictionary of Extension ID -> BrowserActionButton pairs representing the | 43 // A dictionary of Extension ID -> BrowserActionButton pairs representing the |
| 40 // buttons present in the container view. The ID is a string unique to each | 44 // buttons present in the container view. The ID is a string unique to each |
| 41 // extension. | 45 // extension. |
| 42 scoped_nsobject<NSMutableDictionary> buttons_; | 46 scoped_nsobject<NSMutableDictionary> buttons_; |
| 43 | 47 |
| 44 // The order of the BrowserActionButton objects within the dictionary. | 48 // The order of the BrowserActionButton objects within the dictionary. |
| 45 scoped_nsobject<NSMutableArray> buttonOrder_; | 49 scoped_nsobject<NSMutableArray> buttonOrder_; |
| 46 } | 50 } |
| 47 | 51 |
| 48 // Initializes the controller given the current browser and container view that | 52 // Initializes the controller given the current browser and container view that |
| 49 // will hold the browser action buttons. | 53 // will hold the browser action buttons. |
| 50 - (id)initWithBrowser:(Browser*)browser | 54 - (id)initWithBrowser:(Browser*)browser |
| 51 containerView:(BrowserActionsContainerView*)container; | 55 containerView:(BrowserActionsContainerView*)container; |
| 52 | 56 |
| 53 // Creates and appends any existing browser action buttons present within the | 57 // Creates and appends any existing browser action buttons present within the |
| 54 // extensions service to the toolbar. | 58 // extensions service to the toolbar. |
| 55 - (void)createButtons; | 59 - (void)createButtons; |
| 56 | 60 |
| 57 // Update the display of all buttons. | 61 // Update the display of all buttons. |
| 58 - (void)update; | 62 - (void)update; |
| 59 | 63 |
| 60 // Marks the container view for redraw. Called by the extension service | |
| 61 // notification bridge. | |
| 62 - (void)browserActionVisibilityHasChanged; | |
| 63 | |
| 64 // Returns the current number of browser action buttons within the container, | 64 // Returns the current number of browser action buttons within the container, |
| 65 // whether or not they are displayed. | 65 // whether or not they are displayed. |
| 66 - (int)buttonCount; | 66 - (int)buttonCount; |
| 67 | 67 |
| 68 // Returns the current number of browser action buttons displayed in the | 68 // Returns the current number of browser action buttons displayed in the |
| 69 // container. | 69 // container. |
| 70 - (int)visibleButtonCount; | 70 - (int)visibleButtonCount; |
| 71 | 71 |
| 72 // Executes the action designated by the extension. | 72 // Executes the action designated by the extension. |
| 73 - (void)browserActionClicked:(BrowserActionButton*)sender; | 73 - (void)browserActionClicked:(BrowserActionButton*)sender; |
| 74 | 74 |
| 75 // Returns the NSView for the action button associated with an extension. | 75 // Returns the NSView for the action button associated with an extension. |
| 76 - (NSView*)browserActionViewForExtension:(Extension*)extension; | 76 - (NSView*)browserActionViewForExtension:(Extension*)extension; |
| 77 | 77 |
| 78 @end // @interface BrowserActionsController | 78 @end // @interface BrowserActionsController |
| 79 | 79 |
| 80 @interface BrowserActionsController(TestingAPI) | 80 @interface BrowserActionsController(TestingAPI) |
| 81 - (NSButton*)buttonWithIndex:(int)index; | 81 - (NSButton*)buttonWithIndex:(int)index; |
| 82 @end | 82 @end |
| 83 | 83 |
| 84 #endif // CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_ | 84 #endif // CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_ |
| OLD | NEW |