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" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 class WrenchToolbarButton : public views::MenuButton, | 21 class WrenchToolbarButton : public views::MenuButton, |
22 public WrenchIconPainter::Delegate { | 22 public WrenchIconPainter::Delegate { |
23 public: | 23 public: |
24 explicit WrenchToolbarButton(ToolbarView* toolbar_view); | 24 explicit WrenchToolbarButton(ToolbarView* toolbar_view); |
25 ~WrenchToolbarButton() override; | 25 ~WrenchToolbarButton() override; |
26 | 26 |
27 void SetSeverity(WrenchIconPainter::Severity severity, bool animate); | 27 void SetSeverity(WrenchIconPainter::Severity severity, bool animate); |
28 | 28 |
29 // views::MenuButton: | 29 // views::MenuButton: |
30 gfx::Size GetPreferredSize() const override; | 30 gfx::Size GetPreferredSize() const override; |
31 void OnPaint(gfx::Canvas* canvas) override; | |
32 | 31 |
33 // WrenchIconPainter::Delegate: | 32 // WrenchIconPainter::Delegate: |
34 void ScheduleWrenchIconPaint() override; | 33 void ScheduleWrenchIconPaint() override; |
35 | 34 |
36 // Sets |overflowed_toolbar_action_wants_to_run_| and schedules a paint. | 35 // Sets |overflowed_toolbar_action_wants_to_run_| and schedules a paint. |
37 void SetOverflowedToolbarActionWantsToRun(bool wants_to_run); | 36 void SetOverflowedToolbarActionWantsToRun(bool wants_to_run); |
38 | 37 |
39 bool overflowed_toolbar_action_wants_to_run_for_testing() const { | 38 bool overflowed_toolbar_action_wants_to_run_for_testing() const { |
40 return overflowed_toolbar_action_wants_to_run_for_testing_; | 39 return overflowed_toolbar_action_wants_to_run_for_testing_; |
41 } | 40 } |
42 | 41 |
43 // Opens the wrench menu immediately during a drag-and-drop operation. | 42 // Opens the wrench menu immediately during a drag-and-drop operation. |
44 // Used only in testing. | 43 // Used only in testing. |
45 static bool g_open_wrench_immediately_for_testing; | 44 static bool g_open_wrench_immediately_for_testing; |
46 | 45 |
47 private: | 46 private: |
48 // views::View: | 47 // views::MenuButton: |
| 48 const char* GetClassName() const override; |
49 bool GetDropFormats( | 49 bool GetDropFormats( |
50 int* formats, | 50 int* formats, |
51 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; | 51 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; |
52 bool AreDropTypesRequired() override; | 52 bool AreDropTypesRequired() override; |
53 bool CanDrop(const ui::OSExchangeData& data) override; | 53 bool CanDrop(const ui::OSExchangeData& data) override; |
54 void OnDragEntered(const ui::DropTargetEvent& event) override; | 54 void OnDragEntered(const ui::DropTargetEvent& event) override; |
55 int OnDragUpdated(const ui::DropTargetEvent& event) override; | 55 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
56 void OnDragExited() override; | 56 void OnDragExited() override; |
57 int OnPerformDrop(const ui::DropTargetEvent& event) override; | 57 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
| 58 void OnPaint(gfx::Canvas* canvas) override; |
58 | 59 |
59 // Show the extension action overflow menu (which is in the app menu). | 60 // Show the extension action overflow menu (which is in the app menu). |
60 void ShowOverflowMenu(); | 61 void ShowOverflowMenu(); |
61 | 62 |
62 scoped_ptr<WrenchIconPainter> wrench_icon_painter_; | 63 scoped_ptr<WrenchIconPainter> wrench_icon_painter_; |
63 | 64 |
64 // Our owning toolbar view. | 65 // Our owning toolbar view. |
65 ToolbarView* toolbar_view_; | 66 ToolbarView* toolbar_view_; |
66 | 67 |
67 // Whether or not we should allow dragging extension icons onto this button | 68 // Whether or not we should allow dragging extension icons onto this button |
68 // (in order to open the overflow in the app/wrench menu). | 69 // (in order to open the overflow in the app/wrench menu). |
69 bool allow_extension_dragging_; | 70 bool allow_extension_dragging_; |
70 | 71 |
71 // A flag for whether or not any overflowed toolbar actions want to run. | 72 // A flag for whether or not any overflowed toolbar actions want to run. |
72 // Only needed for testing. | 73 // Only needed for testing. |
73 bool overflowed_toolbar_action_wants_to_run_for_testing_; | 74 bool overflowed_toolbar_action_wants_to_run_for_testing_; |
74 | 75 |
75 // Used to spawn weak pointers for delayed tasks to open the overflow menu. | 76 // Used to spawn weak pointers for delayed tasks to open the overflow menu. |
76 base::WeakPtrFactory<WrenchToolbarButton> weak_factory_; | 77 base::WeakPtrFactory<WrenchToolbarButton> weak_factory_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(WrenchToolbarButton); | 79 DISALLOW_COPY_AND_ASSIGN(WrenchToolbarButton); |
79 }; | 80 }; |
80 | 81 |
81 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ | 82 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ |
OLD | NEW |