OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/ui/views/toolbar/chevron_menu_button.h" | 5 #include "chrome/browser/ui/views/toolbar/chevron_menu_button.h" |
6 | 6 |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_action.h" | 10 #include "chrome/browser/extensions/extension_action.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 view_(view) { | 40 view_(view) { |
41 DCHECK(menu_item_view); | 41 DCHECK(menu_item_view); |
42 DCHECK(view); | 42 DCHECK(view); |
43 view->set_icon_observer(this); | 43 view->set_icon_observer(this); |
44 } | 44 } |
45 virtual ~IconUpdater() { | 45 virtual ~IconUpdater() { |
46 view_->set_icon_observer(NULL); | 46 view_->set_icon_observer(NULL); |
47 } | 47 } |
48 | 48 |
49 // BrowserActionView::IconObserver: | 49 // BrowserActionView::IconObserver: |
50 virtual void OnIconUpdated(const gfx::ImageSkia& icon) OVERRIDE { | 50 virtual void OnIconUpdated(const gfx::ImageSkia& icon) override { |
51 menu_item_view_->SetIcon(icon); | 51 menu_item_view_->SetIcon(icon); |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 // The menu item view whose icon might be updated. | 55 // The menu item view whose icon might be updated. |
56 views::MenuItemView* menu_item_view_; | 56 views::MenuItemView* menu_item_view_; |
57 | 57 |
58 // The view to be observed. When its icon changes, update the corresponding | 58 // The view to be observed. When its icon changes, update the corresponding |
59 // menu item view's icon. | 59 // menu item view's icon. |
60 BrowserActionView* view_; | 60 BrowserActionView* view_; |
(...skipping 12 matching lines...) Expand all Loading... |
73 virtual ~MenuController(); | 73 virtual ~MenuController(); |
74 | 74 |
75 // Shows the overflow menu. | 75 // Shows the overflow menu. |
76 void RunMenu(views::Widget* widget); | 76 void RunMenu(views::Widget* widget); |
77 | 77 |
78 // Closes the overflow menu (and its context menu if open as well). | 78 // Closes the overflow menu (and its context menu if open as well). |
79 void CloseMenu(); | 79 void CloseMenu(); |
80 | 80 |
81 private: | 81 private: |
82 // views::MenuDelegate: | 82 // views::MenuDelegate: |
83 virtual bool IsCommandEnabled(int id) const OVERRIDE; | 83 virtual bool IsCommandEnabled(int id) const override; |
84 virtual void ExecuteCommand(int id) OVERRIDE; | 84 virtual void ExecuteCommand(int id) override; |
85 virtual bool ShowContextMenu(views::MenuItemView* source, | 85 virtual bool ShowContextMenu(views::MenuItemView* source, |
86 int id, | 86 int id, |
87 const gfx::Point& p, | 87 const gfx::Point& p, |
88 ui::MenuSourceType source_type) OVERRIDE; | 88 ui::MenuSourceType source_type) override; |
89 virtual void DropMenuClosed(views::MenuItemView* menu) OVERRIDE; | 89 virtual void DropMenuClosed(views::MenuItemView* menu) override; |
90 // These drag functions offer support for dragging icons into the overflow | 90 // These drag functions offer support for dragging icons into the overflow |
91 // menu. | 91 // menu. |
92 virtual bool GetDropFormats( | 92 virtual bool GetDropFormats( |
93 views::MenuItemView* menu, | 93 views::MenuItemView* menu, |
94 int* formats, | 94 int* formats, |
95 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; | 95 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; |
96 virtual bool AreDropTypesRequired(views::MenuItemView* menu) OVERRIDE; | 96 virtual bool AreDropTypesRequired(views::MenuItemView* menu) override; |
97 virtual bool CanDrop(views::MenuItemView* menu, | 97 virtual bool CanDrop(views::MenuItemView* menu, |
98 const ui::OSExchangeData& data) OVERRIDE; | 98 const ui::OSExchangeData& data) override; |
99 virtual int GetDropOperation(views::MenuItemView* item, | 99 virtual int GetDropOperation(views::MenuItemView* item, |
100 const ui::DropTargetEvent& event, | 100 const ui::DropTargetEvent& event, |
101 DropPosition* position) OVERRIDE; | 101 DropPosition* position) override; |
102 virtual int OnPerformDrop(views::MenuItemView* menu, | 102 virtual int OnPerformDrop(views::MenuItemView* menu, |
103 DropPosition position, | 103 DropPosition position, |
104 const ui::DropTargetEvent& event) OVERRIDE; | 104 const ui::DropTargetEvent& event) override; |
105 // These three drag functions offer support for dragging icons out of the | 105 // These three drag functions offer support for dragging icons out of the |
106 // overflow menu. | 106 // overflow menu. |
107 virtual bool CanDrag(views::MenuItemView* menu) OVERRIDE; | 107 virtual bool CanDrag(views::MenuItemView* menu) override; |
108 virtual void WriteDragData(views::MenuItemView* sender, | 108 virtual void WriteDragData(views::MenuItemView* sender, |
109 ui::OSExchangeData* data) OVERRIDE; | 109 ui::OSExchangeData* data) override; |
110 virtual int GetDragOperations(views::MenuItemView* sender) OVERRIDE; | 110 virtual int GetDragOperations(views::MenuItemView* sender) override; |
111 | 111 |
112 // Returns the offset into |views_| for the given |id|. | 112 // Returns the offset into |views_| for the given |id|. |
113 size_t IndexForId(int id) const; | 113 size_t IndexForId(int id) const; |
114 | 114 |
115 // The owning ChevronMenuButton. | 115 // The owning ChevronMenuButton. |
116 ChevronMenuButton* owner_; | 116 ChevronMenuButton* owner_; |
117 | 117 |
118 // A pointer to the browser action container. | 118 // A pointer to the browser action container. |
119 BrowserActionsContainer* browser_actions_container_; | 119 BrowserActionsContainer* browser_actions_container_; |
120 | 120 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 void ChevronMenuButton::ShowOverflowMenu(bool for_drop) { | 433 void ChevronMenuButton::ShowOverflowMenu(bool for_drop) { |
434 DCHECK(!menu_controller_); | 434 DCHECK(!menu_controller_); |
435 menu_controller_.reset(new MenuController( | 435 menu_controller_.reset(new MenuController( |
436 this, browser_actions_container_, for_drop)); | 436 this, browser_actions_container_, for_drop)); |
437 menu_controller_->RunMenu(GetWidget()); | 437 menu_controller_->RunMenu(GetWidget()); |
438 } | 438 } |
439 | 439 |
440 void ChevronMenuButton::MenuDone() { | 440 void ChevronMenuButton::MenuDone() { |
441 menu_controller_.reset(); | 441 menu_controller_.reset(); |
442 } | 442 } |
OLD | NEW |