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

Side by Side Diff: ui/aura_shell/always_on_top_controller.cc

Issue 9026017: Move some more files into ash... this time seed the window manager dir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 12 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 | « ui/aura_shell/always_on_top_controller.h ('k') | ui/aura_shell/aura_shell.gyp » ('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) 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 #include "ui/aura_shell/always_on_top_controller.h"
6
7 #include "ui/aura/client/aura_constants.h"
8 #include "ui/aura/window.h"
9
10 namespace aura_shell {
11 namespace internal {
12
13 AlwaysOnTopController::AlwaysOnTopController()
14 : default_container_(NULL),
15 always_on_top_container_(NULL) {
16 }
17
18 AlwaysOnTopController::~AlwaysOnTopController() {
19 if (default_container_)
20 default_container_->RemoveObserver(this);
21 if (always_on_top_container_)
22 always_on_top_container_->RemoveObserver(this);
23 }
24
25 void AlwaysOnTopController::SetContainers(aura::Window* default_container,
26 aura::Window* always_on_top_container) {
27 // Both containers should have no children.
28 DCHECK(default_container->children().empty());
29 DCHECK(always_on_top_container->children().empty());
30
31 // We are not handling any containers yet.
32 DCHECK(default_container_ == NULL && always_on_top_container_ == NULL);
33
34 default_container_ = default_container;
35 default_container_->AddObserver(this);
36
37 always_on_top_container_ = always_on_top_container;
38 always_on_top_container_->AddObserver(this);
39 }
40
41 aura::Window* AlwaysOnTopController::GetContainer(aura::Window* window) const {
42 DCHECK(default_container_ && always_on_top_container_);
43 return !window->GetProperty(aura::client::kAlwaysOnTopKey) ?
44 default_container_ : always_on_top_container_;
45 }
46
47 void AlwaysOnTopController::OnWindowAdded(aura::Window* child) {
48 // Observe direct child of the containers.
49 if (child->parent() == default_container_ ||
50 child->parent() == always_on_top_container_) {
51 child->AddObserver(this);
52 }
53 }
54
55 void AlwaysOnTopController::OnWillRemoveWindow(aura::Window* child) {
56 child->RemoveObserver(this);
57 }
58
59 void AlwaysOnTopController::OnWindowPropertyChanged(aura::Window* window,
60 const char* name,
61 void* old) {
62 if (name == aura::client::kAlwaysOnTopKey) {
63 DCHECK(window->type() == aura::client::WINDOW_TYPE_NORMAL ||
64 window->type() == aura::client::WINDOW_TYPE_POPUP);
65 aura::Window* container = GetContainer(window);
66 if (window->parent() != container)
67 container->AddChild(window);
68 }
69 }
70
71 void AlwaysOnTopController::OnWindowDestroyed(aura::Window* window) {
72 if (window == default_container_)
73 default_container_ = NULL;
74 if (window == always_on_top_container_)
75 always_on_top_container_ = NULL;
76 }
77
78 } // namespace internal
79 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/always_on_top_controller.h ('k') | ui/aura_shell/aura_shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698