| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/scoped_vector.h" | |
| 12 #include "chrome/browser/ui/views/browser_action_view.h" | |
| 13 #include "ui/views/controls/menu/menu_delegate.h" | 9 #include "ui/views/controls/menu/menu_delegate.h" |
| 14 | 10 |
| 15 class ActionBoxButtonController; | |
| 16 class ActionBoxMenuModel; | 11 class ActionBoxMenuModel; |
| 12 class Profile; |
| 17 | 13 |
| 18 namespace views { | 14 namespace views { |
| 19 class Background; | 15 class MenuButton; |
| 20 class Border; | |
| 21 class MenuItemView; | |
| 22 class MenuRunner; | 16 class MenuRunner; |
| 23 class View; | |
| 24 } | 17 } |
| 25 | 18 |
| 26 // ActionBoxMenu adapts the ActionBoxMenuModel to view's menu related classes. | 19 // ActionBoxMenu adapts the ActionBoxMenuModel to view's menu related classes. |
| 27 class ActionBoxMenu : public views::MenuDelegate, | 20 class ActionBoxMenu : public views::MenuDelegate { |
| 28 public BrowserActionView::Delegate { | |
| 29 public: | 21 public: |
| 30 // Constructs and initializes an ActionBoxMenu. | 22 // Constructs and initializes an ActionBoxMenu. |
| 31 static scoped_ptr<ActionBoxMenu> Create( | 23 static scoped_ptr<ActionBoxMenu> Create(Profile* profile, |
| 32 Browser* browser, | 24 scoped_ptr<ActionBoxMenuModel> model); |
| 33 scoped_ptr<ActionBoxMenuModel> model); | |
| 34 | 25 |
| 35 virtual ~ActionBoxMenu(); | 26 virtual ~ActionBoxMenu(); |
| 36 | 27 |
| 37 // Shows the menu relative to the specified button. | 28 // Shows the menu relative to the specified button. |
| 38 void RunMenu(views::MenuButton* menu_button, gfx::Point menu_offset); | 29 void RunMenu(views::MenuButton* menu_button, gfx::Point menu_offset); |
| 39 | 30 |
| 40 private: | 31 private: |
| 41 ActionBoxMenu(Browser* browser, scoped_ptr<ActionBoxMenuModel> model); | 32 ActionBoxMenu(Profile* profile, scoped_ptr<ActionBoxMenuModel> model); |
| 42 | 33 |
| 43 // Overridden from views::MenuDelegate: | 34 // Overridden from views::MenuDelegate: |
| 44 virtual void ExecuteCommand(int id) OVERRIDE; | 35 virtual void ExecuteCommand(int id) OVERRIDE; |
| 45 | 36 |
| 46 // Overridden from BrowserActionView::Delegate and DragController overrides: | |
| 47 virtual void InspectPopup(ExtensionAction* button) OVERRIDE; | |
| 48 virtual int GetCurrentTabId() const OVERRIDE; | |
| 49 virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE; | |
| 50 virtual void OnBrowserActionVisibilityChanged() OVERRIDE; | |
| 51 virtual gfx::Point GetViewContentOffset() const OVERRIDE; | |
| 52 virtual bool NeedToShowMultipleIconStates() const OVERRIDE; | |
| 53 virtual bool NeedToShowTooltip() const OVERRIDE; | |
| 54 virtual void WriteDragDataForView(views::View* sender, | |
| 55 const gfx::Point& press_pt, | |
| 56 ui::OSExchangeData* data) OVERRIDE; | |
| 57 virtual int GetDragOperationsForView(views::View* sender, | |
| 58 const gfx::Point& p) OVERRIDE; | |
| 59 virtual bool CanStartDragForView(views::View* sender, | |
| 60 const gfx::Point& press_pt, | |
| 61 const gfx::Point& p) OVERRIDE; | |
| 62 | |
| 63 // Populates |root_| with all the child menu items from the |model_|. | 37 // Populates |root_| with all the child menu items from the |model_|. |
| 64 void PopulateMenu(); | 38 void PopulateMenu(); |
| 65 | 39 |
| 66 Browser* browser_; | 40 Profile* profile_; |
| 67 | 41 |
| 68 scoped_ptr<views::MenuRunner> menu_runner_; | 42 scoped_ptr<views::MenuRunner> menu_runner_; |
| 69 | 43 |
| 70 // The model that tracks the order of the toolbar icons. | 44 // The model that tracks the order of the toolbar icons. |
| 71 scoped_ptr<ActionBoxMenuModel> model_; | 45 scoped_ptr<ActionBoxMenuModel> model_; |
| 72 | 46 |
| 73 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu); | 47 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu); |
| 74 }; | 48 }; |
| 75 | 49 |
| 76 #endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | 50 #endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
| OLD | NEW |