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

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

Issue 2035543004: Shuffles and renames ash/common/wm classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: random changes for chrome tests Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/wm/always_on_top_controller.h" 5 #include "ash/common/wm/always_on_top_controller.h"
6 6
7 #include "ash/common/shell_window_ids.h" 7 #include "ash/common/shell_window_ids.h"
8 #include "ash/common/wm/wm_window.h"
9 #include "ash/common/wm/wm_window_property.h"
10 #include "ash/common/wm/workspace/workspace_layout_manager.h" 8 #include "ash/common/wm/workspace/workspace_layout_manager.h"
11 #include "ash/common/wm/workspace/workspace_layout_manager_delegate.h" 9 #include "ash/common/wm/workspace/workspace_layout_manager_delegate.h"
10 #include "ash/common/wm_window.h"
11 #include "ash/common/wm_window_property.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 13
14 namespace ash { 14 namespace ash {
15 15
16 AlwaysOnTopController::AlwaysOnTopController(wm::WmWindow* viewport) 16 AlwaysOnTopController::AlwaysOnTopController(WmWindow* viewport)
17 : always_on_top_container_(viewport) { 17 : always_on_top_container_(viewport) {
18 always_on_top_container_->SetLayoutManager( 18 always_on_top_container_->SetLayoutManager(
19 base::WrapUnique(new WorkspaceLayoutManager(viewport, nullptr))); 19 base::WrapUnique(new WorkspaceLayoutManager(viewport, nullptr)));
20 // Container should be empty. 20 // Container should be empty.
21 DCHECK(always_on_top_container_->GetChildren().empty()); 21 DCHECK(always_on_top_container_->GetChildren().empty());
22 always_on_top_container_->AddObserver(this); 22 always_on_top_container_->AddObserver(this);
23 } 23 }
24 24
25 AlwaysOnTopController::~AlwaysOnTopController() { 25 AlwaysOnTopController::~AlwaysOnTopController() {
26 if (always_on_top_container_) 26 if (always_on_top_container_)
27 always_on_top_container_->RemoveObserver(this); 27 always_on_top_container_->RemoveObserver(this);
28 } 28 }
29 29
30 wm::WmWindow* AlwaysOnTopController::GetContainer(wm::WmWindow* window) const { 30 WmWindow* AlwaysOnTopController::GetContainer(WmWindow* window) const {
31 DCHECK(always_on_top_container_); 31 DCHECK(always_on_top_container_);
32 if (window->GetBoolProperty(wm::WmWindowProperty::ALWAYS_ON_TOP)) 32 if (window->GetBoolProperty(WmWindowProperty::ALWAYS_ON_TOP))
33 return always_on_top_container_; 33 return always_on_top_container_;
34 return always_on_top_container_->GetRootWindow()->GetChildByShellWindowId( 34 return always_on_top_container_->GetRootWindow()->GetChildByShellWindowId(
35 kShellWindowId_DefaultContainer); 35 kShellWindowId_DefaultContainer);
36 } 36 }
37 37
38 // TODO(rsadam@): Refactor so that this cast is unneeded. 38 // TODO(rsadam@): Refactor so that this cast is unneeded.
39 WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const { 39 WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const {
40 return static_cast<WorkspaceLayoutManager*>( 40 return static_cast<WorkspaceLayoutManager*>(
41 always_on_top_container_->GetLayoutManager()); 41 always_on_top_container_->GetLayoutManager());
42 } 42 }
43 43
44 void AlwaysOnTopController::SetLayoutManagerForTest( 44 void AlwaysOnTopController::SetLayoutManagerForTest(
45 std::unique_ptr<WorkspaceLayoutManager> layout_manager) { 45 std::unique_ptr<WorkspaceLayoutManager> layout_manager) {
46 always_on_top_container_->SetLayoutManager(std::move(layout_manager)); 46 always_on_top_container_->SetLayoutManager(std::move(layout_manager));
47 } 47 }
48 48
49 void AlwaysOnTopController::OnWindowTreeChanged( 49 void AlwaysOnTopController::OnWindowTreeChanged(
50 wm::WmWindow* window, 50 WmWindow* window,
51 const TreeChangeParams& params) { 51 const TreeChangeParams& params) {
52 if (params.old_parent == always_on_top_container_) 52 if (params.old_parent == always_on_top_container_)
53 params.target->RemoveObserver(this); 53 params.target->RemoveObserver(this);
54 else if (params.new_parent == always_on_top_container_) 54 else if (params.new_parent == always_on_top_container_)
55 params.target->AddObserver(this); 55 params.target->AddObserver(this);
56 } 56 }
57 57
58 void AlwaysOnTopController::OnWindowPropertyChanged( 58 void AlwaysOnTopController::OnWindowPropertyChanged(WmWindow* window,
59 wm::WmWindow* window, 59 WmWindowProperty property) {
60 wm::WmWindowProperty property) {
61 if (window != always_on_top_container_ && 60 if (window != always_on_top_container_ &&
62 property == wm::WmWindowProperty::ALWAYS_ON_TOP) { 61 property == WmWindowProperty::ALWAYS_ON_TOP) {
63 DCHECK(window->GetType() == ui::wm::WINDOW_TYPE_NORMAL || 62 DCHECK(window->GetType() == ui::wm::WINDOW_TYPE_NORMAL ||
64 window->GetType() == ui::wm::WINDOW_TYPE_POPUP); 63 window->GetType() == ui::wm::WINDOW_TYPE_POPUP);
65 wm::WmWindow* container = GetContainer(window); 64 WmWindow* container = GetContainer(window);
66 if (window->GetParent() != container) 65 if (window->GetParent() != container)
67 container->AddChild(window); 66 container->AddChild(window);
68 } 67 }
69 } 68 }
70 69
71 void AlwaysOnTopController::OnWindowDestroying(wm::WmWindow* window) { 70 void AlwaysOnTopController::OnWindowDestroying(WmWindow* window) {
72 if (window == always_on_top_container_) { 71 if (window == always_on_top_container_) {
73 always_on_top_container_->RemoveObserver(this); 72 always_on_top_container_->RemoveObserver(this);
74 always_on_top_container_ = nullptr; 73 always_on_top_container_ = nullptr;
75 } 74 }
76 } 75 }
77 76
78 } // namespace ash 77 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698