Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: ash/shell_context_menu.cc

Issue 10038020: Disable Set wallpaper option in context menu for guest user instead of remove it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/ash_strings.grd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shell_context_menu.h" 5 #include "ash/shell_context_menu.h"
6 6
7 #include "ash/desktop_background/desktop_background_controller.h" 7 #include "ash/desktop_background/desktop_background_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "grit/ash_strings.h" 9 #include "grit/ash_strings.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/views/controls/menu/menu_model_adapter.h" 11 #include "ui/views/controls/menu/menu_model_adapter.h"
12 #include "ui/views/controls/menu/menu_runner.h" 12 #include "ui/views/controls/menu/menu_runner.h"
13 13
14 namespace ash { 14 namespace ash {
15 namespace internal { 15 namespace internal {
16 16
17 ShellContextMenu::ShellContextMenu() { 17 ShellContextMenu::ShellContextMenu() {
18 } 18 }
19 19
20 ShellContextMenu::~ShellContextMenu() { 20 ShellContextMenu::~ShellContextMenu() {
21 } 21 }
22 22
23 void ShellContextMenu::ShowMenu(views::Widget* widget, 23 void ShellContextMenu::ShowMenu(views::Widget* widget,
24 const gfx::Point& location) { 24 const gfx::Point& location) {
25 if (!Shell::GetInstance()->user_wallpaper_delegate()->
26 CanOpenSetWallpaperPage())
27 return;
28 ui::SimpleMenuModel menu_model(this); 25 ui::SimpleMenuModel menu_model(this);
29 menu_model.AddItem(MENU_CHANGE_WALLPAPER, 26 menu_model.AddItem(MENU_CHANGE_WALLPAPER,
30 l10n_util::GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER)); 27 l10n_util::GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER));
31 views::MenuModelAdapter menu_model_adapter(&menu_model); 28 views::MenuModelAdapter menu_model_adapter(&menu_model);
32 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu())); 29 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu()));
33 if (menu_runner_->RunMenuAt( 30 if (menu_runner_->RunMenuAt(
34 widget, NULL, gfx::Rect(location, gfx::Size()), 31 widget, NULL, gfx::Rect(location, gfx::Size()),
35 views::MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) == 32 views::MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) ==
36 views::MenuRunner::MENU_DELETED) 33 views::MenuRunner::MENU_DELETED)
37 return; 34 return;
38 } 35 }
39 36
40 bool ShellContextMenu::IsCommandIdChecked(int command_id) const { 37 bool ShellContextMenu::IsCommandIdChecked(int command_id) const {
41 return false; 38 return false;
42 } 39 }
43 40
44 bool ShellContextMenu::IsCommandIdEnabled(int command_id) const { 41 bool ShellContextMenu::IsCommandIdEnabled(int command_id) const {
45 return true; 42 switch (static_cast<MenuItem>(command_id)) {
43 case MENU_CHANGE_WALLPAPER: {
44 if (Shell::GetInstance()->user_wallpaper_delegate()->
sky 2012/04/12 16:08:35 nit: no need for the conditional: return Shell::
bshe 2012/04/12 17:49:55 Done.
45 CanOpenSetWallpaperPage())
46 return true;
47 else
48 return false;
49 }
50 default:
51 return true;
52 }
46 } 53 }
47 54
48 void ShellContextMenu::ExecuteCommand(int command_id) { 55 void ShellContextMenu::ExecuteCommand(int command_id) {
49 switch (static_cast<MenuItem>(command_id)) { 56 switch (static_cast<MenuItem>(command_id)) {
50 case MENU_CHANGE_WALLPAPER: { 57 case MENU_CHANGE_WALLPAPER: {
51 Shell::GetInstance()->user_wallpaper_delegate()-> 58 Shell::GetInstance()->user_wallpaper_delegate()->
52 OpenSetWallpaperPage(); 59 OpenSetWallpaperPage();
53 break; 60 break;
54 } 61 }
55 } 62 }
56 } 63 }
57 64
58 bool ShellContextMenu::GetAcceleratorForCommandId( 65 bool ShellContextMenu::GetAcceleratorForCommandId(
59 int command_id, 66 int command_id,
60 ui::Accelerator* accelerator) { 67 ui::Accelerator* accelerator) {
61 return false; 68 return false;
62 } 69 }
63 70
64 } // namespace internal 71 } // namespace internal
65 } // namespace ash 72 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ash_strings.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698