summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 20:27:28 +0000
committersaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 20:27:28 +0000
commitcb054f97d1ba2b7c11b05697ddb46bf3f50ff9a4 (patch)
tree3edf609873567e663a5d7f55f49750af574a51e2
parent98648a35e54bf7c4ba7564ebae9e43a109554639 (diff)
downloadchromium_src-cb054f97d1ba2b7c11b05697ddb46bf3f50ff9a4.zip
chromium_src-cb054f97d1ba2b7c11b05697ddb46bf3f50ff9a4.tar.gz
chromium_src-cb054f97d1ba2b7c11b05697ddb46bf3f50ff9a4.tar.bz2
Add Wallpaper option to launcher context menu
BUG=143015 Review URL: https://codereview.chromium.org/11092034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161391 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/desktop_background/desktop_background_view.cc2
-rw-r--r--ash/launcher/launcher.cc4
-rw-r--r--ash/launcher/launcher.h3
-rw-r--r--ash/shell.cc9
-rw-r--r--ash/shell.h7
-rw-r--r--ash/shell_context_menu.cc72
-rw-r--r--ash/shell_context_menu.h53
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_context_menu.cc10
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_context_menu.h1
10 files changed, 25 insertions, 138 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 1b43871..fcc1553 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -147,8 +147,6 @@
'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_view.cc b/ash/desktop_background/desktop_background_view.cc
index 9ebb8ea..311532e 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -152,7 +152,7 @@ bool DesktopBackgroundView::OnMousePressed(const ui::MouseEvent& event) {
void DesktopBackgroundView::ShowContextMenuForView(views::View* source,
const gfx::Point& point) {
- Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), point);
+ Shell::GetInstance()->ShowContextMenu(point);
}
views::Widget* CreateDesktopBackground(aura::RootWindow* root_window,
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc
index f8e8439..338819a 100644
--- a/ash/launcher/launcher.cc
+++ b/ash/launcher/launcher.cc
@@ -343,6 +343,10 @@ bool Launcher::IsShowingMenu() const {
return launcher_view_->IsShowingMenu();
}
+void Launcher::ShowContextMenu(const gfx::Point& location) {
+ launcher_view_->ShowContextMenu(location, false);
+}
+
bool Launcher::IsShowingOverflowBubble() const {
return launcher_view_->IsShowingOverflowBubble();
}
diff --git a/ash/launcher/launcher.h b/ash/launcher/launcher.h
index bd081896..452730f3 100644
--- a/ash/launcher/launcher.h
+++ b/ash/launcher/launcher.h
@@ -85,6 +85,9 @@ class ASH_EXPORT Launcher {
// Returns true if the Launcher is showing a context menu.
bool IsShowingMenu() const;
+ // Show the context menu for the Launcher.
+ void ShowContextMenu(const gfx::Point& location);
+
bool IsShowingOverflowBubble() const;
void SetVisible(bool visible) const;
diff --git a/ash/shell.cc b/ash/shell.cc
index 9de3e091..95b6f9d 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -25,7 +25,6 @@
#include "ash/magnifier/magnification_controller.h"
#include "ash/root_window_controller.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"
@@ -390,7 +389,6 @@ void Shell::Init() {
nested_dispatcher_controller_.reset(new NestedDispatcherController);
accelerator_controller_.reset(new AcceleratorController);
#endif
- shell_context_menu_.reset(new internal::ShellContextMenu);
// The order in which event filters are added is significant.
user_activity_detector_.reset(new UserActivityDetector);
@@ -523,16 +521,15 @@ void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) {
aura::Env::GetInstance()->RemovePreTargetHandler(filter);
}
-void Shell::ShowBackgroundMenu(views::Widget* widget,
- const gfx::Point& location) {
+void Shell::ShowContextMenu(const gfx::Point& location) {
// No context menus if user have not logged in.
if (!delegate_.get() || !delegate_->IsUserLoggedIn())
return;
// No context menus when screen is locked.
if (IsScreenLocked())
return;
- if (shell_context_menu_.get())
- shell_context_menu_->ShowMenu(widget, location);
+ if (launcher())
+ launcher()->ShowContextMenu(location);
}
void Shell::ToggleAppList() {
diff --git a/ash/shell.h b/ash/shell.h
index 044ba06..a7365d8 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -97,7 +97,6 @@ class RootWindowLayoutManager;
class ScreenPositionController;
class ShadowController;
class ShelfLayoutManager;
-class ShellContextMenu;
class SlowAnimationEventFilter;
class StackingController;
class StatusAreaWidget;
@@ -192,8 +191,9 @@ class ASH_EXPORT Shell : CursorDelegate,
void AddEnvEventFilter(aura::EventFilter* filter);
void RemoveEnvEventFilter(aura::EventFilter* filter);
- // Shows the background menu over |widget|.
- void ShowBackgroundMenu(views::Widget* widget, const gfx::Point& location);
+ // Shows the context menu for the background and launcher at
+ // |location| (in screen coordinates).
+ void ShowContextMenu(const gfx::Point& location);
// Toggles app list.
void ToggleAppList();
@@ -436,7 +436,6 @@ class ASH_EXPORT Shell : CursorDelegate,
scoped_ptr<internal::AppListController> app_list_controller_;
- scoped_ptr<internal::ShellContextMenu> shell_context_menu_;
scoped_ptr<internal::StackingController> stacking_controller_;
scoped_ptr<internal::ActivationController> activation_controller_;
scoped_ptr<internal::CaptureController> capture_controller_;
diff --git a/ash/shell_context_menu.cc b/ash/shell_context_menu.cc
deleted file mode 100644
index 5e190c3..0000000
--- a/ash/shell_context_menu.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// 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::CONTEXT_MENU) == 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
diff --git a/ash/shell_context_menu.h b/ash/shell_context_menu.h
deleted file mode 100644
index cd94828..0000000
--- a/ash/shell_context_menu.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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_
-
-#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/chrome/browser/ui/ash/launcher/launcher_context_menu.cc b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
index e52f2b4..d1e5914 100644
--- a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
+++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
+#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/launcher/launcher_context_menu.h"
#include "ash/shell.h"
#include "base/command_line.h"
@@ -99,6 +100,8 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller,
IDS_AURA_LAUNCHER_CONTEXT_MENU_POSITION,
&alignment_menu_);
}
+ AddItem(MENU_CHANGE_WALLPAPER,
+ l10n_util::GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER));
}
LauncherContextMenu::~LauncherContextMenu() {
@@ -130,6 +133,9 @@ bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const {
case MENU_PIN:
return item_.type == ash::TYPE_PLATFORM_APP ||
controller_->IsPinnable(item_.id);
+ case MENU_CHANGE_WALLPAPER:
+ return ash::Shell::GetInstance()->user_wallpaper_delegate()->
+ CanOpenSetWallpaperPage();
default:
return extension_items_->IsCommandIdEnabled(command_id);
}
@@ -180,6 +186,10 @@ void LauncherContextMenu::ExecuteCommand(int command_id) {
break;
case MENU_ALIGNMENT_MENU:
break;
+ case MENU_CHANGE_WALLPAPER:
+ ash::Shell::GetInstance()->user_wallpaper_delegate()->
+ OpenSetWallpaperPage();
+ break;
default:
extension_items_->ExecuteCommand(command_id, NULL,
content::ContextMenuParams());
diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu.h b/chrome/browser/ui/ash/launcher/launcher_context_menu.h
index 9d9ad6a..a445bdaf 100644
--- a/chrome/browser/ui/ash/launcher/launcher_context_menu.h
+++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.h
@@ -51,6 +51,7 @@ class LauncherContextMenu : public ui::SimpleMenuModel,
MENU_NEW_WINDOW,
MENU_NEW_INCOGNITO_WINDOW,
MENU_ALIGNMENT_MENU,
+ MENU_CHANGE_WALLPAPER,
};
// Does |item_| represent a valid item? See description of constructor for