Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / toolbar / wrench_toolbar_button.h
blob3e99ecd7da1509a6ab23c54eff59c09e87c62f68
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/ui/toolbar/wrench_icon_painter.h"
12 #include "ui/views/controls/button/menu_button.h"
14 namespace views {
15 class LabelButtonBorder;
18 class ToolbarView;
20 // TODO(gbillock): Rename this? No longer a wrench.
21 class WrenchToolbarButton : public views::MenuButton,
22 public WrenchIconPainter::Delegate {
23 public:
24 explicit WrenchToolbarButton(ToolbarView* toolbar_view);
25 ~WrenchToolbarButton() override;
27 void SetSeverity(WrenchIconPainter::Severity severity, bool animate);
29 // views::MenuButton:
30 gfx::Size GetPreferredSize() const override;
32 // WrenchIconPainter::Delegate:
33 void ScheduleWrenchIconPaint() override;
35 // Sets |overflowed_toolbar_action_wants_to_run_| and schedules a paint.
36 void SetOverflowedToolbarActionWantsToRun(bool wants_to_run);
38 bool overflowed_toolbar_action_wants_to_run_for_testing() const {
39 return overflowed_toolbar_action_wants_to_run_for_testing_;
42 // Opens the wrench menu immediately during a drag-and-drop operation.
43 // Used only in testing.
44 static bool g_open_wrench_immediately_for_testing;
46 private:
47 // views::MenuButton:
48 const char* GetClassName() const override;
49 bool GetDropFormats(
50 int* formats,
51 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override;
52 bool AreDropTypesRequired() override;
53 bool CanDrop(const ui::OSExchangeData& data) override;
54 void OnDragEntered(const ui::DropTargetEvent& event) override;
55 int OnDragUpdated(const ui::DropTargetEvent& event) override;
56 void OnDragExited() override;
57 int OnPerformDrop(const ui::DropTargetEvent& event) override;
58 void OnPaint(gfx::Canvas* canvas) override;
60 // Show the extension action overflow menu (which is in the app menu).
61 void ShowOverflowMenu();
63 scoped_ptr<WrenchIconPainter> wrench_icon_painter_;
65 // Our owning toolbar view.
66 ToolbarView* toolbar_view_;
68 // Whether or not we should allow dragging extension icons onto this button
69 // (in order to open the overflow in the app/wrench menu).
70 bool allow_extension_dragging_;
72 // A flag for whether or not any overflowed toolbar actions want to run.
73 // Only needed for testing.
74 bool overflowed_toolbar_action_wants_to_run_for_testing_;
76 // Used to spawn weak pointers for delayed tasks to open the overflow menu.
77 base::WeakPtrFactory<WrenchToolbarButton> weak_factory_;
79 DISALLOW_COPY_AND_ASSIGN(WrenchToolbarButton);
82 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_