blob: a8778636de91c6e209dbfe497d64b0cfb669360c [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]ae4987d2011-11-21 22:52:4435class AppList;
[email protected]084b6bb2011-11-17 05:18:1636class DragDropController;
[email protected]a54e65b2011-11-21 22:03:3437class ShadowController;
[email protected]745816be2011-11-22 05:08:3038class ShellAcceleratorFilter;
[email protected]60fa9bba2011-10-28 21:21:5139class WorkspaceController;
40}
[email protected]2b99f8c2011-10-11 19:42:2441
[email protected]87b0d82e2011-10-07 21:02:5942// Shell is a singleton object that presents the Shell API and implements the
[email protected]99f07e02011-12-07 00:02:5943// RootWindow's delegate interface.
[email protected]6377a002011-11-10 20:26:4744class AURA_SHELL_EXPORT Shell {
[email protected]87b0d82e2011-10-07 21:02:5945 public:
[email protected]99f07e02011-12-07 00:02:5946 // Upon creation, the Shell sets itself as the RootWindow's delegate, which
47 // takes ownership of the Shell.
[email protected]87b0d82e2011-10-07 21:02:5948
[email protected]3266c2b92011-11-14 00:06:0849 // 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]cac10fc62011-10-07 23:22:5654 static Shell* GetInstance();
[email protected]3266c2b92011-11-14 00:06:0855
[email protected]ef589af2011-12-03 01:07:1556 static void DeleteInstance();
[email protected]cac10fc62011-10-07 23:22:5657
[email protected]87b0d82e2011-10-07 21:02:5958 aura::Window* GetContainer(int container_id);
59 const aura::Window* GetContainer(int container_id) const;
60
[email protected]99f07e02011-12-07 00:02:5961 // Adds or removes |filter| from the RootWindowEventFilter.
62 void AddRootWindowEventFilter(aura::EventFilter* filter);
63 void RemoveRootWindowEventFilter(aura::EventFilter* filter);
[email protected]e29014c2011-11-16 18:25:5164
[email protected]ca4ed122011-10-26 05:40:0165 // Toggles between overview mode and normal mode.
66 void ToggleOverview();
[email protected]cac10fc62011-10-07 23:22:5667
[email protected]ae4987d2011-11-21 22:52:4468 // Toggles app list.
69 void ToggleAppList();
70
[email protected]745816be2011-11-22 05:08:3071 ShellAcceleratorController* accelerator_controller() {
72 return accelerator_controller_.get();
73 }
74
[email protected]4a229e902011-12-01 21:21:1175 ShellTooltipManager* tooltip_manager() {
76 return tooltip_manager_.get();
77 }
78
[email protected]3266c2b92011-11-14 00:06:0879 ShellDelegate* delegate() { return delegate_.get(); }
[email protected]671a2ae2011-10-13 21:53:2380 Launcher* launcher() { return launcher_.get(); }
81
[email protected]a54e65b2011-11-21 22:03:3482 // Made available for tests.
83 internal::ShadowController* shadow_controller() {
84 return shadow_controller_.get();
85 }
86
[email protected]cac10fc62011-10-07 23:22:5687 private:
88 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
89
[email protected]3266c2b92011-11-14 00:06:0890 explicit Shell(ShellDelegate* delegate);
91 virtual ~Shell();
92
93 void Init();
94
[email protected]46ca3632011-11-03 03:33:4295 // Enables WorkspaceManager.
96 void EnableWorkspaceManager();
97
[email protected]cac10fc62011-10-07 23:22:5698 static Shell* instance_;
99
100 std::vector<WindowAndBoundsPair> to_restore_;
101
[email protected]f296be72011-10-11 15:40:00102 base::WeakPtrFactory<Shell> method_factory_;
[email protected]cac10fc62011-10-07 23:22:56103
[email protected]745816be2011-11-22 05:08:30104 scoped_ptr<ShellAcceleratorController> accelerator_controller_;
105
[email protected]2b99f8c2011-10-11 19:42:24106 scoped_ptr<ShellDelegate> delegate_;
107
[email protected]671a2ae2011-10-13 21:53:23108 scoped_ptr<Launcher> launcher_;
109
[email protected]ae4987d2011-11-21 22:52:44110 scoped_ptr<internal::AppList> app_list_;
111
[email protected]084b6bb2011-11-17 05:18:16112 scoped_ptr<internal::DragDropController> drag_drop_controller_;
[email protected]60fa9bba2011-10-28 21:21:51113 scoped_ptr<internal::WorkspaceController> workspace_controller_;
[email protected]a54e65b2011-11-21 22:03:34114 scoped_ptr<internal::ShadowController> shadow_controller_;
[email protected]ae18b9112011-11-07 16:59:13115
[email protected]745816be2011-11-22 05:08:30116 // An event filter that pre-handles global accelerators.
117 scoped_ptr<internal::ShellAcceleratorFilter> accelerator_filter_;
118
[email protected]4a229e902011-12-01 21:21:11119 scoped_ptr<ShellTooltipManager> tooltip_manager_;
120
[email protected]87b0d82e2011-10-07 21:02:59121 DISALLOW_COPY_AND_ASSIGN(Shell);
122};
123
124} // namespace aura_shell
125
126#endif // UI_AURA_SHELL_SHELL_H_