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

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

Issue 2777103005: Using WmDisplayObserver in ScreenPinningController. (Closed)
Patch Set: Created 3 years, 8 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/wm/screen_pinning_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/screen_pinning_controller.h" 5 #include "ash/wm/screen_pinning_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/window_user_data.h" 10 #include "ash/common/window_user_data.h"
11 #include "ash/common/wm/container_finder.h" 11 #include "ash/common/wm/container_finder.h"
12 #include "ash/common/wm/window_dimmer.h" 12 #include "ash/common/wm/window_dimmer.h"
13 #include "ash/common/wm/window_state.h" 13 #include "ash/common/wm/window_state.h"
14 #include "ash/common/wm_shell.h"
14 #include "ash/common/wm_window.h" 15 #include "ash/common/wm_window.h"
15 #include "ash/display/window_tree_host_manager.h"
16 #include "ash/public/cpp/shell_window_ids.h" 16 #include "ash/public/cpp/shell_window_ids.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "base/auto_reset.h" 18 #include "base/auto_reset.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/memory/ptr_util.h" 20 #include "base/memory/ptr_util.h"
21 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/aura/window_observer.h" 22 #include "ui/aura/window_observer.h"
23 #include "ui/wm/core/window_util.h" 23 #include "ui/wm/core/window_util.h"
24 24
25 namespace ash { 25 namespace ash {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 void OnWindowDestroying(aura::Window* window) override { 140 void OnWindowDestroying(aura::Window* window) override {
141 // Just in case. There is nothing we can do here. 141 // Just in case. There is nothing we can do here.
142 window->RemoveObserver(this); 142 window->RemoveObserver(this);
143 } 143 }
144 144
145 private: 145 private:
146 ScreenPinningController* controller_; 146 ScreenPinningController* controller_;
147 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerWindowObserver); 147 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerWindowObserver);
148 }; 148 };
149 149
150 ScreenPinningController::ScreenPinningController( 150 ScreenPinningController::ScreenPinningController()
151 WindowTreeHostManager* window_tree_host_manager)
152 : window_dimmers_(base::MakeUnique<WindowUserData<WindowDimmer>>()), 151 : window_dimmers_(base::MakeUnique<WindowUserData<WindowDimmer>>()),
153 window_tree_host_manager_(window_tree_host_manager),
154 pinned_container_window_observer_( 152 pinned_container_window_observer_(
155 base::MakeUnique<PinnedContainerWindowObserver>(this)), 153 base::MakeUnique<PinnedContainerWindowObserver>(this)),
156 pinned_container_child_window_observer_( 154 pinned_container_child_window_observer_(
157 base::MakeUnique<PinnedContainerChildWindowObserver>(this)), 155 base::MakeUnique<PinnedContainerChildWindowObserver>(this)),
158 system_modal_container_window_observer_( 156 system_modal_container_window_observer_(
159 base::MakeUnique<SystemModalContainerWindowObserver>(this)), 157 base::MakeUnique<SystemModalContainerWindowObserver>(this)),
160 system_modal_container_child_window_observer_( 158 system_modal_container_child_window_observer_(
161 base::MakeUnique<SystemModalContainerChildWindowObserver>(this)) { 159 base::MakeUnique<SystemModalContainerChildWindowObserver>(this)) {
162 window_tree_host_manager_->AddObserver(this); 160 WmShell::Get()->AddDisplayObserver(this);
163 } 161 }
164 162
165 ScreenPinningController::~ScreenPinningController() { 163 ScreenPinningController::~ScreenPinningController() {
166 window_tree_host_manager_->RemoveObserver(this); 164 WmShell::Get()->RemoveDisplayObserver(this);
167 } 165 }
168 166
169 bool ScreenPinningController::IsPinned() const { 167 bool ScreenPinningController::IsPinned() const {
170 return pinned_window_ != nullptr; 168 return pinned_window_ != nullptr;
171 } 169 }
172 170
173 void ScreenPinningController::SetPinnedWindow(WmWindow* pinned_window) { 171 void ScreenPinningController::SetPinnedWindow(WmWindow* pinned_window) {
174 window_dimmers_->clear(); 172 window_dimmers_->clear();
175 173
176 if (pinned_window->GetWindowState()->IsPinned()) { 174 if (pinned_window->GetWindowState()->IsPinned()) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 return; 344 return;
347 345
348 WindowDimmer* window_dimmer = window_dimmers_->Get(container); 346 WindowDimmer* window_dimmer = window_dimmers_->Get(container);
349 if (window_dimmer) { 347 if (window_dimmer) {
350 base::AutoReset<bool> auto_reset(&in_restacking_, true); 348 base::AutoReset<bool> auto_reset(&in_restacking_, true);
351 container->StackChildAtBottom(window_dimmer->window()); 349 container->StackChildAtBottom(window_dimmer->window());
352 } 350 }
353 } 351 }
354 352
355 } // namespace ash 353 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/screen_pinning_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698