| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 // Removes a menu listener. | 50 // Removes a menu listener. |
| 51 void RemoveMenuListener(views::MenuListener* listener); | 51 void RemoveMenuListener(views::MenuListener* listener); |
| 52 | 52 |
| 53 // views::MenuButton: | 53 // views::MenuButton: |
| 54 gfx::Size GetPreferredSize() const override; | 54 gfx::Size GetPreferredSize() const override; |
| 55 | 55 |
| 56 // WrenchIconPainter::Delegate: | 56 // WrenchIconPainter::Delegate: |
| 57 void ScheduleWrenchIconPaint() override; | 57 void ScheduleWrenchIconPaint() override; |
| 58 | 58 |
| 59 // Updates the presentation according to |severity_| and the theme provider. |
| 60 // Only used in MD. |
| 61 void UpdateIcon(); |
| 62 |
| 59 // Opens the app menu immediately during a drag-and-drop operation. | 63 // Opens the app menu immediately during a drag-and-drop operation. |
| 60 // Used only in testing. | 64 // Used only in testing. |
| 61 static bool g_open_app_immediately_for_testing; | 65 static bool g_open_app_immediately_for_testing; |
| 62 | 66 |
| 63 private: | 67 private: |
| 64 // views::MenuButton: | 68 // views::MenuButton: |
| 65 const char* GetClassName() const override; | 69 const char* GetClassName() const override; |
| 66 bool GetDropFormats( | 70 bool GetDropFormats( |
| 67 int* formats, | 71 int* formats, |
| 68 std::set<ui::Clipboard::FormatType>* format_types) override; | 72 std::set<ui::Clipboard::FormatType>* format_types) override; |
| 69 bool AreDropTypesRequired() override; | 73 bool AreDropTypesRequired() override; |
| 70 bool CanDrop(const ui::OSExchangeData& data) override; | 74 bool CanDrop(const ui::OSExchangeData& data) override; |
| 71 void OnDragEntered(const ui::DropTargetEvent& event) override; | 75 void OnDragEntered(const ui::DropTargetEvent& event) override; |
| 72 int OnDragUpdated(const ui::DropTargetEvent& event) override; | 76 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
| 73 void OnDragExited() override; | 77 void OnDragExited() override; |
| 74 int OnPerformDrop(const ui::DropTargetEvent& event) override; | 78 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
| 75 void OnPaint(gfx::Canvas* canvas) override; | 79 void OnPaint(gfx::Canvas* canvas) override; |
| 76 | 80 |
| 81 // Only used in pre-MD. |
| 77 scoped_ptr<WrenchIconPainter> wrench_icon_painter_; | 82 scoped_ptr<WrenchIconPainter> wrench_icon_painter_; |
| 78 | 83 |
| 84 // Only used in MD. |
| 85 WrenchIconPainter::Severity severity_; |
| 86 |
| 79 // Our owning toolbar view. | 87 // Our owning toolbar view. |
| 80 ToolbarView* toolbar_view_; | 88 ToolbarView* toolbar_view_; |
| 81 | 89 |
| 82 // Whether or not we should allow dragging extension icons onto this button | 90 // Whether or not we should allow dragging extension icons onto this button |
| 83 // (in order to open the overflow in the app menu). | 91 // (in order to open the overflow in the app menu). |
| 84 bool allow_extension_dragging_; | 92 bool allow_extension_dragging_; |
| 85 | 93 |
| 86 // Listeners to call when the menu opens. | 94 // Listeners to call when the menu opens. |
| 87 base::ObserverList<views::MenuListener> menu_listeners_; | 95 base::ObserverList<views::MenuListener> menu_listeners_; |
| 88 | 96 |
| 89 // App model and menu. | 97 // App model and menu. |
| 90 // Note that the menu should be destroyed before the model it uses, so the | 98 // Note that the menu should be destroyed before the model it uses, so the |
| 91 // menu should be listed later. | 99 // menu should be listed later. |
| 92 scoped_ptr<WrenchMenuModel> menu_model_; | 100 scoped_ptr<WrenchMenuModel> menu_model_; |
| 93 scoped_ptr<WrenchMenu> menu_; | 101 scoped_ptr<WrenchMenu> menu_; |
| 94 | 102 |
| 95 // Used to spawn weak pointers for delayed tasks to open the overflow menu. | 103 // Used to spawn weak pointers for delayed tasks to open the overflow menu. |
| 96 base::WeakPtrFactory<WrenchToolbarButton> weak_factory_; | 104 base::WeakPtrFactory<WrenchToolbarButton> weak_factory_; |
| 97 | 105 |
| 98 DISALLOW_COPY_AND_ASSIGN(WrenchToolbarButton); | 106 DISALLOW_COPY_AND_ASSIGN(WrenchToolbarButton); |
| 99 }; | 107 }; |
| 100 | 108 |
| 101 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ | 109 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_ |
| OLD | NEW |