OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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/other_device_menu_views.h" |
| 6 |
| 7 #include "ui/base/models/simple_menu_model.h" |
| 8 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 9 #include "ui/views/controls/menu/menu_runner.h" |
| 10 #include "ui/views/widget/widget.h" |
| 11 |
| 12 // static |
| 13 OtherDeviceMenu* OtherDeviceMenu::Create(ui::SimpleMenuModel* menu_model) { |
| 14 return new OtherDeviceMenuViews(menu_model); |
| 15 } |
| 16 |
| 17 OtherDeviceMenuViews::OtherDeviceMenuViews(ui::SimpleMenuModel* menu_model) |
| 18 : menu_model_(menu_model) { |
| 19 } |
| 20 |
| 21 OtherDeviceMenuViews::~OtherDeviceMenuViews() { |
| 22 } |
| 23 |
| 24 void OtherDeviceMenuViews::ShowMenu(gfx::NativeWindow window, |
| 25 const gfx::Point& location) { |
| 26 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 27 if (!widget) |
| 28 return; |
| 29 |
| 30 views::MenuModelAdapter menu_model_adapter(menu_model_); |
| 31 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu())); |
| 32 |
| 33 if (menu_runner_->RunMenuAt(widget, NULL, gfx::Rect(location, gfx::Size()), |
| 34 views::MenuItemView::TOPLEFT, 0) == |
| 35 views::MenuRunner::MENU_DELETED) { |
| 36 return; |
| 37 } |
| 38 } |
OLD | NEW |