| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 8 #include "chrome/browser/ui/toolbar/wrench_icon_painter.h" | 11 #include "chrome/browser/ui/toolbar/wrench_icon_painter.h" |
| 9 #include "ui/views/controls/button/menu_button.h" | 12 #include "ui/views/controls/button/menu_button.h" |
| 10 | 13 |
| 14 class ToolbarView; |
| 15 |
| 11 // TODO(gbillock): Rename this? No longer a wrench. | 16 // TODO(gbillock): Rename this? No longer a wrench. |
| 12 class WrenchToolbarButton : public views::MenuButton, | 17 class WrenchToolbarButton : public views::MenuButton, |
| 13 public WrenchIconPainter::Delegate { | 18 public WrenchIconPainter::Delegate { |
| 14 public: | 19 public: |
| 15 explicit WrenchToolbarButton(views::MenuButtonListener* menu_button_listener); | 20 explicit WrenchToolbarButton(ToolbarView* toolbar_view); |
| 16 virtual ~WrenchToolbarButton(); | 21 virtual ~WrenchToolbarButton(); |
| 17 | 22 |
| 18 void SetSeverity(WrenchIconPainter::Severity severity, bool animate); | 23 void SetSeverity(WrenchIconPainter::Severity severity, bool animate); |
| 19 | 24 |
| 20 // views::MenuButton: | 25 // views::MenuButton: |
| 21 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 26 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 22 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 27 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 23 | 28 |
| 24 // WrenchIconPainter::Delegate: | 29 // WrenchIconPainter::Delegate: |
| 25 virtual void ScheduleWrenchIconPaint() OVERRIDE; | 30 virtual void ScheduleWrenchIconPaint() OVERRIDE; |
| 26 | 31 |
| 27 private: | 32 private: |
| 33 // views::View: |
| 34 virtual bool GetDropFormats(int* formats, |
| 35 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; |
| 36 virtual bool AreDropTypesRequired() OVERRIDE; |
| 37 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; |
| 38 virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE; |
| 39 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; |
| 40 virtual void OnDragExited() OVERRIDE; |
| 41 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; |
| 42 |
| 43 // Show the extension action overflow menu (which is in the app menu). |
| 44 void ShowOverflowMenu(); |
| 45 |
| 28 scoped_ptr<WrenchIconPainter> wrench_icon_painter_; | 46 scoped_ptr<WrenchIconPainter> wrench_icon_painter_; |
| 29 | 47 |
| 48 // Our owning toolbar view. |
| 49 ToolbarView* toolbar_view_; |
| 50 |
| 51 // Whether or not we should allow dragging extension icons onto this button |
| 52 // (in order to open the overflow in the app/wrench menu). |
| 53 bool allow_extension_dragging_; |
| 54 |
| 55 // Used to spawn weak pointers for delayed tasks to open the overflow menu. |
| 56 base::WeakPtrFactory<WrenchToolbarButton> weak_factory_; |
| 57 |
| 30 DISALLOW_COPY_AND_ASSIGN(WrenchToolbarButton); | 58 DISALLOW_COPY_AND_ASSIGN(WrenchToolbarButton); |
| 31 }; | 59 }; |
| 32 | 60 |
| 33 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ | 61 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ |
| OLD | NEW |