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

Side by Side Diff: ash/wm/workspace_controller.cc

Issue 9960024: Remove "set wallpaper..." option in system context menu when guest logged in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add shell context menu 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
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/wm/workspace_controller.h" 5 #include "ash/wm/workspace_controller.h"
6 6
7 #include "ash/desktop_background/desktop_background_controller.h"
8 #include "ash/shell.h"
9 #include "ash/wm/window_util.h" 7 #include "ash/wm/window_util.h"
10 #include "ash/wm/workspace/workspace_event_filter.h" 8 #include "ash/wm/workspace/workspace_event_filter.h"
11 #include "ash/wm/workspace/workspace_layout_manager.h" 9 #include "ash/wm/workspace/workspace_layout_manager.h"
12 #include "ash/wm/workspace/workspace_manager.h" 10 #include "ash/wm/workspace/workspace_manager.h"
13 #include "base/utf_string_conversions.h"
14 #include "grit/ash_strings.h"
15 #include "ui/aura/client/activation_client.h" 11 #include "ui/aura/client/activation_client.h"
16 #include "ui/aura/client/aura_constants.h" 12 #include "ui/aura/client/aura_constants.h"
17 #include "ui/aura/root_window.h" 13 #include "ui/aura/root_window.h"
18 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/views/controls/menu/menu_model_adapter.h"
21 #include "ui/views/controls/menu/menu_runner.h"
22 15
23 namespace ash { 16 namespace ash {
24 namespace internal { 17 namespace internal {
25 18
26 namespace { 19 namespace {
27 20
28 // Size of the grid when a grid is enabled. 21 // Size of the grid when a grid is enabled.
29 const int kGridSize = 16; 22 const int kGridSize = 16;
30 23
31 } // namespace 24 } // namespace
(...skipping 17 matching lines...) Expand all
49 viewport_->GetRootWindow()->RemoveObserver(this); 42 viewport_->GetRootWindow()->RemoveObserver(this);
50 // WorkspaceLayoutManager may attempt to access state from us. Destroy it now. 43 // WorkspaceLayoutManager may attempt to access state from us. Destroy it now.
51 if (viewport_->layout_manager() == layout_manager_) 44 if (viewport_->layout_manager() == layout_manager_)
52 viewport_->SetLayoutManager(NULL); 45 viewport_->SetLayoutManager(NULL);
53 } 46 }
54 47
55 void WorkspaceController::ToggleOverview() { 48 void WorkspaceController::ToggleOverview() {
56 workspace_manager_->SetOverview(!workspace_manager_->is_overview()); 49 workspace_manager_->SetOverview(!workspace_manager_->is_overview());
57 } 50 }
58 51
59 void WorkspaceController::ShowMenu(views::Widget* widget,
60 const gfx::Point& location) {
61 // TODO(sky): move this. Since this menu is now specific to the background it
62 // doesn't make sense to be here.
63 #if !defined(OS_MACOSX)
64 ui::SimpleMenuModel menu_model(this);
65 // This is just for testing and will be ripped out before we ship, so none of
66 // the strings are localized.
67 menu_model.AddItem(MENU_CHANGE_WALLPAPER,
68 l10n_util::GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER));
69 views::MenuModelAdapter menu_model_adapter(&menu_model);
70 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu()));
71 if (menu_runner_->RunMenuAt(
72 widget, NULL, gfx::Rect(location, gfx::Size()),
73 views::MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) ==
74 views::MenuRunner::MENU_DELETED)
75 return;
76 #endif // !defined(OS_MACOSX)
77 }
78
79 void WorkspaceController::SetGridSize(int grid_size) { 52 void WorkspaceController::SetGridSize(int grid_size) {
80 workspace_manager_->set_grid_size(grid_size); 53 workspace_manager_->set_grid_size(grid_size);
81 event_filter_->set_grid_size(grid_size); 54 event_filter_->set_grid_size(grid_size);
82 } 55 }
83 56
84 void WorkspaceController::OnWindowPropertyChanged(aura::Window* window, 57 void WorkspaceController::OnWindowPropertyChanged(aura::Window* window,
85 const void* key, 58 const void* key,
86 intptr_t old) { 59 intptr_t old) {
87 if (key == aura::client::kRootWindowActiveWindowKey) 60 if (key == aura::client::kRootWindowActiveWindowKey)
88 workspace_manager_->SetActiveWorkspaceByWindow(wm::GetActiveWindow()); 61 workspace_manager_->SetActiveWorkspaceByWindow(wm::GetActiveWindow());
89 } 62 }
90 63
91 bool WorkspaceController::IsCommandIdChecked(int command_id) const {
92 return false;
93 }
94
95 bool WorkspaceController::IsCommandIdEnabled(int command_id) const {
96 return true;
97 }
98
99 void WorkspaceController::ExecuteCommand(int command_id) {
100 switch (static_cast<MenuItem>(command_id)) {
101 case MENU_CHANGE_WALLPAPER: {
102 Shell::GetInstance()->user_wallpaper_delegate()->
103 OpenSetWallpaperPage();
104 break;
105 }
106 }
107 }
108
109 bool WorkspaceController::GetAcceleratorForCommandId(
110 int command_id,
111 ui::Accelerator* accelerator) {
112 return false;
113 }
114
115 } // namespace internal 64 } // namespace internal
116 } // namespace ash 65 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698