Update path of checkdeps to buildtools checkout
[chromium-blink-merge.git] / ui / message_center / views / message_view_context_menu_controller.cc
blob3edaa29faa787aedb4aa9ef317c4532ad49b77e7
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 #include "ui/message_center/views/message_view_context_menu_controller.h"
7 #include "ui/base/models/menu_model.h"
8 #include "ui/message_center/views/message_center_controller.h"
9 #include "ui/message_center/views/message_view.h"
10 #include "ui/views/controls/menu/menu_runner.h"
11 #include "ui/views/widget/widget.h"
13 namespace message_center {
15 MessageViewContextMenuController::MessageViewContextMenuController(
16 MessageCenterController* controller)
17 : controller_(controller) {
20 MessageViewContextMenuController::~MessageViewContextMenuController() {
23 void MessageViewContextMenuController::ShowContextMenuForView(
24 views::View* source,
25 const gfx::Point& point,
26 ui::MenuSourceType source_type) {
27 // Assumes that the target view has to be MessageView.
28 MessageView* message_view = static_cast<MessageView*>(source);
29 scoped_ptr<ui::MenuModel> menu_model(controller_->CreateMenuModel(
30 message_view->notifier_id(), message_view->display_source()));
32 if (!menu_model || menu_model->GetItemCount() == 0)
33 return;
35 views::MenuRunner menu_runner(menu_model.get());
37 ignore_result(menu_runner.RunMenuAt(source->GetWidget()->GetTopLevelWidget(),
38 NULL,
39 gfx::Rect(point, gfx::Size()),
40 views::MENU_ANCHOR_TOPRIGHT,
41 source_type,
42 views::MenuRunner::HAS_MNEMONICS));
45 } // namespace message_center