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