[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] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 30 | class ShellAcceleratorController; |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 31 | class ShellDelegate; |
[email protected] | 4a229e90 | 2011-12-01 21:21:11 | [diff] [blame] | 32 | class ShellTooltipManager; |
[email protected] | 60fa9bba | 2011-10-28 21:21:51 | [diff] [blame] | 33 | |
34 | namespace internal { | ||||
[email protected] | 9fc206d | 2011-12-13 00:05:33 | [diff] [blame^] | 35 | class ActivationController; |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 36 | class AppList; |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 37 | class DragDropController; |
[email protected] | a54e65b | 2011-11-21 22:03:34 | [diff] [blame] | 38 | class ShadowController; |
[email protected] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 39 | class ShellAcceleratorFilter; |
[email protected] | 60fa9bba | 2011-10-28 21:21:51 | [diff] [blame] | 40 | class WorkspaceController; |
41 | } | ||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 42 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 43 | // Shell is a singleton object that presents the Shell API and implements the |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 44 | // RootWindow's delegate interface. |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 45 | class AURA_SHELL_EXPORT Shell { |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 46 | public: |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 47 | // Upon creation, the Shell sets itself as the RootWindow's delegate, which |
48 | // takes ownership of the Shell. | ||||
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 49 | |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 50 | // A shell must be explicitly created so that it can call |Init()| with the |
51 | // delegate set. |delegate| can be NULL (if not required for initialization). | ||||
52 | static Shell* CreateInstance(ShellDelegate* delegate); | ||||
53 | |||||
54 | // Should never be called before |CreateInstance()|. | ||||
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 55 | static Shell* GetInstance(); |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 56 | |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 57 | static void DeleteInstance(); |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 58 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 59 | aura::Window* GetContainer(int container_id); |
60 | const aura::Window* GetContainer(int container_id) const; | ||||
61 | |||||
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 62 | // Adds or removes |filter| from the RootWindowEventFilter. |
63 | void AddRootWindowEventFilter(aura::EventFilter* filter); | ||||
64 | void RemoveRootWindowEventFilter(aura::EventFilter* filter); | ||||
[email protected] | e29014c | 2011-11-16 18:25:51 | [diff] [blame] | 65 | |
[email protected] | ca4ed12 | 2011-10-26 05:40:01 | [diff] [blame] | 66 | // Toggles between overview mode and normal mode. |
67 | void ToggleOverview(); | ||||
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 68 | |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 69 | // Toggles app list. |
70 | void ToggleAppList(); | ||||
71 | |||||
[email protected] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 72 | ShellAcceleratorController* accelerator_controller() { |
73 | return accelerator_controller_.get(); | ||||
74 | } | ||||
75 | |||||
[email protected] | 4a229e90 | 2011-12-01 21:21:11 | [diff] [blame] | 76 | ShellTooltipManager* tooltip_manager() { |
77 | return tooltip_manager_.get(); | ||||
78 | } | ||||
79 | |||||
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 80 | ShellDelegate* delegate() { return delegate_.get(); } |
[email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 81 | Launcher* launcher() { return launcher_.get(); } |
82 | |||||
[email protected] | a54e65b | 2011-11-21 22:03:34 | [diff] [blame] | 83 | // Made available for tests. |
84 | internal::ShadowController* shadow_controller() { | ||||
85 | return shadow_controller_.get(); | ||||
86 | } | ||||
87 | |||||
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 88 | private: |
89 | typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; | ||||
90 | |||||
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 91 | explicit Shell(ShellDelegate* delegate); |
92 | virtual ~Shell(); | ||||
93 | |||||
94 | void Init(); | ||||
95 | |||||
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 96 | // Enables WorkspaceManager. |
97 | void EnableWorkspaceManager(); | ||||
98 | |||||
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 99 | static Shell* instance_; |
100 | |||||
101 | std::vector<WindowAndBoundsPair> to_restore_; | ||||
102 | |||||
[email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 103 | base::WeakPtrFactory<Shell> method_factory_; |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 104 | |
[email protected] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 105 | scoped_ptr<ShellAcceleratorController> accelerator_controller_; |
106 | |||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 107 | scoped_ptr<ShellDelegate> delegate_; |
108 | |||||
[email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 109 | scoped_ptr<Launcher> launcher_; |
110 | |||||
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 111 | scoped_ptr<internal::AppList> app_list_; |
112 | |||||
[email protected] | 9fc206d | 2011-12-13 00:05:33 | [diff] [blame^] | 113 | scoped_ptr<internal::ActivationController> activation_controller_; |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 114 | scoped_ptr<internal::DragDropController> drag_drop_controller_; |
[email protected] | 60fa9bba | 2011-10-28 21:21:51 | [diff] [blame] | 115 | scoped_ptr<internal::WorkspaceController> workspace_controller_; |
[email protected] | a54e65b | 2011-11-21 22:03:34 | [diff] [blame] | 116 | scoped_ptr<internal::ShadowController> shadow_controller_; |
[email protected] | ae18b911 | 2011-11-07 16:59:13 | [diff] [blame] | 117 | |
[email protected] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 118 | // An event filter that pre-handles global accelerators. |
119 | scoped_ptr<internal::ShellAcceleratorFilter> accelerator_filter_; | ||||
120 | |||||
[email protected] | 4a229e90 | 2011-12-01 21:21:11 | [diff] [blame] | 121 | scoped_ptr<ShellTooltipManager> tooltip_manager_; |
122 | |||||
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 123 | DISALLOW_COPY_AND_ASSIGN(Shell); |
124 | }; | ||||
125 | |||||
126 | } // namespace aura_shell | ||||
127 | |||||
128 | #endif // UI_AURA_SHELL_SHELL_H_ |