| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be | ||||
| 3 | // found in the LICENSE file. | ||||
| 4 | |||||
| 5 | #ifndef UI_AURA_SHELL_SHELL_H_ | ||||
| 6 | #define UI_AURA_SHELL_SHELL_H_ | ||||
| 7 | #pragma once | ||||
| 8 | |||||
| [email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 9 | #include <utility> |
| 10 | #include <vector> | ||||
| 11 | |||||
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 12 | #include "base/basictypes.h" |
| [email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 13 | #include "base/memory/scoped_ptr.h" |
| 14 | #include "base/task.h" | ||||
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 15 | #include "base/compiler_specific.h" |
| [email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 16 | #include "base/memory/weak_ptr.h" |
| [email protected] | 18d23787 | 2011-10-08 02:22:51 | [diff] [blame] | 17 | #include "ui/aura_shell/aura_shell_export.h" |
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 18 | |
| 19 | namespace aura { | ||||
| [email protected] | e29014c | 2011-11-16 18:25:51 | [diff] [blame^] | 20 | class EventFilter; |
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 21 | class Window; |
| 22 | } | ||||
| [email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 23 | namespace gfx { |
| [email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 24 | class Rect; |
| 25 | } | ||||
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 26 | |
| 27 | namespace aura_shell { | ||||
| 28 | |||||
| [email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 29 | class Launcher; |
| [email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 30 | class ShellDelegate; |
| [email protected] | 60fa9bba | 2011-10-28 21:21:51 | [diff] [blame] | 31 | |
| 32 | namespace internal { | ||||
| [email protected] | ae18b911 | 2011-11-07 16:59:13 | [diff] [blame] | 33 | class ShelfLayoutController; |
| [email protected] | 60fa9bba | 2011-10-28 21:21:51 | [diff] [blame] | 34 | class WorkspaceController; |
| 35 | } | ||||
| [email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 36 | |
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 37 | // Shell is a singleton object that presents the Shell API and implements the |
| 38 | // Desktop's delegate interface. | ||||
| [email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 39 | class AURA_SHELL_EXPORT Shell { |
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 40 | public: |
| 41 | // Upon creation, the Shell sets itself as the Desktop's delegate, which takes | ||||
| 42 | // ownership of the Shell. | ||||
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 43 | |
| [email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 44 | // A shell must be explicitly created so that it can call |Init()| with the |
| 45 | // delegate set. |delegate| can be NULL (if not required for initialization). | ||||
| 46 | static Shell* CreateInstance(ShellDelegate* delegate); | ||||
| 47 | |||||
| 48 | // Should never be called before |CreateInstance()|. | ||||
| [email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 49 | static Shell* GetInstance(); |
| [email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 50 | |
| [email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 51 | static void DeleteInstanceForTesting(); |
| [email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 52 | |
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 53 | aura::Window* GetContainer(int container_id); |
| 54 | const aura::Window* GetContainer(int container_id) const; | ||||
| 55 | |||||
| [email protected] | e29014c | 2011-11-16 18:25:51 | [diff] [blame^] | 56 | // Adds or removes |filter| from the DesktopEventFilter. |
| 57 | void AddDesktopEventFilter(aura::EventFilter* filter); | ||||
| 58 | void RemoveDesktopEventFilter(aura::EventFilter* filter); | ||||
| 59 | |||||
| [email protected] | ca4ed12 | 2011-10-26 05:40:01 | [diff] [blame] | 60 | // Toggles between overview mode and normal mode. |
| 61 | void ToggleOverview(); | ||||
| [email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 62 | |
| [email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 63 | ShellDelegate* delegate() { return delegate_.get(); } |
| [email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 64 | Launcher* launcher() { return launcher_.get(); } |
| 65 | |||||
| [email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 66 | private: |
| 67 | typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; | ||||
| 68 | |||||
| [email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 69 | explicit Shell(ShellDelegate* delegate); |
| 70 | virtual ~Shell(); | ||||
| 71 | |||||
| 72 | void Init(); | ||||
| 73 | |||||
| [email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 74 | // Enables WorkspaceManager. |
| 75 | void EnableWorkspaceManager(); | ||||
| 76 | |||||
| [email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 77 | static Shell* instance_; |
| 78 | |||||
| 79 | std::vector<WindowAndBoundsPair> to_restore_; | ||||
| 80 | |||||
| [email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 81 | base::WeakPtrFactory<Shell> method_factory_; |
| [email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 82 | |
| [email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 83 | scoped_ptr<ShellDelegate> delegate_; |
| 84 | |||||
| [email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 85 | scoped_ptr<Launcher> launcher_; |
| 86 | |||||
| [email protected] | 60fa9bba | 2011-10-28 21:21:51 | [diff] [blame] | 87 | scoped_ptr<internal::WorkspaceController> workspace_controller_; |
| [email protected] | ae18b911 | 2011-11-07 16:59:13 | [diff] [blame] | 88 | scoped_ptr<internal::ShelfLayoutController> shelf_layout_controller_; |
| 89 | |||||
| [email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 90 | DISALLOW_COPY_AND_ASSIGN(Shell); |
| 91 | }; | ||||
| 92 | |||||
| 93 | } // namespace aura_shell | ||||
| 94 | |||||
| 95 | #endif // UI_AURA_SHELL_SHELL_H_ | ||||