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