OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #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 "content/public/browser/notification_observer.h" |
| 14 #include "ui/base/models/menu_model.h" |
| 15 #include "ui/views/controls/menu/menu_delegate.h" |
| 16 |
| 17 class ActionBoxMenuModel; |
| 18 |
| 19 namespace views { |
| 20 class Background; |
| 21 class Border; |
| 22 class MenuItemView; |
| 23 class MenuRunner; |
| 24 class View; |
| 25 } |
| 26 |
| 27 // ActionBoxMenu adapts the ActionBoxMenuModel to view's menu related classes. |
| 28 class ActionBoxMenu : public views::MenuDelegate, |
| 29 public BrowserActionView::Delegate, |
| 30 public content::NotificationObserver { |
| 31 public: |
| 32 ActionBoxMenu(Browser* browser, |
| 33 ActionBoxMenuModel* model, |
| 34 bool bookmark_item_state); |
| 35 virtual ~ActionBoxMenu(); |
| 36 |
| 37 void Init(); |
| 38 |
| 39 // Shows the menu relative to the specified button. |
| 40 void RunMenu(views::MenuButton* menu_button); |
| 41 |
| 42 private: |
| 43 // MenuDelegate overrides: |
| 44 virtual void ExecuteCommand(int id) OVERRIDE; |
| 45 virtual views::Border* CreateMenuBorder() OVERRIDE; |
| 46 virtual views::Background* CreateMenuBackground() OVERRIDE; |
| 47 |
| 48 // BrowserActionView::Delegate and DragController overrides: |
| 49 virtual int GetCurrentTabId() const OVERRIDE; |
| 50 virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE; |
| 51 virtual void OnBrowserActionVisibilityChanged() OVERRIDE; |
| 52 virtual gfx::Size GetViewContentOffset() const OVERRIDE; |
| 53 virtual void WriteDragDataForView(views::View* sender, |
| 54 const gfx::Point& press_pt, |
| 55 ui::OSExchangeData* data) OVERRIDE; |
| 56 virtual int GetDragOperationsForView(views::View* sender, |
| 57 const gfx::Point& p) OVERRIDE; |
| 58 virtual bool CanStartDragForView(views::View* sender, |
| 59 const gfx::Point& press_pt, |
| 60 const gfx::Point& p) OVERRIDE; |
| 61 |
| 62 // NotificationObserver overrides: |
| 63 virtual void Observe(int type, |
| 64 const content::NotificationSource& source, |
| 65 const content::NotificationDetails& details) OVERRIDE; |
| 66 |
| 67 // Creates bookmark menu item and adds it to menu, |next_id| is incremented. |
| 68 views::MenuItemView* AddBookmarkMenuItem(views::MenuItemView* parent, |
| 69 int* next_id); |
| 70 |
| 71 // Populates |parent| with all the child menus in |model|. |
| 72 void PopulateMenu(); |
| 73 |
| 74 Browser* browser_; |
| 75 |
| 76 // The views menu. Owned by |menu_runner_|. |
| 77 views::MenuItemView* root_; |
| 78 |
| 79 scoped_ptr<views::MenuRunner> menu_runner_; |
| 80 |
| 81 // The model that tracks the order of the toolbar icons. |
| 82 ActionBoxMenuModel* model_; |
| 83 |
| 84 bool bookmark_item_state_; |
| 85 |
| 86 ScopedVector<BrowserActionView> browser_action_views_; |
| 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu); |
| 89 }; |
| 90 |
| 91 #endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
OLD | NEW |