diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-14 00:06:08 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-14 00:06:08 +0000 |
commit | 3266c2b9cc63c1a4533f8e99cb535f30e67e5499 (patch) | |
tree | 58e0ab9c7259a575f2d4abd8da7bda731b0f14b3 /ui/aura_shell | |
parent | f6231b17e8a950570602ed4b6e99d08f8f9f85f6 (diff) | |
download | chromium_src-3266c2b9cc63c1a4533f8e99cb535f30e67e5499.zip chromium_src-3266c2b9cc63c1a4533f8e99cb535f30e67e5499.tar.gz chromium_src-3266c2b9cc63c1a4533f8e99cb535f30e67e5499.tar.bz2 |
Add status area to Aura builds.
BUG=97263
TEST=Test status area buttons and associated menus in aura + win / linux / chromeos. (Only the clock and --memory-widget icon will show up on non-chromeos)
Review URL: http://codereview.chromium.org/8509027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura_shell')
-rw-r--r-- | ui/aura_shell/examples/aura_shell_main.cc | 7 | ||||
-rw-r--r-- | ui/aura_shell/shell.cc | 31 | ||||
-rw-r--r-- | ui/aura_shell/shell.h | 20 | ||||
-rw-r--r-- | ui/aura_shell/shell_delegate.h | 7 | ||||
-rw-r--r-- | ui/aura_shell/stacking_controller_unittest.cc | 2 |
5 files changed, 45 insertions, 22 deletions
diff --git a/ui/aura_shell/examples/aura_shell_main.cc b/ui/aura_shell/examples/aura_shell_main.cc index 414bcdd..20a3623 100644 --- a/ui/aura_shell/examples/aura_shell_main.cc +++ b/ui/aura_shell/examples/aura_shell_main.cc @@ -31,6 +31,10 @@ class ShellDelegateImpl : public aura_shell::ShellDelegate { aura_shell::examples::ToplevelWindow::CreateToplevelWindow(create_params); } + virtual views::Widget* CreateStatusArea() OVERRIDE { + return aura_shell::internal::CreateStatusArea(); + } + virtual void ShowApps() OVERRIDE { NOTIMPLEMENTED(); } @@ -72,7 +76,7 @@ int main(int argc, char** argv) { MessageLoop message_loop(MessageLoop::TYPE_UI); ui::CompositorTestSupport::Initialize(); - aura_shell::Shell::GetInstance()->SetDelegate(new ShellDelegateImpl);; + aura_shell::Shell::CreateInstance(new ShellDelegateImpl); aura_shell::examples::InitWindowTypeLauncher(); @@ -84,4 +88,3 @@ int main(int argc, char** argv) { return 0; } - diff --git a/ui/aura_shell/shell.cc b/ui/aura_shell/shell.cc index a9d9c81..c16b63c 100644 --- a/ui/aura_shell/shell.cc +++ b/ui/aura_shell/shell.cc @@ -82,8 +82,9 @@ Shell* Shell::instance_ = NULL; //////////////////////////////////////////////////////////////////////////////// // Shell, public: -Shell::Shell() - : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { +Shell::Shell(ShellDelegate* delegate) + : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), + delegate_(delegate) { aura::Desktop::GetInstance()->SetEventFilter( new internal::DesktopEventFilter); aura::Desktop::GetInstance()->SetStackingClient( @@ -97,11 +98,16 @@ Shell::~Shell() { } // static +Shell* Shell::CreateInstance(ShellDelegate* delegate) { + CHECK(!instance_); + instance_ = new Shell(delegate); + instance_->Init(); + return instance_; +} + +// static Shell* Shell::GetInstance() { - if (!instance_) { - instance_ = new Shell; - instance_->Init(); - } + DCHECK(instance_); return instance_; } @@ -133,8 +139,15 @@ void Shell::Init() { GetContainer(internal::kShellWindowId_DefaultContainer); launcher_.reset(new Launcher(default_container)); + views::Widget* status_widget = NULL; + if (delegate_.get()) + status_widget = delegate_->CreateStatusArea(); + if (!status_widget) + status_widget = internal::CreateStatusArea(); + shelf_layout_controller_.reset(new internal::ShelfLayoutController( - launcher_->widget(), internal::CreateStatusArea())); + launcher_->widget(), status_widget)); + desktop_layout->set_shelf(shelf_layout_controller_.get()); if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAuraWindows)) { @@ -150,10 +163,6 @@ void Shell::Init() { desktop_layout->OnWindowResized(); } -void Shell::SetDelegate(ShellDelegate* delegate) { - delegate_.reset(delegate); -} - aura::Window* Shell::GetContainer(int container_id) { return const_cast<aura::Window*>( const_cast<const aura_shell::Shell*>(this)->GetContainer(container_id)); diff --git a/ui/aura_shell/shell.h b/ui/aura_shell/shell.h index 5abe2b0..1b4c719 100644 --- a/ui/aura_shell/shell.h +++ b/ui/aura_shell/shell.h @@ -39,17 +39,15 @@ class AURA_SHELL_EXPORT Shell { public: // Upon creation, the Shell sets itself as the Desktop's delegate, which takes // ownership of the Shell. - Shell(); - virtual ~Shell(); - static Shell* GetInstance(); - static void DeleteInstanceForTesting(); + // A shell must be explicitly created so that it can call |Init()| with the + // delegate set. |delegate| can be NULL (if not required for initialization). + static Shell* CreateInstance(ShellDelegate* delegate); - void Init(); + // Should never be called before |CreateInstance()|. + static Shell* GetInstance(); - // Sets the delegate. Shell owns its delegate. - void SetDelegate(ShellDelegate* delegate); - ShellDelegate* delegate() { return delegate_.get(); } + static void DeleteInstanceForTesting(); aura::Window* GetContainer(int container_id); const aura::Window* GetContainer(int container_id) const; @@ -57,11 +55,17 @@ class AURA_SHELL_EXPORT Shell { // Toggles between overview mode and normal mode. void ToggleOverview(); + ShellDelegate* delegate() { return delegate_.get(); } Launcher* launcher() { return launcher_.get(); } private: typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; + explicit Shell(ShellDelegate* delegate); + virtual ~Shell(); + + void Init(); + // Enables WorkspaceManager. void EnableWorkspaceManager(); diff --git a/ui/aura_shell/shell_delegate.h b/ui/aura_shell/shell_delegate.h index 1fdb735..b316669 100644 --- a/ui/aura_shell/shell_delegate.h +++ b/ui/aura_shell/shell_delegate.h @@ -8,6 +8,10 @@ #include "ui/aura_shell/aura_shell_export.h" +namespace views { +class Widget; +} + namespace aura_shell { struct LauncherItem; @@ -22,6 +26,9 @@ class AURA_SHELL_EXPORT ShellDelegate { // window. virtual void CreateNewWindow() = 0; + // Invoked to create a new status area. Can return NULL. + virtual views::Widget* CreateStatusArea() = 0; + // Invoked when the user clicks the app list button on the launcher. virtual void ShowApps() = 0; diff --git a/ui/aura_shell/stacking_controller_unittest.cc b/ui/aura_shell/stacking_controller_unittest.cc index a7cd2c9..500c24f 100644 --- a/ui/aura_shell/stacking_controller_unittest.cc +++ b/ui/aura_shell/stacking_controller_unittest.cc @@ -16,7 +16,7 @@ namespace test { typedef aura::test::AuraTestBase StackingControllerTest; TEST_F(StackingControllerTest, GetTopmostWindowToActivate) { - Shell::GetInstance(); + Shell::CreateInstance(NULL); aura::test::ActivateWindowDelegate activate; aura::test::ActivateWindowDelegate non_activate(false); |