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

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

Issue 2861243003: chromeos: Converts WorkspaceLayoutManager to aura::LayoutManager (Closed)
Patch Set: moar Created 3 years, 7 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/wm/always_on_top_controller.h" 5 #include "ash/wm/always_on_top_controller.h"
6 6
7 #include "ash/public/cpp/shell_window_ids.h" 7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/wm/workspace/workspace_layout_manager.h" 8 #include "ash/wm/workspace/workspace_layout_manager.h"
9 #include "ash/wm_window.h" 9 #include "ash/wm_window.h"
10 #include "base/memory/ptr_util.h"
11 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
12 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
13 12
14 namespace ash { 13 namespace ash {
15 14
16 AlwaysOnTopController::AlwaysOnTopController(WmWindow* viewport) 15 AlwaysOnTopController::AlwaysOnTopController(WmWindow* viewport)
17 : always_on_top_container_(viewport) { 16 : always_on_top_container_(viewport) {
18 DCHECK_NE(kShellWindowId_DefaultContainer, viewport->aura_window()->id()); 17 DCHECK_NE(kShellWindowId_DefaultContainer, viewport->aura_window()->id());
19 always_on_top_container_->SetLayoutManager( 18 always_on_top_container_->aura_window()->SetLayoutManager(
20 base::MakeUnique<WorkspaceLayoutManager>(viewport)); 19 new WorkspaceLayoutManager(viewport->aura_window()));
21 // Container should be empty. 20 // Container should be empty.
22 DCHECK(always_on_top_container_->GetChildren().empty()); 21 DCHECK(always_on_top_container_->GetChildren().empty());
23 always_on_top_container_->aura_window()->AddObserver(this); 22 always_on_top_container_->aura_window()->AddObserver(this);
24 } 23 }
25 24
26 AlwaysOnTopController::~AlwaysOnTopController() { 25 AlwaysOnTopController::~AlwaysOnTopController() {
27 if (always_on_top_container_) 26 if (always_on_top_container_)
28 always_on_top_container_->aura_window()->RemoveObserver(this); 27 always_on_top_container_->aura_window()->RemoveObserver(this);
29 } 28 }
30 29
31 WmWindow* AlwaysOnTopController::GetContainer(WmWindow* window) const { 30 WmWindow* AlwaysOnTopController::GetContainer(WmWindow* window) const {
32 DCHECK(always_on_top_container_); 31 DCHECK(always_on_top_container_);
33 if (window->aura_window()->GetProperty(aura::client::kAlwaysOnTopKey)) 32 if (window->aura_window()->GetProperty(aura::client::kAlwaysOnTopKey))
34 return always_on_top_container_; 33 return always_on_top_container_;
35 return always_on_top_container_->GetRootWindow()->GetChildByShellWindowId( 34 return always_on_top_container_->GetRootWindow()->GetChildByShellWindowId(
36 kShellWindowId_DefaultContainer); 35 kShellWindowId_DefaultContainer);
37 } 36 }
38 37
39 // TODO(rsadam@): Refactor so that this cast is unneeded. 38 // TODO(rsadam@): Refactor so that this cast is unneeded.
40 WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const { 39 WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const {
41 return static_cast<WorkspaceLayoutManager*>( 40 return static_cast<WorkspaceLayoutManager*>(
42 always_on_top_container_->GetLayoutManager()); 41 always_on_top_container_->aura_window()->layout_manager());
43 } 42 }
44 43
45 void AlwaysOnTopController::SetLayoutManagerForTest( 44 void AlwaysOnTopController::SetLayoutManagerForTest(
46 std::unique_ptr<WorkspaceLayoutManager> layout_manager) { 45 std::unique_ptr<WorkspaceLayoutManager> layout_manager) {
47 always_on_top_container_->SetLayoutManager(std::move(layout_manager)); 46 always_on_top_container_->aura_window()->SetLayoutManager(
47 layout_manager.release());
48 } 48 }
49 49
50 void AlwaysOnTopController::OnWindowHierarchyChanged( 50 void AlwaysOnTopController::OnWindowHierarchyChanged(
51 const HierarchyChangeParams& params) { 51 const HierarchyChangeParams& params) {
52 if (WmWindow::Get(params.old_parent) == always_on_top_container_) 52 if (WmWindow::Get(params.old_parent) == always_on_top_container_)
53 params.target->RemoveObserver(this); 53 params.target->RemoveObserver(this);
54 else if (WmWindow::Get(params.new_parent) == always_on_top_container_) 54 else if (WmWindow::Get(params.new_parent) == always_on_top_container_)
55 params.target->AddObserver(this); 55 params.target->AddObserver(this);
56 } 56 }
57 57
(...skipping 11 matching lines...) Expand all
69 } 69 }
70 70
71 void AlwaysOnTopController::OnWindowDestroying(aura::Window* window) { 71 void AlwaysOnTopController::OnWindowDestroying(aura::Window* window) {
72 if (WmWindow::Get(window) == always_on_top_container_) { 72 if (WmWindow::Get(window) == always_on_top_container_) {
73 always_on_top_container_->aura_window()->RemoveObserver(this); 73 always_on_top_container_->aura_window()->RemoveObserver(this);
74 always_on_top_container_ = nullptr; 74 always_on_top_container_ = nullptr;
75 } 75 }
76 } 76 }
77 77
78 } // namespace ash 78 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698