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

Side by Side Diff: ash/common/wm_shell.cc

Issue 2736753005: Converts WmActivationObserver to aura::client::ActivationChangeObserver (Closed)
Patch Set: cleanup 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
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/common/wm_shell.h" 5 #include "ash/common/wm_shell.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
10 #include "ash/common/accelerators/ash_focus_manager_factory.h" 10 #include "ash/common/accelerators/ash_focus_manager_factory.h"
(...skipping 28 matching lines...) Expand all
39 #include "ash/common/system/tray/system_tray_notifier.h" 39 #include "ash/common/system/tray/system_tray_notifier.h"
40 #include "ash/common/wallpaper/wallpaper_controller.h" 40 #include "ash/common/wallpaper/wallpaper_controller.h"
41 #include "ash/common/wallpaper/wallpaper_delegate.h" 41 #include "ash/common/wallpaper/wallpaper_delegate.h"
42 #include "ash/common/wm/immersive_context_ash.h" 42 #include "ash/common/wm/immersive_context_ash.h"
43 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 43 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
44 #include "ash/common/wm/mru_window_tracker.h" 44 #include "ash/common/wm/mru_window_tracker.h"
45 #include "ash/common/wm/overview/window_selector_controller.h" 45 #include "ash/common/wm/overview/window_selector_controller.h"
46 #include "ash/common/wm/root_window_finder.h" 46 #include "ash/common/wm/root_window_finder.h"
47 #include "ash/common/wm/system_modal_container_layout_manager.h" 47 #include "ash/common/wm/system_modal_container_layout_manager.h"
48 #include "ash/common/wm/window_cycle_controller.h" 48 #include "ash/common/wm/window_cycle_controller.h"
49 #include "ash/common/wm_activation_observer.h"
50 #include "ash/common/wm_window.h" 49 #include "ash/common/wm_window.h"
51 #include "ash/public/cpp/shell_window_ids.h" 50 #include "ash/public/cpp/shell_window_ids.h"
52 #include "ash/root_window_controller.h" 51 #include "ash/root_window_controller.h"
53 #include "ash/shell.h" 52 #include "ash/shell.h"
54 #include "base/bind.h" 53 #include "base/bind.h"
55 #include "base/logging.h" 54 #include "base/logging.h"
56 #include "base/memory/ptr_util.h" 55 #include "base/memory/ptr_util.h"
57 #include "base/threading/sequenced_worker_pool.h" 56 #include "base/threading/sequenced_worker_pool.h"
58 #include "services/preferences/public/cpp/pref_client_store.h" 57 #include "services/preferences/public/cpp/pref_client_store.h"
59 #include "services/preferences/public/interfaces/preferences.mojom.h" 58 #include "services/preferences/public/interfaces/preferences.mojom.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get()); 107 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get());
109 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>( 108 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>(
110 "Ash", devtools_server_.get()); 109 "Ash", devtools_server_.get());
111 devtools_client->AddAgent(std::move(dom_backend)); 110 devtools_client->AddAgent(std::move(dom_backend));
112 devtools_client->AddAgent(std::move(css_backend)); 111 devtools_client->AddAgent(std::move(css_backend));
113 devtools_server_->AttachClient(std::move(devtools_client)); 112 devtools_server_->AttachClient(std::move(devtools_client));
114 } 113 }
115 } 114 }
116 115
117 void WmShell::Shutdown() { 116 void WmShell::Shutdown() {
118 if (added_activation_observer_) 117 Shell::GetInstance()->activation_client()->RemoveObserver(this);
119 Shell::GetInstance()->activation_client()->RemoveObserver(this);
120 118
121 // These members access WmShell in their destructors. 119 // These members access WmShell in their destructors.
122 wallpaper_controller_.reset(); 120 wallpaper_controller_.reset();
123 accessibility_delegate_.reset(); 121 accessibility_delegate_.reset();
124 122
125 // ShelfWindowWatcher has window observers and a pointer to the shelf model. 123 // ShelfWindowWatcher has window observers and a pointer to the shelf model.
126 shelf_window_watcher_.reset(); 124 shelf_window_watcher_.reset();
127 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC 125 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC
128 // shelf items in Chrome) so explicitly shutdown early. 126 // shelf items in Chrome) so explicitly shutdown early.
129 shelf_model()->DestroyItemDelegates(); 127 shelf_model()->DestroyItemDelegates();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 void WmShell::NotifyShelfAlignmentChanged(WmWindow* root_window) { 221 void WmShell::NotifyShelfAlignmentChanged(WmWindow* root_window) {
224 for (auto& observer : shell_observers_) 222 for (auto& observer : shell_observers_)
225 observer.OnShelfAlignmentChanged(root_window); 223 observer.OnShelfAlignmentChanged(root_window);
226 } 224 }
227 225
228 void WmShell::NotifyShelfAutoHideBehaviorChanged(WmWindow* root_window) { 226 void WmShell::NotifyShelfAutoHideBehaviorChanged(WmWindow* root_window) {
229 for (auto& observer : shell_observers_) 227 for (auto& observer : shell_observers_)
230 observer.OnShelfAutoHideBehaviorChanged(root_window); 228 observer.OnShelfAutoHideBehaviorChanged(root_window);
231 } 229 }
232 230
233 void WmShell::AddActivationObserver(WmActivationObserver* observer) {
234 if (!added_activation_observer_) {
235 added_activation_observer_ = true;
236 Shell::GetInstance()->activation_client()->AddObserver(this);
237 }
238 activation_observers_.AddObserver(observer);
239 }
240
241 void WmShell::RemoveActivationObserver(WmActivationObserver* observer) {
242 activation_observers_.RemoveObserver(observer);
243 }
244
245 void WmShell::AddShellObserver(ShellObserver* observer) { 231 void WmShell::AddShellObserver(ShellObserver* observer) {
246 shell_observers_.AddObserver(observer); 232 shell_observers_.AddObserver(observer);
247 } 233 }
248 234
249 void WmShell::RemoveShellObserver(ShellObserver* observer) { 235 void WmShell::RemoveShellObserver(ShellObserver* observer) {
250 shell_observers_.RemoveObserver(observer); 236 shell_observers_.RemoveObserver(observer);
251 } 237 }
252 238
253 void WmShell::OnLockStateEvent(LockStateObserver::EventType event) { 239 void WmShell::OnLockStateEvent(LockStateObserver::EventType event) {
254 for (auto& observer : lock_state_observers_) 240 for (auto& observer : lock_state_observers_)
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // Create the shelf when a session becomes active. It's safe to do this 434 // Create the shelf when a session becomes active. It's safe to do this
449 // multiple times (e.g. initial login vs. multiprofile add session). 435 // multiple times (e.g. initial login vs. multiprofile add session).
450 if (state == session_manager::SessionState::ACTIVE) 436 if (state == session_manager::SessionState::ACTIVE)
451 CreateShelfView(); 437 CreateShelfView();
452 } 438 }
453 439
454 void WmShell::OnWindowActivated( 440 void WmShell::OnWindowActivated(
455 aura::client::ActivationChangeObserver::ActivationReason reason, 441 aura::client::ActivationChangeObserver::ActivationReason reason,
456 aura::Window* gained_active, 442 aura::Window* gained_active,
457 aura::Window* lost_active) { 443 aura::Window* lost_active) {
444 // TODO(sky): Shell should implement ActivationChangeObserver, not WmShell.
458 WmWindow* gained_active_wm = WmWindow::Get(gained_active); 445 WmWindow* gained_active_wm = WmWindow::Get(gained_active);
459 WmWindow* lost_active_wm = WmWindow::Get(lost_active);
460 if (gained_active_wm) 446 if (gained_active_wm)
461 set_root_window_for_new_windows(gained_active_wm->GetRootWindow()); 447 set_root_window_for_new_windows(gained_active_wm->GetRootWindow());
462 for (auto& observer : activation_observers_)
463 observer.OnWindowActivated(gained_active_wm, lost_active_wm);
464 }
465
466 void WmShell::OnAttemptToReactivateWindow(aura::Window* request_active,
467 aura::Window* actual_active) {
468 for (auto& observer : activation_observers_) {
469 observer.OnAttemptToReactivateWindow(WmWindow::Get(request_active),
470 WmWindow::Get(actual_active));
471 }
472 } 448 }
473 449
474 } // namespace ash 450 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698