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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/task.h" | 14 #include "base/task.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "ui/aura_shell/aura_shell_export.h" | 17 #include "ui/aura_shell/aura_shell_export.h" |
18 #include "ui/base/models/accelerator.h" | |
18 | 19 |
19 namespace aura { | 20 namespace aura { |
20 class Window; | 21 class Window; |
21 } | 22 } |
22 namespace gfx { | 23 namespace gfx { |
23 class Rect; | 24 class Rect; |
24 } | 25 } |
26 namespace ui { | |
27 class AcceleratorManager; | |
28 } | |
25 | 29 |
26 namespace aura_shell { | 30 namespace aura_shell { |
27 | 31 |
28 class Launcher; | 32 class Launcher; |
29 class ShellDelegate; | 33 class ShellDelegate; |
30 | 34 |
31 namespace internal { | 35 namespace internal { |
32 class ShelfLayoutController; | 36 class ShelfLayoutController; |
33 class WorkspaceController; | 37 class WorkspaceController; |
34 } | 38 } |
35 | 39 |
36 // Shell is a singleton object that presents the Shell API and implements the | 40 // Shell is a singleton object that presents the Shell API and implements the |
37 // Desktop's delegate interface. | 41 // Desktop's delegate interface. |
38 class AURA_SHELL_EXPORT Shell { | 42 class AURA_SHELL_EXPORT Shell : public ui::AcceleratorTarget { |
Ben Goodger (Google)
2011/11/16 16:16:10
Rather than making the Shell an accelerator target
| |
39 public: | 43 public: |
40 // Upon creation, the Shell sets itself as the Desktop's delegate, which takes | 44 // Upon creation, the Shell sets itself as the Desktop's delegate, which takes |
41 // ownership of the Shell. | 45 // ownership of the Shell. |
42 | 46 |
43 // A shell must be explicitly created so that it can call |Init()| with the | 47 // A shell must be explicitly created so that it can call |Init()| with the |
44 // delegate set. |delegate| can be NULL (if not required for initialization). | 48 // delegate set. |delegate| can be NULL (if not required for initialization). |
45 static Shell* CreateInstance(ShellDelegate* delegate); | 49 static Shell* CreateInstance(ShellDelegate* delegate); |
46 | 50 |
47 // Should never be called before |CreateInstance()|. | 51 // Should never be called before |CreateInstance()|. |
48 static Shell* GetInstance(); | 52 static Shell* GetInstance(); |
49 | 53 |
50 static void DeleteInstanceForTesting(); | 54 static void DeleteInstanceForTesting(); |
51 | 55 |
52 aura::Window* GetContainer(int container_id); | 56 aura::Window* GetContainer(int container_id); |
53 const aura::Window* GetContainer(int container_id) const; | 57 const aura::Window* GetContainer(int container_id) const; |
54 | 58 |
55 // Toggles between overview mode and normal mode. | 59 // Toggles between overview mode and normal mode. |
56 void ToggleOverview(); | 60 void ToggleOverview(); |
57 | 61 |
58 ShellDelegate* delegate() { return delegate_.get(); } | 62 ShellDelegate* delegate() { return delegate_.get(); } |
59 Launcher* launcher() { return launcher_.get(); } | 63 Launcher* launcher() { return launcher_.get(); } |
60 | 64 |
65 // Returns the AcceleratorManager that managers global keyboard shortcuts. | |
66 ui::AcceleratorManager* accelerator_manager() { | |
67 return accelerator_manager_.get(); | |
68 } | |
69 | |
70 // Overridden from ui::AcceleratorTarget: | |
71 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
72 | |
61 private: | 73 private: |
62 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; | 74 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; |
63 | 75 |
64 explicit Shell(ShellDelegate* delegate); | 76 explicit Shell(ShellDelegate* delegate); |
65 virtual ~Shell(); | 77 virtual ~Shell(); |
66 | 78 |
67 void Init(); | 79 void Init(); |
68 | 80 |
69 // Enables WorkspaceManager. | 81 // Enables WorkspaceManager. |
70 void EnableWorkspaceManager(); | 82 void EnableWorkspaceManager(); |
71 | 83 |
72 static Shell* instance_; | 84 static Shell* instance_; |
73 | 85 |
74 std::vector<WindowAndBoundsPair> to_restore_; | 86 std::vector<WindowAndBoundsPair> to_restore_; |
75 | 87 |
76 base::WeakPtrFactory<Shell> method_factory_; | 88 base::WeakPtrFactory<Shell> method_factory_; |
77 | 89 |
78 scoped_ptr<ShellDelegate> delegate_; | 90 scoped_ptr<ShellDelegate> delegate_; |
79 | 91 |
80 scoped_ptr<Launcher> launcher_; | 92 scoped_ptr<Launcher> launcher_; |
81 | 93 |
82 scoped_ptr<internal::WorkspaceController> workspace_controller_; | 94 scoped_ptr<internal::WorkspaceController> workspace_controller_; |
83 scoped_ptr<internal::ShelfLayoutController> shelf_layout_controller_; | 95 scoped_ptr<internal::ShelfLayoutController> shelf_layout_controller_; |
84 | 96 |
97 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | |
98 | |
85 DISALLOW_COPY_AND_ASSIGN(Shell); | 99 DISALLOW_COPY_AND_ASSIGN(Shell); |
86 }; | 100 }; |
87 | 101 |
88 } // namespace aura_shell | 102 } // namespace aura_shell |
89 | 103 |
90 #endif // UI_AURA_SHELL_SHELL_H_ | 104 #endif // UI_AURA_SHELL_SHELL_H_ |
OLD | NEW |