window_watcher.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
1// Copyright (c) 2012 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 ASH_SHELL_WINDOW_WATCHER_H_
6#define ASH_SHELL_WINDOW_WATCHER_H_
7
8#include <map>
9
10#include "ash/launcher/launcher_types.h"
11#include "base/compiler_specific.h"
12#include "base/logging.h"
13#include "base/memory/scoped_ptr.h"
14#include "ui/aura/window_observer.h"
15
16namespace aura {
17class Window;
18}
19
20namespace ash {
21namespace shell {
22
23// TODO(sky): fix this class, its a bit broke with workspace2.
24
25// WindowWatcher is responsible for listening for newly created windows and
26// creating items on the Launcher for them.
27class WindowWatcher : public aura::WindowObserver {
28 public:
29  WindowWatcher();
30  virtual ~WindowWatcher();
31
32  aura::Window* GetWindowByID(ash::LauncherID id);
33  ash::LauncherID GetIDByWindow(aura::Window* window) const;
34
35  // aura::WindowObserver overrides:
36  virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE;
37  virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE;
38
39 private:
40  class WorkspaceWindowWatcher;
41
42  typedef std::map<ash::LauncherID, aura::Window*> IDToWindow;
43
44  // Window watching for newly created windows to be added to.
45  aura::Window* window_;
46
47  aura::Window* panel_container_;
48
49  // Maps from window to the id we gave it.
50  IDToWindow id_to_window_;
51
52  scoped_ptr<WorkspaceWindowWatcher> workspace_window_watcher_;
53
54  DISALLOW_COPY_AND_ASSIGN(WindowWatcher);
55};
56
57}  // namespace shell
58}  // namespace ash
59
60#endif  // ASH_SHELL_WINDOW_WATCHER_H_
61