Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / toolbar / wrench_toolbar_button.h
blobcab4651813cdb628ebd3c0cdda57e16278833a16
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 // Opens the wrench menu immediately during a drag-and-drop operation.
36 // Used only in testing.
37 static bool g_open_wrench_immediately_for_testing;
39 private:
40 // views::MenuButton:
41 const char* GetClassName() const override;
42 bool GetDropFormats(
43 int* formats,
44 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override;
45 bool AreDropTypesRequired() override;
46 bool CanDrop(const ui::OSExchangeData& data) override;
47 void OnDragEntered(const ui::DropTargetEvent& event) override;
48 int OnDragUpdated(const ui::DropTargetEvent& event) override;
49 void OnDragExited() override;
50 int OnPerformDrop(const ui::DropTargetEvent& event) override;
51 void OnPaint(gfx::Canvas* canvas) override;
53 // Show the extension action overflow menu (which is in the app menu).
54 void ShowOverflowMenu();
56 scoped_ptr<WrenchIconPainter> wrench_icon_painter_;
58 // Our owning toolbar view.
59 ToolbarView* toolbar_view_;
61 // Whether or not we should allow dragging extension icons onto this button
62 // (in order to open the overflow in the app/wrench menu).
63 bool allow_extension_dragging_;
65 // Used to spawn weak pointers for delayed tasks to open the overflow menu.
66 base::WeakPtrFactory<WrenchToolbarButton> weak_factory_;
68 DISALLOW_COPY_AND_ASSIGN(WrenchToolbarButton);
71 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_TOOLBAR_BUTTON_H_