Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 #include "ash/magnifier/partial_magnification_controller.h" | 48 #include "ash/magnifier/partial_magnification_controller.h" |
| 49 #include "ash/media_controller.h" | 49 #include "ash/media_controller.h" |
| 50 #include "ash/new_window_controller.h" | 50 #include "ash/new_window_controller.h" |
| 51 #include "ash/palette_delegate.h" | 51 #include "ash/palette_delegate.h" |
| 52 #include "ash/public/cpp/config.h" | 52 #include "ash/public/cpp/config.h" |
| 53 #include "ash/public/cpp/shell_window_ids.h" | 53 #include "ash/public/cpp/shell_window_ids.h" |
| 54 #include "ash/root_window_controller.h" | 54 #include "ash/root_window_controller.h" |
| 55 #include "ash/session/session_controller.h" | 55 #include "ash/session/session_controller.h" |
| 56 #include "ash/session/session_state_delegate.h" | 56 #include "ash/session/session_state_delegate.h" |
| 57 #include "ash/shelf/shelf_controller.h" | 57 #include "ash/shelf/shelf_controller.h" |
| 58 #include "ash/shelf/shelf_delegate.h" | |
| 59 #include "ash/shelf/shelf_model.h" | 58 #include "ash/shelf/shelf_model.h" |
| 60 #include "ash/shelf/shelf_window_watcher.h" | 59 #include "ash/shelf/shelf_window_watcher.h" |
| 61 #include "ash/shelf/wm_shelf.h" | 60 #include "ash/shelf/wm_shelf.h" |
| 62 #include "ash/shell_delegate.h" | 61 #include "ash/shell_delegate.h" |
| 63 #include "ash/shell_init_params.h" | 62 #include "ash/shell_init_params.h" |
| 64 #include "ash/shell_observer.h" | 63 #include "ash/shell_observer.h" |
| 65 #include "ash/shell_port.h" | 64 #include "ash/shell_port.h" |
| 66 #include "ash/shutdown_controller.h" | 65 #include "ash/shutdown_controller.h" |
| 67 #include "ash/sticky_keys/sticky_keys_controller.h" | 66 #include "ash/sticky_keys/sticky_keys_controller.h" |
| 68 #include "ash/system/bluetooth/bluetooth_notification_controller.h" | 67 #include "ash/system/bluetooth/bluetooth_notification_controller.h" |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 } | 405 } |
| 407 | 406 |
| 408 FirstRunHelper* Shell::CreateFirstRunHelper() { | 407 FirstRunHelper* Shell::CreateFirstRunHelper() { |
| 409 return new FirstRunHelperImpl; | 408 return new FirstRunHelperImpl; |
| 410 } | 409 } |
| 411 | 410 |
| 412 void Shell::CreateShelfView() { | 411 void Shell::CreateShelfView() { |
| 413 // Must occur after SessionController creation and user login. | 412 // Must occur after SessionController creation and user login. |
| 414 DCHECK(session_controller()); | 413 DCHECK(session_controller()); |
| 415 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0); | 414 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0); |
| 416 CreateShelfDelegate(); | |
| 417 | 415 |
| 416 // Notify the ShellDelegate that the shelf is being initialized. | |
| 417 // TODO(msw): Refine ChromeLauncherControllerImpl lifetime management. | |
| 418 shell_delegate_->ShelfInit(); | |
|
James Cook
2017/04/19 00:23:47
Aside: It's unfortunate that ShelfInit() code has
msw
2017/04/19 20:56:06
Acknowledged.
| |
| 419 | |
| 420 if (!shelf_window_watcher_) | |
| 421 shelf_window_watcher_ = base::MakeUnique<ShelfWindowWatcher>(shelf_model()); | |
| 418 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) | 422 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) |
| 419 root_window->GetRootWindowController()->CreateShelfView(); | 423 root_window->GetRootWindowController()->CreateShelfView(); |
| 420 } | 424 } |
| 421 | 425 |
| 422 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { | 426 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { |
| 423 window_tree_host_manager_->cursor_window_controller() | 427 window_tree_host_manager_->cursor_window_controller() |
| 424 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); | 428 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); |
| 425 } | 429 } |
| 426 | 430 |
| 427 void Shell::SetCursorCompositingEnabled(bool enabled) { | 431 void Shell::SetCursorCompositingEnabled(bool enabled) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 // Balances the Install() in Initialize(). | 724 // Balances the Install() in Initialize(). |
| 721 views::FocusManagerFactory::Install(nullptr); | 725 views::FocusManagerFactory::Install(nullptr); |
| 722 | 726 |
| 723 // ShelfWindowWatcher has window observers and a pointer to the shelf model. | 727 // ShelfWindowWatcher has window observers and a pointer to the shelf model. |
| 724 shelf_window_watcher_.reset(); | 728 shelf_window_watcher_.reset(); |
| 725 | 729 |
| 726 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC | 730 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC |
| 727 // shelf items in Chrome) so explicitly shutdown early. | 731 // shelf items in Chrome) so explicitly shutdown early. |
| 728 shelf_model()->DestroyItemDelegates(); | 732 shelf_model()->DestroyItemDelegates(); |
| 729 | 733 |
| 730 // Must be destroyed before FocusController. | 734 // Notify the ShellDelegate that the shelf is shutting down. |
| 731 shelf_delegate_.reset(); | 735 // TODO(msw): Refine ChromeLauncherControllerImpl lifetime management. |
| 736 shell_delegate_->ShelfShutdown(); | |
| 732 | 737 |
| 733 // Removes itself as an observer of |pref_service_|. | 738 // Removes itself as an observer of |pref_service_|. |
| 734 shelf_controller_.reset(); | 739 shelf_controller_.reset(); |
| 735 | 740 |
| 736 shell_port_->Shutdown(); | 741 shell_port_->Shutdown(); |
| 737 | 742 |
| 738 // Depends on |focus_controller_|, so must be destroyed before. | 743 // Depends on |focus_controller_|, so must be destroyed before. |
| 739 window_tree_host_manager_.reset(); | 744 window_tree_host_manager_.reset(); |
| 740 focus_controller_->RemoveObserver(this); | 745 focus_controller_->RemoveObserver(this); |
| 741 focus_controller_.reset(); | 746 focus_controller_.reset(); |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1160 controller->CloseChildWindows(); | 1165 controller->CloseChildWindows(); |
| 1161 } else { | 1166 } else { |
| 1162 while (!root_window->children().empty()) { | 1167 while (!root_window->children().empty()) { |
| 1163 aura::Window* child = root_window->children()[0]; | 1168 aura::Window* child = root_window->children()[0]; |
| 1164 delete child; | 1169 delete child; |
| 1165 } | 1170 } |
| 1166 } | 1171 } |
| 1167 } | 1172 } |
| 1168 } | 1173 } |
| 1169 | 1174 |
| 1170 void Shell::CreateShelfDelegate() { | |
| 1171 // May be called multiple times as shelves are created and destroyed. | |
| 1172 if (shelf_delegate_) | |
| 1173 return; | |
| 1174 // Must occur after SessionController creation and user login because | |
| 1175 // Chrome's implementation of ShelfDelegate assumes it can get information | |
| 1176 // about multi-profile login state. | |
| 1177 DCHECK(session_controller()); | |
| 1178 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0); | |
| 1179 shelf_delegate_.reset(shell_delegate_->CreateShelfDelegate(shelf_model())); | |
| 1180 shelf_window_watcher_ = base::MakeUnique<ShelfWindowWatcher>(shelf_model()); | |
| 1181 } | |
| 1182 | |
| 1183 bool Shell::CanWindowReceiveEvents(aura::Window* window) { | 1175 bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 1184 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 1176 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 1185 for (RootWindowController* controller : controllers) { | 1177 for (RootWindowController* controller : controllers) { |
| 1186 if (controller->CanWindowReceiveEvents(window)) | 1178 if (controller->CanWindowReceiveEvents(window)) |
| 1187 return true; | 1179 return true; |
| 1188 } | 1180 } |
| 1189 return false; | 1181 return false; |
| 1190 } | 1182 } |
| 1191 | 1183 |
| 1192 //////////////////////////////////////////////////////////////////////////////// | 1184 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1258 void Shell::OnPrefServiceInitialized( | 1250 void Shell::OnPrefServiceInitialized( |
| 1259 std::unique_ptr<::PrefService> pref_service) { | 1251 std::unique_ptr<::PrefService> pref_service) { |
| 1260 if (!instance_) | 1252 if (!instance_) |
| 1261 return; | 1253 return; |
| 1262 // |pref_service_| is null if can't connect to Chrome (as happens when | 1254 // |pref_service_| is null if can't connect to Chrome (as happens when |
| 1263 // running mash outside of chrome --mash and chrome isn't built). | 1255 // running mash outside of chrome --mash and chrome isn't built). |
| 1264 pref_service_ = std::move(pref_service); | 1256 pref_service_ = std::move(pref_service); |
| 1265 } | 1257 } |
| 1266 | 1258 |
| 1267 } // namespace ash | 1259 } // namespace ash |
| OLD | NEW |