summaryrefslogtreecommitdiffstats
path: root/ash/shell/shell_main.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-16 03:01:31 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-16 03:01:31 +0000
commit16f2d3fc202e6950aa1bd145d9f71106fa779e49 (patch)
treef45e74cb6c5cf8f288c300d6c7b9fe530f627d93 /ash/shell/shell_main.cc
parentc39c9229daf3995a6d1cec55ae1f89021fd4eb66 (diff)
downloadchromium_src-16f2d3fc202e6950aa1bd145d9f71106fa779e49.zip
chromium_src-16f2d3fc202e6950aa1bd145d9f71106fa779e49.tar.gz
chromium_src-16f2d3fc202e6950aa1bd145d9f71106fa779e49.tar.bz2
Refactors launcher related ShellDelegate methods into standalone
class. BUG=none TEST=none R=ben@chromium.org Review URL: http://codereview.chromium.org/9403002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shell/shell_main.cc')
-rw-r--r--ash/shell/shell_main.cc53
1 files changed, 35 insertions, 18 deletions
diff --git a/ash/shell/shell_main.cc b/ash/shell/shell_main.cc
index e6a1efa..4dc19b3 100644
--- a/ash/shell/shell_main.cc
+++ b/ash/shell/shell_main.cc
@@ -5,6 +5,7 @@
#include <map>
#include "ash/launcher/launcher.h"
+#include "ash/launcher/launcher_delegate.h"
#include "ash/launcher/launcher_model.h"
#include "ash/launcher/launcher_types.h"
#include "ash/shell.h"
@@ -110,12 +111,13 @@ class WindowWatcher : public aura::WindowObserver {
DISALLOW_COPY_AND_ASSIGN(WindowWatcher);
};
-class ShellDelegateImpl : public ash::ShellDelegate {
+class LauncherDelegateImpl : public ash::LauncherDelegate {
public:
- ShellDelegateImpl() {}
-
- void set_watcher(WindowWatcher* watcher) { watcher_ = watcher; }
+ explicit LauncherDelegateImpl(WindowWatcher* watcher)
+ : watcher_(watcher) {
+ }
+ // LauncherDelegate overrides:
virtual void CreateNewWindow() OVERRIDE {
ash::shell::ToplevelWindow::CreateParams create_params;
create_params.can_resize = true;
@@ -123,6 +125,33 @@ class ShellDelegateImpl : public ash::ShellDelegate {
ash::shell::ToplevelWindow::CreateToplevelWindow(create_params);
}
+ virtual void ItemClicked(const ash::LauncherItem& item) OVERRIDE {
+ aura::Window* window = watcher_->GetWindowByID(item.id);
+ window->Show();
+ ash::ActivateWindow(window);
+ }
+
+ virtual int GetBrowserShortcutResourceId() OVERRIDE {
+ return IDR_AURA_LAUNCHER_BROWSER_SHORTCUT;
+ }
+
+ virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE {
+ return watcher_->GetWindowByID(item.id)->title();
+ }
+
+ private:
+ // Used to update Launcher. Owned by main.
+ WindowWatcher* watcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(LauncherDelegateImpl);
+};
+
+class ShellDelegateImpl : public ash::ShellDelegate {
+ public:
+ ShellDelegateImpl() {}
+
+ void set_watcher(WindowWatcher* watcher) { watcher_ = watcher; }
+
virtual views::Widget* CreateStatusArea() OVERRIDE {
return ash::internal::CreateStatusArea();
}
@@ -156,20 +185,8 @@ class ShellDelegateImpl : public ash::ShellDelegate {
return windows;
}
- virtual void LauncherItemClicked(
- const ash::LauncherItem& item) OVERRIDE {
- aura::Window* window = watcher_->GetWindowByID(item.id);
- window->Show();
- ash::ActivateWindow(window);
- }
-
- virtual int GetBrowserShortcutResourceId() OVERRIDE {
- return IDR_AURA_LAUNCHER_BROWSER_SHORTCUT;
- }
-
- virtual string16 GetLauncherItemTitle(
- const ash::LauncherItem& item) OVERRIDE {
- return watcher_->GetWindowByID(item.id)->title();
+ virtual ash::LauncherDelegate* CreateLauncherDelegate() OVERRIDE {
+ return new LauncherDelegateImpl(watcher_);
}
private: