diff options
Diffstat (limited to 'ash')
-rw-r--r-- | ash/ash.gyp | 2 | ||||
-rw-r--r-- | ash/desktop_background/desktop_background_view.cc | 2 | ||||
-rw-r--r-- | ash/launcher/launcher.cc | 4 | ||||
-rw-r--r-- | ash/launcher/launcher.h | 3 | ||||
-rw-r--r-- | ash/shell.cc | 9 | ||||
-rw-r--r-- | ash/shell.h | 7 | ||||
-rw-r--r-- | ash/shell_context_menu.cc | 72 | ||||
-rw-r--r-- | ash/shell_context_menu.h | 53 |
8 files changed, 14 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_ |