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

Side by Side Diff: ash/shell.cc

Issue 2177663002: mash: Move ownership of ShelfDelegate to WmShell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix WallpaperManagerBrowserTest Created 4 years, 5 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/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "ash/accelerators/accelerator_controller_delegate_aura.h" 11 #include "ash/accelerators/accelerator_controller_delegate_aura.h"
12 #include "ash/accelerators/accelerator_delegate.h" 12 #include "ash/accelerators/accelerator_delegate.h"
13 #include "ash/accelerators/focus_manager_factory.h" 13 #include "ash/accelerators/focus_manager_factory.h"
14 #include "ash/aura/wm_shell_aura.h" 14 #include "ash/aura/wm_shell_aura.h"
15 #include "ash/aura/wm_window_aura.h" 15 #include "ash/aura/wm_window_aura.h"
16 #include "ash/autoclick/autoclick_controller.h" 16 #include "ash/autoclick/autoclick_controller.h"
17 #include "ash/common/accelerators/accelerator_controller.h" 17 #include "ash/common/accelerators/accelerator_controller.h"
18 #include "ash/common/ash_switches.h" 18 #include "ash/common/ash_switches.h"
19 #include "ash/common/gpu_support.h" 19 #include "ash/common/gpu_support.h"
20 #include "ash/common/keyboard/keyboard_ui.h" 20 #include "ash/common/keyboard/keyboard_ui.h"
21 #include "ash/common/login_status.h" 21 #include "ash/common/login_status.h"
22 #include "ash/common/pointer_watcher_delegate.h" 22 #include "ash/common/pointer_watcher_delegate.h"
23 #include "ash/common/session/session_state_delegate.h" 23 #include "ash/common/session/session_state_delegate.h"
24 #include "ash/common/shelf/app_list_shelf_item_delegate.h" 24 #include "ash/common/shelf/app_list_shelf_item_delegate.h"
25 #include "ash/common/shelf/shelf_delegate.h"
25 #include "ash/common/shelf/shelf_item_delegate.h" 26 #include "ash/common/shelf/shelf_item_delegate.h"
26 #include "ash/common/shelf/shelf_model.h" 27 #include "ash/common/shelf/shelf_model.h"
27 #include "ash/common/shell_delegate.h" 28 #include "ash/common/shell_delegate.h"
28 #include "ash/common/shell_window_ids.h" 29 #include "ash/common/shell_window_ids.h"
29 #include "ash/common/system/locale/locale_notification_controller.h" 30 #include "ash/common/system/locale/locale_notification_controller.h"
30 #include "ash/common/system/status_area_widget.h" 31 #include "ash/common/system/status_area_widget.h"
31 #include "ash/common/system/tray/system_tray_delegate.h" 32 #include "ash/common/system/tray/system_tray_delegate.h"
32 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 33 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
33 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" 34 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h"
34 #include "ash/common/wm/mru_window_tracker.h" 35 #include "ash/common/wm/mru_window_tracker.h"
(...skipping 15 matching lines...) Expand all
50 #include "ash/frame/custom_frame_view_ash.h" 51 #include "ash/frame/custom_frame_view_ash.h"
51 #include "ash/high_contrast/high_contrast_controller.h" 52 #include "ash/high_contrast/high_contrast_controller.h"
52 #include "ash/host/ash_window_tree_host_init_params.h" 53 #include "ash/host/ash_window_tree_host_init_params.h"
53 #include "ash/ime/input_method_event_handler.h" 54 #include "ash/ime/input_method_event_handler.h"
54 #include "ash/keyboard_uma_event_filter.h" 55 #include "ash/keyboard_uma_event_filter.h"
55 #include "ash/magnifier/magnification_controller.h" 56 #include "ash/magnifier/magnification_controller.h"
56 #include "ash/magnifier/partial_magnification_controller.h" 57 #include "ash/magnifier/partial_magnification_controller.h"
57 #include "ash/new_window_delegate.h" 58 #include "ash/new_window_delegate.h"
58 #include "ash/root_window_controller.h" 59 #include "ash/root_window_controller.h"
59 #include "ash/shelf/shelf.h" 60 #include "ash/shelf/shelf.h"
60 #include "ash/shelf/shelf_delegate.h"
61 #include "ash/shelf/shelf_widget.h" 61 #include "ash/shelf/shelf_widget.h"
62 #include "ash/shelf/shelf_window_watcher.h" 62 #include "ash/shelf/shelf_window_watcher.h"
63 #include "ash/shell_factory.h" 63 #include "ash/shell_factory.h"
64 #include "ash/shell_init_params.h" 64 #include "ash/shell_init_params.h"
65 #include "ash/utility/screenshot_controller.h" 65 #include "ash/utility/screenshot_controller.h"
66 #include "ash/wm/ash_focus_rules.h" 66 #include "ash/wm/ash_focus_rules.h"
67 #include "ash/wm/ash_native_cursor_manager.h" 67 #include "ash/wm/ash_native_cursor_manager.h"
68 #include "ash/wm/event_client_impl.h" 68 #include "ash/wm/event_client_impl.h"
69 #include "ash/wm/lock_state_controller.h" 69 #include "ash/wm/lock_state_controller.h"
70 #include "ash/wm/overlay_event_filter.h" 70 #include "ash/wm/overlay_event_filter.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 OnCastingSessionStartedOrStopped(started)); 365 OnCastingSessionStartedOrStopped(started));
366 #endif 366 #endif
367 } 367 }
368 368
369 void Shell::OnRootWindowAdded(WmWindow* root_window) { 369 void Shell::OnRootWindowAdded(WmWindow* root_window) {
370 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), 370 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(),
371 OnRootWindowAdded(root_window)); 371 OnRootWindowAdded(root_window));
372 } 372 }
373 373
374 void Shell::CreateShelf() { 374 void Shell::CreateShelf() {
375 // Must occur after SessionStateDelegate creation and user login.
msw 2016/07/23 00:02:37 Why? Move these checks into CreateShelfDelegate; c
James Cook 2016/07/23 00:38:03 Done and commented more on why.
376 DCHECK(session_state_delegate_);
377 DCHECK_GT(session_state_delegate_->NumberOfLoggedInUsers(), 0);
378 wm_shell_->CreateShelfDelegate();
379
380 // TODO(jamescook): This is here for historical reasons. Move it to WmShell.
381 // http://crbug.com/629257
382 if (!shelf_window_watcher_) {
383 shelf_window_watcher_.reset(
384 new ShelfWindowWatcher(wm_shell_->shelf_model()));
385 }
386
375 RootWindowControllerList controllers = GetAllRootWindowControllers(); 387 RootWindowControllerList controllers = GetAllRootWindowControllers();
376 for (RootWindowControllerList::iterator iter = controllers.begin(); 388 for (RootWindowControllerList::iterator iter = controllers.begin();
377 iter != controllers.end(); ++iter) 389 iter != controllers.end(); ++iter)
378 (*iter)->CreateShelf(); 390 (*iter)->CreateShelf();
379 } 391 }
380 392
381 void Shell::OnShelfCreatedForRootWindow(WmWindow* root_window) { 393 void Shell::OnShelfCreatedForRootWindow(WmWindow* root_window) {
382 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), 394 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(),
383 OnShelfCreatedForRootWindow(root_window)); 395 OnShelfCreatedForRootWindow(root_window));
384 } 396 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 508
497 bool Shell::HasPrimaryStatusArea() { 509 bool Shell::HasPrimaryStatusArea() {
498 ShelfWidget* shelf = GetPrimaryRootWindowController()->shelf_widget(); 510 ShelfWidget* shelf = GetPrimaryRootWindowController()->shelf_widget();
499 return shelf && shelf->status_area_widget(); 511 return shelf && shelf->status_area_widget();
500 } 512 }
501 513
502 SystemTray* Shell::GetPrimarySystemTray() { 514 SystemTray* Shell::GetPrimarySystemTray() {
503 return GetPrimaryRootWindowController()->GetSystemTray(); 515 return GetPrimaryRootWindowController()->GetSystemTray();
504 } 516 }
505 517
506 ShelfDelegate* Shell::GetShelfDelegate() {
507 if (!shelf_delegate_) {
508 ShelfModel* shelf_model = wm_shell_->shelf_model();
509 shelf_delegate_.reset(
510 wm_shell_->delegate()->CreateShelfDelegate(shelf_model));
511 shelf_window_watcher_.reset(new ShelfWindowWatcher(shelf_model));
512 }
513 return shelf_delegate_.get();
514 }
515
516 void Shell::SetTouchHudProjectionEnabled(bool enabled) { 518 void Shell::SetTouchHudProjectionEnabled(bool enabled) {
517 if (is_touch_hud_projection_enabled_ == enabled) 519 if (is_touch_hud_projection_enabled_ == enabled)
518 return; 520 return;
519 521
520 is_touch_hud_projection_enabled_ = enabled; 522 is_touch_hud_projection_enabled_ = enabled;
521 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), 523 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(),
522 OnTouchHudProjectionToggled(enabled)); 524 OnTouchHudProjectionToggled(enabled));
523 } 525 }
524 526
525 #if defined(OS_CHROMEOS) 527 #if defined(OS_CHROMEOS)
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // window observers. 663 // window observers.
662 shelf_window_watcher_.reset(); 664 shelf_window_watcher_.reset();
663 665
664 // Destroy all child windows including widgets. 666 // Destroy all child windows including widgets.
665 window_tree_host_manager_->CloseChildWindows(); 667 window_tree_host_manager_->CloseChildWindows();
666 // MruWindowTracker must be destroyed after all windows have been deleted to 668 // MruWindowTracker must be destroyed after all windows have been deleted to
667 // avoid a possible crash when Shell is destroyed from a non-normal shutdown 669 // avoid a possible crash when Shell is destroyed from a non-normal shutdown
668 // path. (crbug.com/485438). 670 // path. (crbug.com/485438).
669 wm_shell_->DeleteMruWindowTracker(); 671 wm_shell_->DeleteMruWindowTracker();
670 672
671 // Chrome implementation of shelf delegate depends on FocusClient,
672 // so must be deleted before |focus_client_| (below).
673 shelf_delegate_.reset();
674
675 // These need a valid Shell instance to clean up properly, so explicitly 673 // These need a valid Shell instance to clean up properly, so explicitly
676 // delete them before invalidating the instance. 674 // delete them before invalidating the instance.
677 // Alphabetical. TODO(oshima): sort. 675 // Alphabetical. TODO(oshima): sort.
678 magnification_controller_.reset(); 676 magnification_controller_.reset();
679 partial_magnification_controller_.reset(); 677 partial_magnification_controller_.reset();
680 tooltip_controller_.reset(); 678 tooltip_controller_.reset();
681 event_client_.reset(); 679 event_client_.reset();
682 toplevel_window_event_handler_.reset(); 680 toplevel_window_event_handler_.reset();
683 visibility_controller_.reset(); 681 visibility_controller_.reset();
684 682
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1106
1109 void Shell::OnWindowActivated( 1107 void Shell::OnWindowActivated(
1110 aura::client::ActivationChangeObserver::ActivationReason reason, 1108 aura::client::ActivationChangeObserver::ActivationReason reason,
1111 aura::Window* gained_active, 1109 aura::Window* gained_active,
1112 aura::Window* lost_active) { 1110 aura::Window* lost_active) {
1113 if (gained_active) 1111 if (gained_active)
1114 target_root_window_ = gained_active->GetRootWindow(); 1112 target_root_window_ = gained_active->GetRootWindow();
1115 } 1113 }
1116 1114
1117 } // namespace ash 1115 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698