BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / views / toolbar / extension_toolbar_menu_view.h
bloba8e87fa6dd4b3ab33303f3be5f70953cf29af9aa
1 // Copyright 2014 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_EXTENSION_TOOLBAR_MENU_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_EXTENSION_TOOLBAR_MENU_VIEW_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/scoped_observer.h"
10 #include "chrome/browser/ui/views/toolbar/browser_actions_container_observer.h"
11 #include "ui/views/controls/scroll_view.h"
13 class Browser;
14 class BrowserActionsContainer;
15 class WrenchMenu;
17 // ExtensionToolbarMenuView is the view containing the extension actions that
18 // overflowed from the BrowserActionsContainer, and is contained in and owned by
19 // the wrench menu.
20 // In the event that the WrenchMenu was opened for an Extension Action drag-and-
21 // drop, this will also close the menu upon completion.
22 class ExtensionToolbarMenuView : public views::ScrollView,
23 public BrowserActionsContainerObserver {
24 public:
25 ExtensionToolbarMenuView(Browser* browser, WrenchMenu* wrench_menu);
26 ~ExtensionToolbarMenuView() override;
28 // Returns whether the wrench menu should show this view. This is true when
29 // either |container_| has icons to display or the menu was opened for a drag-
30 // and-drop operation.
31 bool ShouldShow();
33 // views::View:
34 gfx::Size GetPreferredSize() const override;
35 int GetHeightForWidth(int width) const override;
36 void Layout() override;
38 BrowserActionsContainer* container_for_testing() {
39 return container_;
42 // Sets the time delay the wrench menu takes to close after a drag-and-drop
43 // operation.
44 static void set_close_menu_delay_for_testing(int delay);
46 private:
47 // BrowserActionsContainerObserver:
48 void OnBrowserActionDragDone() override;
50 // Closes the |wrench_menu_|.
51 void CloseWrenchMenu();
53 // Returns the padding before the BrowserActionsContainer in the menu.
54 int start_padding() const;
56 // The associated browser.
57 Browser* browser_;
59 // The WrenchMenu, which may need to be closed after a drag-and-drop.
60 WrenchMenu* wrench_menu_;
62 // The overflow BrowserActionsContainer which is nested in this view.
63 BrowserActionsContainer* container_;
65 // The maximum allowed height for the view.
66 int max_height_;
68 ScopedObserver<BrowserActionsContainer, BrowserActionsContainerObserver>
69 browser_actions_container_observer_;
71 base::WeakPtrFactory<ExtensionToolbarMenuView> weak_factory_;
73 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarMenuView);
76 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_EXTENSION_TOOLBAR_MENU_VIEW_H_