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

Side by Side Diff: ash/common/wm/always_on_top_controller.cc

Issue 2736573002: chromeos: Move files in //ash/common to //ash, part 2 (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « ash/common/wm/always_on_top_controller.h ('k') | ash/common/wm/container_finder.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/common/wm/always_on_top_controller.h"
6
7 #include "ash/common/wm/workspace/workspace_layout_manager.h"
8 #include "ash/common/wm_window.h"
9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "base/memory/ptr_util.h"
11 #include "ui/aura/client/aura_constants.h"
12 #include "ui/aura/window.h"
13
14 namespace ash {
15
16 AlwaysOnTopController::AlwaysOnTopController(WmWindow* viewport)
17 : always_on_top_container_(viewport) {
18 DCHECK_NE(kShellWindowId_DefaultContainer, viewport->GetShellWindowId());
19 always_on_top_container_->SetLayoutManager(
20 base::MakeUnique<WorkspaceLayoutManager>(viewport));
21 // Container should be empty.
22 DCHECK(always_on_top_container_->GetChildren().empty());
23 always_on_top_container_->aura_window()->AddObserver(this);
24 }
25
26 AlwaysOnTopController::~AlwaysOnTopController() {
27 if (always_on_top_container_)
28 always_on_top_container_->aura_window()->RemoveObserver(this);
29 }
30
31 WmWindow* AlwaysOnTopController::GetContainer(WmWindow* window) const {
32 DCHECK(always_on_top_container_);
33 if (window->aura_window()->GetProperty(aura::client::kAlwaysOnTopKey))
34 return always_on_top_container_;
35 return always_on_top_container_->GetRootWindow()->GetChildByShellWindowId(
36 kShellWindowId_DefaultContainer);
37 }
38
39 // TODO(rsadam@): Refactor so that this cast is unneeded.
40 WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const {
41 return static_cast<WorkspaceLayoutManager*>(
42 always_on_top_container_->GetLayoutManager());
43 }
44
45 void AlwaysOnTopController::SetLayoutManagerForTest(
46 std::unique_ptr<WorkspaceLayoutManager> layout_manager) {
47 always_on_top_container_->SetLayoutManager(std::move(layout_manager));
48 }
49
50 void AlwaysOnTopController::OnWindowHierarchyChanged(
51 const HierarchyChangeParams& params) {
52 if (WmWindow::Get(params.old_parent) == always_on_top_container_)
53 params.target->RemoveObserver(this);
54 else if (WmWindow::Get(params.new_parent) == always_on_top_container_)
55 params.target->AddObserver(this);
56 }
57
58 void AlwaysOnTopController::OnWindowPropertyChanged(aura::Window* window,
59 const void* key,
60 intptr_t old) {
61 if (WmWindow::Get(window) != always_on_top_container_ &&
62 key == aura::client::kAlwaysOnTopKey) {
63 DCHECK(window->type() == ui::wm::WINDOW_TYPE_NORMAL ||
64 window->type() == ui::wm::WINDOW_TYPE_POPUP);
65 WmWindow* container = GetContainer(WmWindow::Get(window));
66 if (WmWindow::Get(window->parent()) != container)
67 container->AddChild(WmWindow::Get(window));
68 }
69 }
70
71 void AlwaysOnTopController::OnWindowDestroying(aura::Window* window) {
72 if (WmWindow::Get(window) == always_on_top_container_) {
73 always_on_top_container_->aura_window()->RemoveObserver(this);
74 always_on_top_container_ = nullptr;
75 }
76 }
77
78 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/always_on_top_controller.h ('k') | ash/common/wm/container_finder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698