diff options
27 files changed, 140 insertions, 29 deletions
diff --git a/ash/launcher/launcher_types.h b/ash/launcher/launcher_types.h index 1a7a894..847418c 100644 --- a/ash/launcher/launcher_types.h +++ b/ash/launcher/launcher_types.h @@ -35,6 +35,9 @@ enum LauncherItemType { // Represents a windowed V1 browser app. TYPE_WINDOWED_APP, + // Represents a dialog. + TYPE_DIALOG, + // Default value. TYPE_UNDEFINED, }; diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index ac607c5..38d6d99 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -541,7 +541,9 @@ void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen, ui::MenuSourceType source_type) { DCHECK(Shell::GetInstance()->delegate()); scoped_ptr<ui::MenuModel> menu_model( - Shell::GetInstance()->delegate()->CreateContextMenu(root_window())); + Shell::GetInstance()->delegate()->CreateContextMenu(root_window(), + NULL, + NULL)); if (!menu_model) return; diff --git a/ash/shelf/app_list_shelf_item_delegate.cc b/ash/shelf/app_list_shelf_item_delegate.cc index 8d56de6..51562ca 100644 --- a/ash/shelf/app_list_shelf_item_delegate.cc +++ b/ash/shelf/app_list_shelf_item_delegate.cc @@ -39,7 +39,9 @@ base::string16 AppListShelfItemDelegate::GetTitle() { ui::MenuModel* AppListShelfItemDelegate::CreateContextMenu( aura::Window* root_window) { - return Shell::GetInstance()->delegate()->CreateContextMenu(root_window); + return Shell::GetInstance()->delegate()->CreateContextMenu(root_window, + NULL, + NULL); } ShelfMenuModel* AppListShelfItemDelegate::CreateApplicationMenu( @@ -56,5 +58,8 @@ bool AppListShelfItemDelegate::ShouldShowTooltip() { return true; } +void AppListShelfItemDelegate::Close() { +} + } // namespace internal } // namespace ash diff --git a/ash/shelf/app_list_shelf_item_delegate.h b/ash/shelf/app_list_shelf_item_delegate.h index 0396821..d858229 100644 --- a/ash/shelf/app_list_shelf_item_delegate.h +++ b/ash/shelf/app_list_shelf_item_delegate.h @@ -26,6 +26,7 @@ class AppListShelfItemDelegate : public ShelfItemDelegate { virtual ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE; virtual bool IsDraggable() OVERRIDE; virtual bool ShouldShowTooltip() OVERRIDE; + virtual void Close() OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(AppListShelfItemDelegate); diff --git a/ash/shelf/shelf_item_delegate.h b/ash/shelf/shelf_item_delegate.h index 72815cf..6ac81b3 100644 --- a/ash/shelf/shelf_item_delegate.h +++ b/ash/shelf/shelf_item_delegate.h @@ -59,6 +59,10 @@ class ASH_EXPORT ShelfItemDelegate { // Returns true if a tooltip should be shown. virtual bool ShouldShowTooltip() = 0; + + // Closes all windows associated with this item. + virtual void Close() = 0; + }; } // namespace ash diff --git a/ash/shelf/shelf_model.cc b/ash/shelf/shelf_model.cc index d5d83f1..8f4f10f 100644 --- a/ash/shelf/shelf_model.cc +++ b/ash/shelf/shelf_model.cc @@ -26,8 +26,10 @@ int LauncherItemTypeToWeight(LauncherItemType type) { return 1; case TYPE_PLATFORM_APP: return 2; - case TYPE_APP_PANEL: + case TYPE_DIALOG: return 3; + case TYPE_APP_PANEL: + return 4; case TYPE_UNDEFINED: NOTREACHED() << "LauncherItemType must be set"; return -1; @@ -42,8 +44,10 @@ int LauncherItemTypeToWeight(LauncherItemType type) { return 1; case TYPE_APP_LIST: return 2; - case TYPE_APP_PANEL: + case TYPE_DIALOG: return 3; + case TYPE_APP_PANEL: + return 4; case TYPE_UNDEFINED: NOTREACHED() << "LauncherItemType must be set"; return -1; diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index 67988af..4348c98 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -918,6 +918,7 @@ views::View* ShelfView::CreateViewForItem(const LauncherItem& item) { case TYPE_APP_SHORTCUT: case TYPE_WINDOWED_APP: case TYPE_PLATFORM_APP: + case TYPE_DIALOG: case TYPE_APP_PANEL: { ShelfButton* button = ShelfButton::Create(this, this, layout_manager_); button->SetImage(item.image); @@ -1252,6 +1253,7 @@ bool ShelfView::SameDragType(LauncherItemType typea, case TYPE_PLATFORM_APP: case TYPE_WINDOWED_APP: case TYPE_APP_PANEL: + case TYPE_DIALOG: return typeb == typea; case TYPE_UNDEFINED: NOTREACHED() << "LauncherItemType must be set."; @@ -1614,6 +1616,7 @@ void ShelfView::ShelfItemChanged(int model_index, case TYPE_APP_SHORTCUT: case TYPE_WINDOWED_APP: case TYPE_PLATFORM_APP: + case TYPE_DIALOG: case TYPE_APP_PANEL: { ShelfButton* button = static_cast<ShelfButton*>(view); ReflectItemStatus(item, button); @@ -1788,6 +1791,7 @@ void ShelfView::ButtonPressed(views::Button* sender, const ui::Event& event) { break; case TYPE_APP_PANEL: + case TYPE_DIALOG: break; case TYPE_UNDEFINED: diff --git a/ash/shelf/shelf_window_watcher.cc b/ash/shelf/shelf_window_watcher.cc index 9766f54..18a4408 100644 --- a/ash/shelf/shelf_window_watcher.cc +++ b/ash/shelf/shelf_window_watcher.cc @@ -91,7 +91,7 @@ void ShelfWindowWatcher::AddLauncherItem(aura::Window* window) { SetShelfItemDetailsForLauncherItem(&item, *item_details); SetLauncherIDForWindow(id, window); scoped_ptr<ShelfItemDelegate> item_delegate( - new ShelfWindowWatcherItemDelegate(window)); + new ShelfWindowWatcherItemDelegate(window, model_)); // |item_delegate| is owned by |item_delegate_manager_|. item_delegate_manager_->SetShelfItemDelegate(id, item_delegate.Pass()); model_->Add(item); diff --git a/ash/shelf/shelf_window_watcher_item_delegate.cc b/ash/shelf/shelf_window_watcher_item_delegate.cc index 6c7cc65..53fd100 100644 --- a/ash/shelf/shelf_window_watcher_item_delegate.cc +++ b/ash/shelf/shelf_window_watcher_item_delegate.cc @@ -4,7 +4,10 @@ #include "ash/shelf/shelf_window_watcher_item_delegate.h" +#include "ash/shelf/shelf_model.h" #include "ash/shelf/shelf_util.h" +#include "ash/shell.h" +#include "ash/shell_delegate.h" #include "ash/wm/window_state.h" #include "ui/aura/window.h" #include "ui/views/corewm/window_animations.h" @@ -14,8 +17,9 @@ namespace ash { namespace internal { ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate( - aura::Window* window) - : window_(window) { + aura::Window* window, ShelfModel* model) + : window_(window), + model_(model) { } ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() { @@ -47,8 +51,11 @@ base::string16 ShelfWindowWatcherItemDelegate::GetTitle() { ui::MenuModel* ShelfWindowWatcherItemDelegate::CreateContextMenu( aura::Window* root_window) { - // TODO(simonhong): Create ShelfItemContextMenu. - return NULL; + ash::LauncherItem item = + *(model_->ItemByID(GetLauncherIDForWindow(window_))); + return Shell::GetInstance()->delegate()->CreateContextMenu(root_window, + this, + &item); } ShelfMenuModel* ShelfWindowWatcherItemDelegate::CreateApplicationMenu( diff --git a/ash/shelf/shelf_window_watcher_item_delegate.h b/ash/shelf/shelf_window_watcher_item_delegate.h index 2472311..7a40f63 100644 --- a/ash/shelf/shelf_window_watcher_item_delegate.h +++ b/ash/shelf/shelf_window_watcher_item_delegate.h @@ -14,18 +14,18 @@ class Window; } namespace ash { + +class ShelfModel; + namespace internal { // ShelfItemDelegate for the items created by ShelfWindowWatcher. class ShelfWindowWatcherItemDelegate : public ShelfItemDelegate { public: - explicit ShelfWindowWatcherItemDelegate(aura::Window* window); + ShelfWindowWatcherItemDelegate(aura::Window* window, ShelfModel* model_); virtual ~ShelfWindowWatcherItemDelegate(); - // Closes the window associated with this item. - void Close(); - private: // ShelfItemDelegate overrides: virtual bool ItemSelected(const ui::Event& event) OVERRIDE; @@ -34,10 +34,14 @@ class ShelfWindowWatcherItemDelegate : public ShelfItemDelegate { virtual ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE; virtual bool IsDraggable() OVERRIDE; virtual bool ShouldShowTooltip() OVERRIDE; + virtual void Close() OVERRIDE; // Stores a Window associated with this item. Not owned. aura::Window* window_; + // Not owned. + ShelfModel* model_; + DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcherItemDelegate); }; diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index ab41a4c..20e8fde 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc @@ -158,7 +158,10 @@ aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() { return NULL; } -ui::MenuModel* ShellDelegateImpl::CreateContextMenu(aura::Window* root) { +ui::MenuModel* ShellDelegateImpl::CreateContextMenu( + aura::Window* root, + ash::ShelfItemDelegate* item_delegate, + ash::LauncherItem* item) { return new ContextMenu(root); } diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h index 7a1e98e..bea08e3 100644 --- a/ash/shell/shell_delegate_impl.h +++ b/ash/shell/shell_delegate_impl.h @@ -55,7 +55,9 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual ui::MenuModel* CreateContextMenu( - aura::Window* root_window) OVERRIDE; + aura::Window* root_window, + ash::ShelfItemDelegate* item_delegate, + ash::LauncherItem* item) OVERRIDE; virtual WindowTreeHostFactory* CreateWindowTreeHostFactory() OVERRIDE; virtual base::string16 GetProductName() const OVERRIDE; diff --git a/ash/shell/window_watcher_shelf_item_delegate.cc b/ash/shell/window_watcher_shelf_item_delegate.cc index fd8be8e..1c665d6 100644 --- a/ash/shell/window_watcher_shelf_item_delegate.cc +++ b/ash/shell/window_watcher_shelf_item_delegate.cc @@ -53,5 +53,8 @@ bool WindowWatcherShelfItemDelegate::ShouldShowTooltip() { return true; } +void WindowWatcherShelfItemDelegate::Close() { +} + } // namespace shell } // namespace ash diff --git a/ash/shell/window_watcher_shelf_item_delegate.h b/ash/shell/window_watcher_shelf_item_delegate.h index cf8f6a7..a77698c 100644 --- a/ash/shell/window_watcher_shelf_item_delegate.h +++ b/ash/shell/window_watcher_shelf_item_delegate.h @@ -28,6 +28,7 @@ class WindowWatcherShelfItemDelegate : public ShelfItemDelegate { virtual ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE; virtual bool IsDraggable() OVERRIDE; virtual bool ShouldShowTooltip() OVERRIDE; + virtual void Close() OVERRIDE; private: LauncherID id_; diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index fecb655..452c420 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h @@ -49,6 +49,7 @@ class NewWindowDelegate; class WindowTreeHostFactory; class SessionStateDelegate; class ShelfDelegate; +class ShelfItemDelegate; class ShelfModel; class SystemTrayDelegate; class UserWallpaperDelegate; @@ -126,7 +127,12 @@ class ASH_EXPORT ShellDelegate { virtual aura::client::UserActionClient* CreateUserActionClient() = 0; // Creates a menu model of the context for the |root_window|. - virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) = 0; + // When a ContextMenu is used for an item created by ShelfWindowWatcher, + // passes its ShelfItemDelegate and LauncherItem. + virtual ui::MenuModel* CreateContextMenu( + aura::Window* root_window, + ash::ShelfItemDelegate* item_delegate, + ash::LauncherItem* item) = 0; // Creates a root window host factory. Shell takes ownership of the returned // value. diff --git a/ash/test/test_shelf_item_delegate.cc b/ash/test/test_shelf_item_delegate.cc index ed87531..e8f4780 100644 --- a/ash/test/test_shelf_item_delegate.cc +++ b/ash/test/test_shelf_item_delegate.cc @@ -48,5 +48,8 @@ bool TestShelfItemDelegate::ShouldShowTooltip() { return true; } +void TestShelfItemDelegate::Close() { +} + } // namespace test } // namespace ash diff --git a/ash/test/test_shelf_item_delegate.h b/ash/test/test_shelf_item_delegate.h index af8a26a..fcff772 100644 --- a/ash/test/test_shelf_item_delegate.h +++ b/ash/test/test_shelf_item_delegate.h @@ -29,6 +29,7 @@ class TestShelfItemDelegate : public ShelfItemDelegate { virtual ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE; virtual bool IsDraggable() OVERRIDE; virtual bool ShouldShowTooltip() OVERRIDE; + virtual void Close() OVERRIDE; private: aura::Window* window_; diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index c89487a..bc9ebcf 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -139,7 +139,10 @@ aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { return NULL; } -ui::MenuModel* TestShellDelegate::CreateContextMenu(aura::Window* root) { +ui::MenuModel* TestShellDelegate::CreateContextMenu( + aura::Window* root, + ash::ShelfItemDelegate* item_delegate, + ash::LauncherItem* item) { return NULL; } diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h index 11445ee..93462f2 100644 --- a/ash/test/test_shell_delegate.h +++ b/ash/test/test_shell_delegate.h @@ -50,7 +50,10 @@ class TestShellDelegate : public ShellDelegate { virtual NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual MediaDelegate* CreateMediaDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; - virtual ui::MenuModel* CreateContextMenu(aura::Window* root) OVERRIDE; + virtual ui::MenuModel* CreateContextMenu( + aura::Window* root, + ash::ShelfItemDelegate* item_delegate, + ash::LauncherItem* item) OVERRIDE; virtual WindowTreeHostFactory* CreateWindowTreeHostFactory() OVERRIDE; virtual base::string16 GetProductName() const OVERRIDE; diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc index a3d8878..497c973c 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc @@ -127,12 +127,18 @@ aura::client::UserActionClient* ChromeShellDelegate::CreateUserActionClient() { return new UserActionHandler; } -ui::MenuModel* ChromeShellDelegate::CreateContextMenu(aura::Window* root) { +ui::MenuModel* ChromeShellDelegate::CreateContextMenu( + aura::Window* root, + ash::ShelfItemDelegate* item_delegate, + ash::LauncherItem* item) { DCHECK(shelf_delegate_); // Don't show context menu for exclusive app runtime mode. if (chrome::IsRunningInAppMode()) return NULL; + if (item_delegate && item) + return new LauncherContextMenu(shelf_delegate_, item_delegate, item, root); + return new LauncherContextMenu(shelf_delegate_, root); } diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h index 72edd56..344965d 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.h +++ b/chrome/browser/ui/ash/chrome_shell_delegate.h @@ -17,6 +17,10 @@ class Browser; +namespace ash { +class ShelfItemDelegate; +} + namespace content { class WebContents; } @@ -57,7 +61,10 @@ class ChromeShellDelegate : public ash::ShellDelegate, virtual ash::NewWindowDelegate* CreateNewWindowDelegate() OVERRIDE; virtual ash::MediaDelegate* CreateMediaDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; - virtual ui::MenuModel* CreateContextMenu(aura::Window* root) OVERRIDE; + virtual ui::MenuModel* CreateContextMenu( + aura::Window* root, + ash::ShelfItemDelegate* item_delegate, + ash::LauncherItem* item) OVERRIDE; virtual ash::WindowTreeHostFactory* CreateWindowTreeHostFactory() OVERRIDE; virtual base::string16 GetProductName() const OVERRIDE; diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h index e614c39..38b652b 100644 --- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h +++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h @@ -40,7 +40,6 @@ class AppShortcutLauncherItemController : public LauncherItemController { virtual bool IsVisible() const OVERRIDE; virtual void Launch(ash::LaunchSource source, int event_flags) OVERRIDE; virtual bool Activate(ash::LaunchSource source) OVERRIDE; - virtual void Close() OVERRIDE; virtual ChromeLauncherAppMenuItems GetApplicationList( int event_flags) OVERRIDE; virtual bool ItemSelected(const ui::Event& event) OVERRIDE; @@ -50,6 +49,7 @@ class AppShortcutLauncherItemController : public LauncherItemController { virtual ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE; virtual bool IsDraggable() OVERRIDE; virtual bool ShouldShowTooltip() OVERRIDE; + virtual void Close() OVERRIDE; // Get the refocus url pattern, which can be used to identify this application // from a URL link. diff --git a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.h b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.h index 69fff4a..74791201 100644 --- a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.h +++ b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.h @@ -34,7 +34,6 @@ class BrowserShortcutLauncherItemController : public LauncherItemController { virtual bool IsVisible() const OVERRIDE; virtual void Launch(ash::LaunchSource source, int event_flags) OVERRIDE; virtual bool Activate(ash::LaunchSource source) OVERRIDE; - virtual void Close() OVERRIDE; virtual ChromeLauncherAppMenuItems GetApplicationList( int event_flags) OVERRIDE; virtual bool ItemSelected(const ui::Event& event) OVERRIDE; @@ -44,6 +43,7 @@ class BrowserShortcutLauncherItemController : public LauncherItemController { virtual ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE; virtual bool IsDraggable() OVERRIDE; virtual bool ShouldShowTooltip() OVERRIDE; + virtual void Close() OVERRIDE; private: // Get the favicon for the browser list entry for |web_contents|. diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc index 80c4d7f..c85c0ad 100644 --- a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc +++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc @@ -9,6 +9,7 @@ #include "ash/desktop_background/user_wallpaper_delegate.h" #include "ash/metrics/user_metrics_recorder.h" #include "ash/root_window_controller.h" +#include "ash/shelf/shelf_item_delegate.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "base/bind.h" @@ -42,7 +43,24 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, controller_(controller), item_(*item), shelf_alignment_menu_(root), - root_window_(root) { + root_window_(root), + item_delegate_(NULL) { + DCHECK(item); + DCHECK(root_window_); + Init(); +} + +LauncherContextMenu::LauncherContextMenu( + ChromeLauncherController* controller, + ash::ShelfItemDelegate* item_delegate, + ash::LauncherItem* item, + aura::Window* root) + : ui::SimpleMenuModel(NULL), + controller_(controller), + item_(*item), + shelf_alignment_menu_(root), + root_window_(root), + item_delegate_(item_delegate) { DCHECK(item); DCHECK(root_window_); Init(); @@ -57,7 +75,8 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, extension_items_(new extensions::ContextMenuMatcher( controller->profile(), this, this, base::Bind(MenuItemHasLauncherContext))), - root_window_(root) { + root_window_(root), + item_delegate_(NULL) { DCHECK(root_window_); Init(); } @@ -120,6 +139,9 @@ void LauncherContextMenu::Init() { AddItem(MENU_NEW_INCOGNITO_WINDOW, l10n_util::GetStringUTF16(IDS_LAUNCHER_NEW_INCOGNITO_WINDOW)); } + } else if (item_.type == ash::TYPE_DIALOG) { + AddItem(MENU_CLOSE, + l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); } else { if (item_.type == ash::TYPE_PLATFORM_APP) { AddItem( @@ -246,7 +268,13 @@ void LauncherContextMenu::ExecuteCommand(int command_id, int event_flags) { controller_->Launch(item_.id, ui::EF_NONE); break; case MENU_CLOSE: - controller_->Close(item_.id); + if (item_.type == ash::TYPE_DIALOG) { + DCHECK(item_delegate_); + item_delegate_->Close(); + } else { + // TODO(simonhong): Use ShelfItemDelegate::Close(). + controller_->Close(item_.id); + } ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( ash::UMA_CLOSE_THROUGH_CONTEXT_MENU); break; diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu.h b/chrome/browser/ui/ash/launcher/launcher_context_menu.h index bf73f1f..a3e4ece 100644 --- a/chrome/browser/ui/ash/launcher/launcher_context_menu.h +++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.h @@ -14,6 +14,10 @@ class ChromeLauncherController; +namespace ash { +class ShelfItemDelegate; +} + namespace aura { class Window; } @@ -31,6 +35,13 @@ class LauncherContextMenu : public ui::SimpleMenuModel, LauncherContextMenu(ChromeLauncherController* controller, const ash::LauncherItem* item, aura::Window* root_window); + + // Creates a menu used by item created by ShelfWindowWatcher. + LauncherContextMenu(ChromeLauncherController* controller, + ash::ShelfItemDelegate* item_delegate, + ash::LauncherItem* item, + aura::Window* root_window); + // Creates a menu used as a desktop context menu on |root_window|. LauncherContextMenu(ChromeLauncherController* controller, aura::Window* root_window); @@ -90,6 +101,9 @@ class LauncherContextMenu : public ui::SimpleMenuModel, aura::Window* root_window_; + // Not owned. + ash::ShelfItemDelegate* item_delegate_; + DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu); }; diff --git a/chrome/browser/ui/ash/launcher/launcher_item_controller.h b/chrome/browser/ui/ash/launcher/launcher_item_controller.h index 633440f..9ed78c1 100644 --- a/chrome/browser/ui/ash/launcher/launcher_item_controller.h +++ b/chrome/browser/ui/ash/launcher/launcher_item_controller.h @@ -78,9 +78,6 @@ class LauncherItemController : public ash::ShelfItemDelegate { // Returns true when a new item got created. virtual bool Activate(ash::LaunchSource source) = 0; - // Closes all windows associated with this item. - virtual void Close() = 0; - // Called to retrieve the list of running applications. virtual ChromeLauncherAppMenuItems GetApplicationList(int event_flags) = 0; diff --git a/chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h b/chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h index b3bdf04..d4ce1194 100644 --- a/chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h +++ b/chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h @@ -59,7 +59,6 @@ class ShellWindowLauncherItemController : public LauncherItemController, virtual bool IsVisible() const OVERRIDE; virtual void Launch(ash::LaunchSource source, int event_flags) OVERRIDE; virtual bool Activate(ash::LaunchSource source) OVERRIDE; - virtual void Close() OVERRIDE; virtual ChromeLauncherAppMenuItems GetApplicationList( int event_flags) OVERRIDE; virtual bool ItemSelected(const ui::Event& eent) OVERRIDE; @@ -68,6 +67,7 @@ class ShellWindowLauncherItemController : public LauncherItemController, virtual ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE; virtual bool IsDraggable() OVERRIDE; virtual bool ShouldShowTooltip() OVERRIDE; + virtual void Close() OVERRIDE; // aura::WindowObserver overrides: virtual void OnWindowPropertyChanged(aura::Window* window, |