Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: ash/wm/window_manager_extension.cc

Issue 10824364: [NOT FOR REVIEW] ash: Add some implementation for the window management extension API. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/window_manager_extension.h ('k') | ash/wm/window_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "ash/wm/window_manager_extension.h"
6
7 #include "ash/shell.h"
8 #include "ui/aura/client/activation_client.h"
9 #include "ui/aura/env.h"
10 #include "ui/aura/window.h"
11
12 namespace ash {
13 namespace internal {
14
15 ////////////////////////////////////////////////////////////////////////////////
16 // WindowManagerExtension, public:
17
18 WindowManagerExtension::WindowManagerExtension() {
19 aura::Env::GetInstance()->AddObserver(this);
20 aura::client::GetActivationClient(
21 Shell::GetPrimaryRootWindow())->AddObserver(this);
22 }
23
24 WindowManagerExtension::~WindowManagerExtension() {
25 aura::client::GetActivationClient(
26 Shell::GetPrimaryRootWindow())->RemoveObserver(this);
27 aura::Env::GetInstance()->RemoveObserver(this);
28 for (size_t i = 0; i < windows_.size(); ++i)
29 windows_[i]->RemoveObserver(this);
30 }
31
32 ////////////////////////////////////////////////////////////////////////////////
33 // WindowManagerExtension, aura::EnvObserver implementation:
34
35 void WindowManagerExtension::OnWindowInitialized(aura::Window* window) {
36 windows_.push_back(window);
37 window->AddObserver(this);
38
39 if (delegate_.get())
40 delegate_->OnWindowCreated(window);
41 }
42
43 ////////////////////////////////////////////////////////////////////////////////
44 // WindowManagerExtension, aura::WindowObserver implementation:
45
46 void WindowManagerExtension::OnWindowVisibilityChanged(
47 aura::Window* window,
48 bool visible) {
49 if (delegate_.get()) {
50 if (visible)
51 delegate_->OnWindowShown(window);
52 else
53 delegate_->OnWindowHidden(window);
54 }
55 }
56
57 void WindowManagerExtension::OnWindowDestroyed(aura::Window* window) {
58 windows_.erase(std::find(windows_.begin(), windows_.end(), window));
59 window->RemoveObserver(this);
60
61 if (delegate_.get())
62 delegate_->OnWindowClosed(window);
63 }
64
65 ////////////////////////////////////////////////////////////////////////////////
66 // WindowManagerExtension, aura::WindowObserver implementation:
67
68 void WindowManagerExtension::OnWindowActivated(aura::Window* active,
69 aura::Window* old_active) {
70 if (delegate_.get())
71 delegate_->OnActiveWindowChanged(active);
72 }
73
74 } // namespace internal
75 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_manager_extension.h ('k') | ash/wm/window_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698