summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
Diffstat (limited to 'ash')
-rw-r--r--ash/launcher/launcher_types.h3
-rw-r--r--ash/root_window_controller.cc4
-rw-r--r--ash/shelf/app_list_shelf_item_delegate.cc7
-rw-r--r--ash/shelf/app_list_shelf_item_delegate.h1
-rw-r--r--ash/shelf/shelf_item_delegate.h4
-rw-r--r--ash/shelf/shelf_model.cc8
-rw-r--r--ash/shelf/shelf_view.cc4
-rw-r--r--ash/shelf/shelf_window_watcher.cc2
-rw-r--r--ash/shelf/shelf_window_watcher_item_delegate.cc15
-rw-r--r--ash/shelf/shelf_window_watcher_item_delegate.h12
-rw-r--r--ash/shell/shell_delegate_impl.cc5
-rw-r--r--ash/shell/shell_delegate_impl.h4
-rw-r--r--ash/shell/window_watcher_shelf_item_delegate.cc3
-rw-r--r--ash/shell/window_watcher_shelf_item_delegate.h1
-rw-r--r--ash/shell_delegate.h8
-rw-r--r--ash/test/test_shelf_item_delegate.cc3
-rw-r--r--ash/test/test_shelf_item_delegate.h1
-rw-r--r--ash/test/test_shell_delegate.cc5
-rw-r--r--ash/test/test_shell_delegate.h5
19 files changed, 77 insertions, 18 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;