Move VISUAL_STATE promise to activation
[chromium-blink-merge.git] / ui / message_center / views / message_view_context_menu_controller.cc
blobd5b6139c1dda40813f4f7b0dbc940544bae28392
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(),
36 views::MenuRunner::HAS_MNEMONICS);
38 ignore_result(menu_runner.RunMenuAt(source->GetWidget()->GetTopLevelWidget(),
39 NULL,
40 gfx::Rect(point, gfx::Size()),
41 views::MENU_ANCHOR_TOPRIGHT,
42 source_type));
45 } // namespace message_center