summaryrefslogtreecommitdiffstats
path: root/ash/shell_context_menu.cc
blob: e7041470b879197b5534055399a6a07ba2ca562f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/shell_context_menu.h"

#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/display/display_controller.h"
#include "ash/shell.h"
#include "grit/ash_strings.h"
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/widget/widget.h"

namespace ash {
namespace internal {

ShellContextMenu::ShellContextMenu() {
}

ShellContextMenu::~ShellContextMenu() {
}

void ShellContextMenu::ShowMenu(views::Widget* widget,
                                const gfx::Point& location) {
  ui::SimpleMenuModel menu_model(this);
  menu_model.AddItem(MENU_CHANGE_WALLPAPER,
      l10n_util::GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER));
  views::MenuModelAdapter menu_model_adapter(&menu_model);
  menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu()));
  if (menu_runner_->RunMenuAt(
          widget, NULL, gfx::Rect(location, gfx::Size()),
          views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) ==
      views::MenuRunner::MENU_DELETED)
    return;
}

bool ShellContextMenu::IsCommandIdChecked(int command_id) const {
  return false;
}

bool ShellContextMenu::IsCommandIdEnabled(int command_id) const {
  switch (static_cast<MenuItem>(command_id)) {
    case MENU_CHANGE_WALLPAPER: {
      return Shell::GetInstance()->user_wallpaper_delegate()->
          CanOpenSetWallpaperPage();
    }
    default:
      return true;
  }
}

void ShellContextMenu::ExecuteCommand(int command_id) {
  switch (static_cast<MenuItem>(command_id)) {
    case MENU_CHANGE_WALLPAPER: {
      Shell::GetInstance()->user_wallpaper_delegate()->
          OpenSetWallpaperPage();
      break;
    }
  }
}

bool ShellContextMenu::GetAcceleratorForCommandId(
      int command_id,
      ui::Accelerator* accelerator) {
  return false;
}

}  // namespace internal
}  // namespace ash