blob: cbb904e58858dc6bd4d19da73af4d401b1f6feed [file] [log] [blame]
[email protected]87b0d82e2011-10-07 21:02:591// 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]cac10fc62011-10-07 23:22:569#include <utility>
10#include <vector>
11
[email protected]87b0d82e2011-10-07 21:02:5912#include "base/basictypes.h"
[email protected]2b99f8c2011-10-11 19:42:2413#include "base/memory/scoped_ptr.h"
14#include "base/task.h"
[email protected]87b0d82e2011-10-07 21:02:5915#include "base/compiler_specific.h"
[email protected]f296be72011-10-11 15:40:0016#include "base/memory/weak_ptr.h"
[email protected]18d237872011-10-08 02:22:5117#include "ui/aura_shell/aura_shell_export.h"
[email protected]87b0d82e2011-10-07 21:02:5918
19namespace aura {
[email protected]e29014c2011-11-16 18:25:5120class EventFilter;
[email protected]87b0d82e2011-10-07 21:02:5921class Window;
22}
[email protected]2b99f8c2011-10-11 19:42:2423namespace gfx {
[email protected]cac10fc62011-10-07 23:22:5624class Rect;
25}
[email protected]87b0d82e2011-10-07 21:02:5926
27namespace aura_shell {
28
[email protected]671a2ae2011-10-13 21:53:2329class Launcher;
[email protected]745816be2011-11-22 05:08:3030class ShellAcceleratorController;
[email protected]2b99f8c2011-10-11 19:42:2431class ShellDelegate;
[email protected]4a229e902011-12-01 21:21:1132class ShellTooltipManager;
[email protected]60fa9bba2011-10-28 21:21:5133
34namespace internal {
[email protected]9fc206d2011-12-13 00:05:3335class ActivationController;
[email protected]ae4987d2011-11-21 22:52:4436class AppList;
[email protected]084b6bb2011-11-17 05:18:1637class DragDropController;
[email protected]a54e65b2011-11-21 22:03:3438class ShadowController;
[email protected]745816be2011-11-22 05:08:3039class ShellAcceleratorFilter;
[email protected]60fa9bba2011-10-28 21:21:5140class WorkspaceController;
41}
[email protected]2b99f8c2011-10-11 19:42:2442
[email protected]87b0d82e2011-10-07 21:02:5943// Shell is a singleton object that presents the Shell API and implements the
[email protected]99f07e02011-12-07 00:02:5944// RootWindow's delegate interface.
[email protected]6377a002011-11-10 20:26:4745class AURA_SHELL_EXPORT Shell {
[email protected]87b0d82e2011-10-07 21:02:5946 public:
[email protected]99f07e02011-12-07 00:02:5947 // Upon creation, the Shell sets itself as the RootWindow's delegate, which
48 // takes ownership of the Shell.
[email protected]87b0d82e2011-10-07 21:02:5949
[email protected]3266c2b92011-11-14 00:06:0850 // 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]cac10fc62011-10-07 23:22:5655 static Shell* GetInstance();
[email protected]3266c2b92011-11-14 00:06:0856
[email protected]ef589af2011-12-03 01:07:1557 static void DeleteInstance();
[email protected]cac10fc62011-10-07 23:22:5658
[email protected]87b0d82e2011-10-07 21:02:5959 aura::Window* GetContainer(int container_id);
60 const aura::Window* GetContainer(int container_id) const;
61
[email protected]99f07e02011-12-07 00:02:5962 // Adds or removes |filter| from the RootWindowEventFilter.
63 void AddRootWindowEventFilter(aura::EventFilter* filter);
64 void RemoveRootWindowEventFilter(aura::EventFilter* filter);
[email protected]e29014c2011-11-16 18:25:5165
[email protected]ca4ed122011-10-26 05:40:0166 // Toggles between overview mode and normal mode.
67 void ToggleOverview();
[email protected]cac10fc62011-10-07 23:22:5668
[email protected]ae4987d2011-11-21 22:52:4469 // Toggles app list.
70 void ToggleAppList();
71
[email protected]745816be2011-11-22 05:08:3072 ShellAcceleratorController* accelerator_controller() {
73 return accelerator_controller_.get();
74 }
75
[email protected]4a229e902011-12-01 21:21:1176 ShellTooltipManager* tooltip_manager() {
77 return tooltip_manager_.get();
78 }
79
[email protected]3266c2b92011-11-14 00:06:0880 ShellDelegate* delegate() { return delegate_.get(); }
[email protected]671a2ae2011-10-13 21:53:2381 Launcher* launcher() { return launcher_.get(); }
82
[email protected]a54e65b2011-11-21 22:03:3483 // Made available for tests.
84 internal::ShadowController* shadow_controller() {
85 return shadow_controller_.get();
86 }
87
[email protected]cac10fc62011-10-07 23:22:5688 private:
89 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
90
[email protected]3266c2b92011-11-14 00:06:0891 explicit Shell(ShellDelegate* delegate);
92 virtual ~Shell();
93
94 void Init();
95
[email protected]46ca3632011-11-03 03:33:4296 // Enables WorkspaceManager.
97 void EnableWorkspaceManager();
98
[email protected]cac10fc62011-10-07 23:22:5699 static Shell* instance_;
100
101 std::vector<WindowAndBoundsPair> to_restore_;
102
[email protected]f296be72011-10-11 15:40:00103 base::WeakPtrFactory<Shell> method_factory_;
[email protected]cac10fc62011-10-07 23:22:56104
[email protected]745816be2011-11-22 05:08:30105 scoped_ptr<ShellAcceleratorController> accelerator_controller_;
106
[email protected]2b99f8c2011-10-11 19:42:24107 scoped_ptr<ShellDelegate> delegate_;
108
[email protected]671a2ae2011-10-13 21:53:23109 scoped_ptr<Launcher> launcher_;
110
[email protected]ae4987d2011-11-21 22:52:44111 scoped_ptr<internal::AppList> app_list_;
112
[email protected]9fc206d2011-12-13 00:05:33113 scoped_ptr<internal::ActivationController> activation_controller_;
[email protected]084b6bb2011-11-17 05:18:16114 scoped_ptr<internal::DragDropController> drag_drop_controller_;
[email protected]60fa9bba2011-10-28 21:21:51115 scoped_ptr<internal::WorkspaceController> workspace_controller_;
[email protected]a54e65b2011-11-21 22:03:34116 scoped_ptr<internal::ShadowController> shadow_controller_;
[email protected]ae18b9112011-11-07 16:59:13117
[email protected]745816be2011-11-22 05:08:30118 // An event filter that pre-handles global accelerators.
119 scoped_ptr<internal::ShellAcceleratorFilter> accelerator_filter_;
120
[email protected]4a229e902011-12-01 21:21:11121 scoped_ptr<ShellTooltipManager> tooltip_manager_;
122
[email protected]87b0d82e2011-10-07 21:02:59123 DISALLOW_COPY_AND_ASSIGN(Shell);
124};
125
126} // namespace aura_shell
127
128#endif // UI_AURA_SHELL_SHELL_H_