This source file includes following definitions.
- ShowContextMenuForView
#include "ui/message_center/views/message_view_context_menu_controller.h"
#include "ui/base/models/menu_model.h"
#include "ui/message_center/views/message_center_controller.h"
#include "ui/message_center/views/message_view.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/widget/widget.h"
namespace message_center {
MessageViewContextMenuController::MessageViewContextMenuController(
MessageCenterController* controller)
: controller_(controller) {
}
MessageViewContextMenuController::~MessageViewContextMenuController() {
}
void MessageViewContextMenuController::ShowContextMenuForView(
views::View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) {
MessageView* message_view = static_cast<MessageView*>(source);
scoped_ptr<ui::MenuModel> menu_model(controller_->CreateMenuModel(
message_view->notifier_id(), message_view->display_source()));
if (!menu_model || menu_model->GetItemCount() == 0)
return;
views::MenuRunner menu_runner(menu_model.get());
ignore_result(menu_runner.RunMenuAt(
source->GetWidget()->GetTopLevelWidget(),
NULL,
gfx::Rect(point, gfx::Size()),
views::MenuItemView::TOPRIGHT,
source_type,
views::MenuRunner::HAS_MNEMONICS));
}
}