OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_AURA_SHELL_SHELL_H_ | 5 #ifndef UI_AURA_SHELL_SHELL_H_ |
6 #define UI_AURA_SHELL_SHELL_H_ | 6 #define UI_AURA_SHELL_SHELL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 22 matching lines...) Expand all Loading... |
33 class ShelfLayoutController; | 33 class ShelfLayoutController; |
34 class WorkspaceController; | 34 class WorkspaceController; |
35 } | 35 } |
36 | 36 |
37 // Shell is a singleton object that presents the Shell API and implements the | 37 // Shell is a singleton object that presents the Shell API and implements the |
38 // Desktop's delegate interface. | 38 // Desktop's delegate interface. |
39 class AURA_SHELL_EXPORT Shell : public aura::StackingClient { | 39 class AURA_SHELL_EXPORT Shell : public aura::StackingClient { |
40 public: | 40 public: |
41 // Upon creation, the Shell sets itself as the Desktop's delegate, which takes | 41 // Upon creation, the Shell sets itself as the Desktop's delegate, which takes |
42 // ownership of the Shell. | 42 // ownership of the Shell. |
43 Shell(); | |
44 virtual ~Shell(); | |
45 | 43 |
| 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()|. |
46 static Shell* GetInstance(); | 49 static Shell* GetInstance(); |
47 | 50 |
48 void Init(); | |
49 | |
50 // Sets the delegate. Shell owns its delegate. | |
51 void SetDelegate(ShellDelegate* delegate); | |
52 ShellDelegate* delegate() { return delegate_.get(); } | |
53 | |
54 aura::Window* GetContainer(int container_id); | 51 aura::Window* GetContainer(int container_id); |
55 const aura::Window* GetContainer(int container_id) const; | 52 const aura::Window* GetContainer(int container_id) const; |
56 | 53 |
57 // Toggles between overview mode and normal mode. | 54 // Toggles between overview mode and normal mode. |
58 void ToggleOverview(); | 55 void ToggleOverview(); |
59 | 56 |
| 57 ShellDelegate* delegate() { return delegate_.get(); } |
60 Launcher* launcher() { return launcher_.get(); } | 58 Launcher* launcher() { return launcher_.get(); } |
61 | 59 |
62 private: | 60 private: |
63 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; | 61 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; |
64 | 62 |
| 63 explicit Shell(ShellDelegate* delegate); |
| 64 virtual ~Shell(); |
| 65 |
| 66 void Init(); |
| 67 |
65 // Enables WorkspaceManager. | 68 // Enables WorkspaceManager. |
66 void EnableWorkspaceManager(); | 69 void EnableWorkspaceManager(); |
67 | 70 |
68 // Overridden from aura::StackingClient: | 71 // Overridden from aura::StackingClient: |
69 virtual void AddChildToDefaultParent(aura::Window* window) OVERRIDE; | 72 virtual void AddChildToDefaultParent(aura::Window* window) OVERRIDE; |
70 virtual aura::Window* GetTopmostWindowToActivate( | 73 virtual aura::Window* GetTopmostWindowToActivate( |
71 aura::Window* ignore) const OVERRIDE; | 74 aura::Window* ignore) const OVERRIDE; |
72 | 75 |
73 static Shell* instance_; | 76 static Shell* instance_; |
74 | 77 |
75 std::vector<WindowAndBoundsPair> to_restore_; | 78 std::vector<WindowAndBoundsPair> to_restore_; |
76 | 79 |
77 base::WeakPtrFactory<Shell> method_factory_; | 80 base::WeakPtrFactory<Shell> method_factory_; |
78 | 81 |
79 scoped_ptr<ShellDelegate> delegate_; | 82 scoped_ptr<ShellDelegate> delegate_; |
80 | 83 |
81 scoped_ptr<Launcher> launcher_; | 84 scoped_ptr<Launcher> launcher_; |
82 | 85 |
83 scoped_ptr<internal::WorkspaceController> workspace_controller_; | 86 scoped_ptr<internal::WorkspaceController> workspace_controller_; |
84 | 87 |
85 scoped_ptr<internal::ShelfLayoutController> shelf_layout_controller_; | 88 scoped_ptr<internal::ShelfLayoutController> shelf_layout_controller_; |
86 | 89 |
87 DISALLOW_COPY_AND_ASSIGN(Shell); | 90 DISALLOW_COPY_AND_ASSIGN(Shell); |
88 }; | 91 }; |
89 | 92 |
90 } // namespace aura_shell | 93 } // namespace aura_shell |
91 | 94 |
92 #endif // UI_AURA_SHELL_SHELL_H_ | 95 #endif // UI_AURA_SHELL_SHELL_H_ |
OLD | NEW |