summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 18:17:47 +0000
committerbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 18:17:47 +0000
commit0cfc18eb157e254e046ad48b104f7d59f04a30a2 (patch)
tree64f7e20270bd0c26175792e20cb2f90c224a4cee /ash
parent60ca6f3e715460d584cdd4ef2929e449bb46ff74 (diff)
downloadchromium_src-0cfc18eb157e254e046ad48b104f7d59f04a30a2.zip
chromium_src-0cfc18eb157e254e046ad48b104f7d59f04a30a2.tar.gz
chromium_src-0cfc18eb157e254e046ad48b104f7d59f04a30a2.tar.bz2
Remove "set wallpaper..." option in system context menu when guest logged in
BUG=120763 TEST=Log in as guest user, click right mouse button on wallpaper, there should be no "set wallpaper..." options in the popup context menu. Review URL: https://chromiumcodereview.appspot.com/9960024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131806 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/desktop_background/desktop_background_controller.h4
-rw-r--r--ash/shell.cc10
-rw-r--r--ash/shell.h2
-rw-r--r--ash/shell_context_menu.cc65
-rw-r--r--ash/shell_context_menu.h54
-rw-r--r--ash/wm/workspace_controller.cc51
-rw-r--r--ash/wm/workspace_controller.h33
8 files changed, 136 insertions, 85 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 2bd4937..5c8c215 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -109,6 +109,8 @@
'screenshot_delegate.h',
'shell.cc',
'shell.h',
+ 'shell_context_menu.cc',
+ 'shell_context_menu.h',
'shell_delegate.h',
'shell_factory.h',
'shell_window_ids.h',
diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h
index 710e00e..b603fbd 100644
--- a/ash/desktop_background/desktop_background_controller.h
+++ b/ash/desktop_background/desktop_background_controller.h
@@ -23,6 +23,10 @@ class UserWallpaperDelegate {
// Open the set wallpaper page in the browser.
virtual void OpenSetWallpaperPage() = 0;
+
+ // Returns true if user can open set wallpaper page. Only guest user returns
+ // false currently.
+ virtual bool CanOpenSetWallpaperPage() = 0;
};
// A class to listen for login and desktop background change events and set the
diff --git a/ash/shell.cc b/ash/shell.cc
index 036c00f..0d30ef1 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -18,6 +18,7 @@
#include "ash/monitor/monitor_controller.h"
#include "ash/monitor/multi_monitor_manager.h"
#include "ash/screen_ash.h"
+#include "ash/shell_context_menu.h"
#include "ash/shell_delegate.h"
#include "ash/shell_factory.h"
#include "ash/shell_window_ids.h"
@@ -255,6 +256,10 @@ class DummyUserWallpaperDelegate : public UserWallpaperDelegate {
virtual void OpenSetWallpaperPage() OVERRIDE {
}
+ virtual bool CanOpenSetWallpaperPage() OVERRIDE {
+ return false;
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate);
};
@@ -635,6 +640,7 @@ void Shell::Init() {
nested_dispatcher_controller_.reset(new NestedDispatcherController);
accelerator_controller_.reset(new AcceleratorController);
#endif
+ shell_context_menu_.reset(new internal::ShellContextMenu);
// Pass ownership of the filter to the root window.
GetRootWindow()->SetEventFilter(root_filter_);
@@ -794,8 +800,8 @@ size_t Shell::GetRootWindowEventFilterCount() const {
void Shell::ShowBackgroundMenu(views::Widget* widget,
const gfx::Point& location) {
- if (workspace_controller_.get())
- workspace_controller_->ShowMenu(widget, location);
+ if (shell_context_menu_.get())
+ shell_context_menu_->ShowMenu(widget, location);
}
void Shell::ToggleAppList() {
diff --git a/ash/shell.h b/ash/shell.h
index 2c0657b..f7fda36 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -72,6 +72,7 @@ class RootWindowEventFilter;
class RootWindowLayoutManager;
class ShadowController;
class ShelfLayoutManager;
+class ShellContextMenu;
class SystemGestureEventFilter;
class StackingController;
class TooltipController;
@@ -291,6 +292,7 @@ class ASH_EXPORT Shell {
scoped_ptr<internal::AppList> app_list_;
+ scoped_ptr<internal::ShellContextMenu> shell_context_menu_;
scoped_ptr<internal::StackingController> stacking_controller_;
scoped_ptr<internal::ActivationController> activation_controller_;
scoped_ptr<internal::WindowModalityController> window_modality_controller_;
diff --git a/ash/shell_context_menu.cc b/ash/shell_context_menu.cc
new file mode 100644
index 0000000..4c0ab85
--- /dev/null
+++ b/ash/shell_context_menu.cc
@@ -0,0 +1,65 @@
+// 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/shell.h"
+#include "grit/ash_strings.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"
+
+namespace ash {
+namespace internal {
+
+ShellContextMenu::ShellContextMenu() {
+}
+
+ShellContextMenu::~ShellContextMenu() {
+}
+
+void ShellContextMenu::ShowMenu(views::Widget* widget,
+ const gfx::Point& location) {
+ if (!Shell::GetInstance()->user_wallpaper_delegate()->
+ CanOpenSetWallpaperPage())
+ return;
+ 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::TOPRIGHT, 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 {
+ 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
diff --git a/ash/shell_context_menu.h b/ash/shell_context_menu.h
new file mode 100644
index 0000000..555e1d5
--- /dev/null
+++ b/ash/shell_context_menu.h
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef ASH_SHELL_CONTEXT_MENU_H_
+#define ASH_SHELL_CONTEXT_MENU_H_
+#pragma once
+
+#include "base/memory/scoped_ptr.h"
+#include "ui/base/models/simple_menu_model.h"
+
+namespace gfx {
+class Point;
+class Size;
+}
+
+namespace views {
+class MenuRunner;
+class Widget;
+}
+
+namespace ash {
+namespace internal {
+
+class ShellContextMenu : public ui::SimpleMenuModel::Delegate {
+ public:
+ ShellContextMenu();
+ virtual ~ShellContextMenu();
+
+ // Shows the context menu when right click on background.
+ void ShowMenu(views::Widget* widget, const gfx::Point& location);
+
+ // ui::SimpleMenuModel::Delegate overrides:
+ virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
+ virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
+ virtual void ExecuteCommand(int command_id) OVERRIDE;
+ virtual bool GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* accelerator) OVERRIDE;
+
+ private:
+ enum MenuItem {
+ MENU_CHANGE_WALLPAPER,
+ };
+
+ scoped_ptr<views::MenuRunner> menu_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellContextMenu);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_SHELL_CONTEXT_MENU_H_
diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc
index 355e5e5..ba652c2 100644
--- a/ash/wm/workspace_controller.cc
+++ b/ash/wm/workspace_controller.cc
@@ -4,21 +4,14 @@
#include "ash/wm/workspace_controller.h"
-#include "ash/desktop_background/desktop_background_controller.h"
-#include "ash/shell.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_event_filter.h"
#include "ash/wm/workspace/workspace_layout_manager.h"
#include "ash/wm/workspace/workspace_manager.h"
-#include "base/utf_string_conversions.h"
-#include "grit/ash_strings.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.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"
namespace ash {
namespace internal {
@@ -56,26 +49,6 @@ void WorkspaceController::ToggleOverview() {
workspace_manager_->SetOverview(!workspace_manager_->is_overview());
}
-void WorkspaceController::ShowMenu(views::Widget* widget,
- const gfx::Point& location) {
- // TODO(sky): move this. Since this menu is now specific to the background it
- // doesn't make sense to be here.
-#if !defined(OS_MACOSX)
- ui::SimpleMenuModel menu_model(this);
- // This is just for testing and will be ripped out before we ship, so none of
- // the strings are localized.
- 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::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) ==
- views::MenuRunner::MENU_DELETED)
- return;
-#endif // !defined(OS_MACOSX)
-}
-
void WorkspaceController::SetGridSize(int grid_size) {
workspace_manager_->set_grid_size(grid_size);
event_filter_->set_grid_size(grid_size);
@@ -88,29 +61,5 @@ void WorkspaceController::OnWindowPropertyChanged(aura::Window* window,
workspace_manager_->SetActiveWorkspaceByWindow(wm::GetActiveWindow());
}
-bool WorkspaceController::IsCommandIdChecked(int command_id) const {
- return false;
-}
-
-bool WorkspaceController::IsCommandIdEnabled(int command_id) const {
- return true;
-}
-
-void WorkspaceController::ExecuteCommand(int command_id) {
- switch (static_cast<MenuItem>(command_id)) {
- case MENU_CHANGE_WALLPAPER: {
- Shell::GetInstance()->user_wallpaper_delegate()->
- OpenSetWallpaperPage();
- break;
- }
- }
-}
-
-bool WorkspaceController::GetAcceleratorForCommandId(
- int command_id,
- ui::Accelerator* accelerator) {
- return false;
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/wm/workspace_controller.h b/ash/wm/workspace_controller.h
index b1c1f24..b95ca21 100644
--- a/ash/wm/workspace_controller.h
+++ b/ash/wm/workspace_controller.h
@@ -10,22 +10,11 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/window_observer.h"
-#include "ui/base/models/simple_menu_model.h"
namespace aura {
class Window;
}
-namespace gfx {
-class Point;
-class Size;
-}
-
-namespace views {
-class MenuRunner;
-class Widget;
-}
-
namespace ash {
namespace internal {
@@ -38,8 +27,7 @@ class WorkspaceManager;
// various workspace pieces: WorkspaceManager, WorkspaceLayoutManager and
// WorkspaceEventFilter.
class ASH_EXPORT WorkspaceController :
- public aura::WindowObserver,
- public ui::SimpleMenuModel::Delegate {
+ public aura::WindowObserver {
public:
explicit WorkspaceController(aura::Window* viewport);
virtual ~WorkspaceController();
@@ -51,9 +39,6 @@ class ASH_EXPORT WorkspaceController :
return workspace_manager_.get();
}
- // Shows the menu allowing you to configure various aspects of workspaces.
- void ShowMenu(views::Widget* widget, const gfx::Point& location);
-
// Sets the size of the grid.
void SetGridSize(int grid_size);
@@ -62,21 +47,9 @@ class ASH_EXPORT WorkspaceController :
const void* key,
intptr_t old) OVERRIDE;
- // ui::SimpleMenuModel::Delegate overrides:
- virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
- virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
- virtual void ExecuteCommand(int command_id) OVERRIDE;
- virtual bool GetAcceleratorForCommandId(
- int command_id,
- ui::Accelerator* accelerator) OVERRIDE;
-
private:
friend class WorkspaceControllerTestHelper;
- enum MenuItem {
- MENU_CHANGE_WALLPAPER,
- };
-
aura::Window* viewport_;
scoped_ptr<WorkspaceManager> workspace_manager_;
@@ -87,10 +60,6 @@ class ASH_EXPORT WorkspaceController :
// Owned by |viewport_|.
WorkspaceEventFilter* event_filter_;
-#if !defined(OS_MACOSX)
- scoped_ptr<views::MenuRunner> menu_runner_;
-#endif
-
DISALLOW_COPY_AND_ASSIGN(WorkspaceController);
};