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

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

Issue 2739553005: Moves maintaining root_window_for_new_windows_ to Shell (Closed)
Patch Set: remove ash:: 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_shell.h ('k') | ash/drag_drop/drag_drop_tracker_unittest.cc » ('j') | 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/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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "base/bind.h" 53 #include "base/bind.h"
54 #include "base/logging.h" 54 #include "base/logging.h"
55 #include "base/memory/ptr_util.h" 55 #include "base/memory/ptr_util.h"
56 #include "base/threading/sequenced_worker_pool.h" 56 #include "base/threading/sequenced_worker_pool.h"
57 #include "services/preferences/public/cpp/pref_client_store.h" 57 #include "services/preferences/public/cpp/pref_client_store.h"
58 #include "services/preferences/public/interfaces/preferences.mojom.h" 58 #include "services/preferences/public/interfaces/preferences.mojom.h"
59 #include "services/service_manager/public/cpp/connector.h" 59 #include "services/service_manager/public/cpp/connector.h"
60 #include "ui/app_list/presenter/app_list.h" 60 #include "ui/app_list/presenter/app_list.h"
61 #include "ui/display/display.h" 61 #include "ui/display/display.h"
62 #include "ui/views/focus/focus_manager_factory.h" 62 #include "ui/views/focus/focus_manager_factory.h"
63 #include "ui/wm/public/activation_client.h"
64 63
65 namespace ash { 64 namespace ash {
66 65
67 // static 66 // static
68 WmShell* WmShell::instance_ = nullptr; 67 WmShell* WmShell::instance_ = nullptr;
69 68
70 WmShell::~WmShell() { 69 WmShell::~WmShell() {
71 session_controller_->RemoveSessionStateObserver(this); 70 session_controller_->RemoveSessionStateObserver(this);
72 } 71 }
73 72
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get()); 106 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get());
108 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>( 107 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>(
109 "Ash", devtools_server_.get()); 108 "Ash", devtools_server_.get());
110 devtools_client->AddAgent(std::move(dom_backend)); 109 devtools_client->AddAgent(std::move(dom_backend));
111 devtools_client->AddAgent(std::move(css_backend)); 110 devtools_client->AddAgent(std::move(css_backend));
112 devtools_server_->AttachClient(std::move(devtools_client)); 111 devtools_server_->AttachClient(std::move(devtools_client));
113 } 112 }
114 } 113 }
115 114
116 void WmShell::Shutdown() { 115 void WmShell::Shutdown() {
117 Shell::GetInstance()->activation_client()->RemoveObserver(this);
118
119 // These members access WmShell in their destructors. 116 // These members access WmShell in their destructors.
120 wallpaper_controller_.reset(); 117 wallpaper_controller_.reset();
121 accessibility_delegate_.reset(); 118 accessibility_delegate_.reset();
122 119
123 // ShelfWindowWatcher has window observers and a pointer to the shelf model. 120 // ShelfWindowWatcher has window observers and a pointer to the shelf model.
124 shelf_window_watcher_.reset(); 121 shelf_window_watcher_.reset();
125 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC 122 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC
126 // shelf items in Chrome) so explicitly shutdown early. 123 // shelf items in Chrome) so explicitly shutdown early.
127 shelf_model()->DestroyItemDelegates(); 124 shelf_model()->DestroyItemDelegates();
128 // Must be destroyed before FocusClient. 125 // Must be destroyed before FocusClient.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 return; 288 return;
292 delegate_->GetShellConnector()->BindInterface(prefs::mojom::kServiceName, 289 delegate_->GetShellConnector()->BindInterface(prefs::mojom::kServiceName,
293 &pref_factory_ptr); 290 &pref_factory_ptr);
294 pref_store_ = new preferences::PrefClientStore(std::move(pref_factory_ptr)); 291 pref_store_ = new preferences::PrefClientStore(std::move(pref_factory_ptr));
295 } 292 }
296 293
297 RootWindowController* WmShell::GetPrimaryRootWindowController() { 294 RootWindowController* WmShell::GetPrimaryRootWindowController() {
298 return GetPrimaryRootWindow()->GetRootWindowController(); 295 return GetPrimaryRootWindow()->GetRootWindowController();
299 } 296 }
300 297
301 WmWindow* WmShell::GetRootWindowForNewWindows() {
302 if (scoped_root_window_for_new_windows_)
303 return scoped_root_window_for_new_windows_;
304 return root_window_for_new_windows_;
305 }
306
307 bool WmShell::IsForceMaximizeOnFirstRun() { 298 bool WmShell::IsForceMaximizeOnFirstRun() {
308 return delegate()->IsForceMaximizeOnFirstRun(); 299 return delegate()->IsForceMaximizeOnFirstRun();
309 } 300 }
310 301
311 bool WmShell::IsSystemModalWindowOpen() { 302 bool WmShell::IsSystemModalWindowOpen() {
312 if (simulate_modal_window_open_for_testing_) 303 if (simulate_modal_window_open_for_testing_)
313 return true; 304 return true;
314 305
315 // Traverse all system modal containers, and find its direct child window 306 // Traverse all system modal containers, and find its direct child window
316 // with "SystemModal" setting, and visible. 307 // with "SystemModal" setting, and visible.
(...skipping 30 matching lines...) Expand all
347 } 338 }
348 for (WmWindow* root_window : root_windows) { 339 for (WmWindow* root_window : root_windows) {
349 root_window->GetRootWindowController() 340 root_window->GetRootWindowController()
350 ->GetSystemModalLayoutManager(removed) 341 ->GetSystemModalLayoutManager(removed)
351 ->DestroyModalBackground(); 342 ->DestroyModalBackground();
352 } 343 }
353 } 344 }
354 345
355 void WmShell::ShowAppList() { 346 void WmShell::ShowAppList() {
356 // Show the app list on the default display for new windows. 347 // Show the app list on the default display for new windows.
357 app_list_->Show(GetRootWindowForNewWindows()->GetDisplayNearestWindow().id()); 348 app_list_->Show(
349 Shell::GetWmRootWindowForNewWindows()->GetDisplayNearestWindow().id());
358 } 350 }
359 351
360 void WmShell::DismissAppList() { 352 void WmShell::DismissAppList() {
361 app_list_->Dismiss(); 353 app_list_->Dismiss();
362 } 354 }
363 355
364 void WmShell::ToggleAppList() { 356 void WmShell::ToggleAppList() {
365 // Toggle the app list on the default display for new windows. 357 // Toggle the app list on the default display for new windows.
366 app_list_->ToggleAppList( 358 app_list_->ToggleAppList(
367 GetRootWindowForNewWindows()->GetDisplayNearestWindow().id()); 359 Shell::GetWmRootWindowForNewWindows()->GetDisplayNearestWindow().id());
368 } 360 }
369 361
370 bool WmShell::IsApplistVisible() const { 362 bool WmShell::IsApplistVisible() const {
371 return app_list_->IsVisible(); 363 return app_list_->IsVisible();
372 } 364 }
373 365
374 bool WmShell::GetAppListTargetVisibility() const { 366 bool WmShell::GetAppListTargetVisibility() const {
375 return app_list_->GetTargetVisibility(); 367 return app_list_->GetTargetVisibility();
376 } 368 }
377 369
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 accelerator_controller_ = std::move(accelerator_controller); 422 accelerator_controller_ = std::move(accelerator_controller);
431 } 423 }
432 424
433 void WmShell::SessionStateChanged(session_manager::SessionState state) { 425 void WmShell::SessionStateChanged(session_manager::SessionState state) {
434 // Create the shelf when a session becomes active. It's safe to do this 426 // Create the shelf when a session becomes active. It's safe to do this
435 // multiple times (e.g. initial login vs. multiprofile add session). 427 // multiple times (e.g. initial login vs. multiprofile add session).
436 if (state == session_manager::SessionState::ACTIVE) 428 if (state == session_manager::SessionState::ACTIVE)
437 CreateShelfView(); 429 CreateShelfView();
438 } 430 }
439 431
440 void WmShell::OnWindowActivated(
441 aura::client::ActivationChangeObserver::ActivationReason reason,
442 aura::Window* gained_active,
443 aura::Window* lost_active) {
444 // TODO(sky): Shell should implement ActivationChangeObserver, not WmShell.
445 WmWindow* gained_active_wm = WmWindow::Get(gained_active);
446 if (gained_active_wm)
447 set_root_window_for_new_windows(gained_active_wm->GetRootWindow());
448 }
449
450 } // namespace ash 432 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm_shell.h ('k') | ash/drag_drop/drag_drop_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698