OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h" |
| 6 |
| 7 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 8 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 9 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 10 #include "ui/views/controls/menu/menu_item_view.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 // Bottom padding to make sure we have enough room for the icons. |
| 15 // TODO(devlin): Figure out why the bottom few pixels of the last row in the |
| 16 // overflow menu are cut off (so we can remove this). |
| 17 const int kVerticalPadding = 8; |
| 18 |
| 19 } // namespace |
| 20 |
| 21 ExtensionToolbarMenuView::ExtensionToolbarMenuView(Browser* browser) |
| 22 : browser_(browser) { |
| 23 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 24 container_ = new BrowserActionsContainer( |
| 25 browser_, |
| 26 NULL, // No owner view, means no extra keybindings are registered. |
| 27 browser_view->GetToolbarView()->browser_actions()); |
| 28 container_->Init(); |
| 29 AddChildView(container_); |
| 30 } |
| 31 |
| 32 ExtensionToolbarMenuView::~ExtensionToolbarMenuView() { |
| 33 } |
| 34 |
| 35 gfx::Size ExtensionToolbarMenuView::GetPreferredSize() const { |
| 36 gfx::Size sz = container_->GetPreferredSize(); |
| 37 if (sz.height() == 0) |
| 38 return sz; |
| 39 |
| 40 sz.Enlarge(0, kVerticalPadding); |
| 41 return sz; |
| 42 } |
| 43 |
| 44 void ExtensionToolbarMenuView::Layout() { |
| 45 // All buttons are given the same width. |
| 46 gfx::Size sz = container_->GetPreferredSize(); |
| 47 container_->SetBounds(views::MenuItemView::label_start(), |
| 48 0, |
| 49 sz.width(), |
| 50 sz.height() + (kVerticalPadding / 2)); |
| 51 } |
OLD | NEW |