| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 400 } |
| 402 | 401 |
| 403 FirstRunHelper* Shell::CreateFirstRunHelper() { | 402 FirstRunHelper* Shell::CreateFirstRunHelper() { |
| 404 return new FirstRunHelperImpl; | 403 return new FirstRunHelperImpl; |
| 405 } | 404 } |
| 406 | 405 |
| 407 void Shell::CreateShelfView() { | 406 void Shell::CreateShelfView() { |
| 408 // Must occur after SessionController creation and user login. | 407 // Must occur after SessionController creation and user login. |
| 409 DCHECK(session_controller()); | 408 DCHECK(session_controller()); |
| 410 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0); | 409 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0); |
| 411 CreateShelfDelegate(); | |
| 412 | 410 |
| 411 // Notify the ShellDelegate that the shelf is being initialized. |
| 412 // TODO(msw): Refine ChromeLauncherControllerImpl lifetime management. |
| 413 shell_delegate_->ShelfInit(); |
| 414 |
| 415 if (!shelf_window_watcher_) |
| 416 shelf_window_watcher_ = base::MakeUnique<ShelfWindowWatcher>(shelf_model()); |
| 413 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) | 417 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) |
| 414 root_window->GetRootWindowController()->CreateShelfView(); | 418 root_window->GetRootWindowController()->CreateShelfView(); |
| 415 } | 419 } |
| 416 | 420 |
| 417 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { | 421 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { |
| 418 window_tree_host_manager_->cursor_window_controller() | 422 window_tree_host_manager_->cursor_window_controller() |
| 419 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); | 423 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); |
| 420 } | 424 } |
| 421 | 425 |
| 422 void Shell::SetCursorCompositingEnabled(bool enabled) { | 426 void Shell::SetCursorCompositingEnabled(bool enabled) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 // Balances the Install() in Initialize(). | 721 // Balances the Install() in Initialize(). |
| 718 views::FocusManagerFactory::Install(nullptr); | 722 views::FocusManagerFactory::Install(nullptr); |
| 719 | 723 |
| 720 // ShelfWindowWatcher has window observers and a pointer to the shelf model. | 724 // ShelfWindowWatcher has window observers and a pointer to the shelf model. |
| 721 shelf_window_watcher_.reset(); | 725 shelf_window_watcher_.reset(); |
| 722 | 726 |
| 723 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC | 727 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC |
| 724 // shelf items in Chrome) so explicitly shutdown early. | 728 // shelf items in Chrome) so explicitly shutdown early. |
| 725 shelf_model()->DestroyItemDelegates(); | 729 shelf_model()->DestroyItemDelegates(); |
| 726 | 730 |
| 727 // Must be destroyed before FocusController. | 731 // Notify the ShellDelegate that the shelf is shutting down. |
| 728 shelf_delegate_.reset(); | 732 // TODO(msw): Refine ChromeLauncherControllerImpl lifetime management. |
| 733 shell_delegate_->ShelfShutdown(); |
| 729 | 734 |
| 730 // Removes itself as an observer of |pref_service_|. | 735 // Removes itself as an observer of |pref_service_|. |
| 731 shelf_controller_.reset(); | 736 shelf_controller_.reset(); |
| 732 | 737 |
| 733 shell_port_->Shutdown(); | 738 shell_port_->Shutdown(); |
| 734 | 739 |
| 735 // Depends on |focus_controller_|, so must be destroyed before. | 740 // Depends on |focus_controller_|, so must be destroyed before. |
| 736 window_tree_host_manager_.reset(); | 741 window_tree_host_manager_.reset(); |
| 737 focus_controller_->RemoveObserver(this); | 742 focus_controller_->RemoveObserver(this); |
| 738 focus_controller_.reset(); | 743 focus_controller_.reset(); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 controller->CloseChildWindows(); | 1159 controller->CloseChildWindows(); |
| 1155 } else { | 1160 } else { |
| 1156 while (!root_window->children().empty()) { | 1161 while (!root_window->children().empty()) { |
| 1157 aura::Window* child = root_window->children()[0]; | 1162 aura::Window* child = root_window->children()[0]; |
| 1158 delete child; | 1163 delete child; |
| 1159 } | 1164 } |
| 1160 } | 1165 } |
| 1161 } | 1166 } |
| 1162 } | 1167 } |
| 1163 | 1168 |
| 1164 void Shell::CreateShelfDelegate() { | |
| 1165 // May be called multiple times as shelves are created and destroyed. | |
| 1166 if (shelf_delegate_) | |
| 1167 return; | |
| 1168 // Must occur after SessionController creation and user login because | |
| 1169 // Chrome's implementation of ShelfDelegate assumes it can get information | |
| 1170 // about multi-profile login state. | |
| 1171 DCHECK(session_controller()); | |
| 1172 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0); | |
| 1173 shelf_delegate_.reset(shell_delegate_->CreateShelfDelegate(shelf_model())); | |
| 1174 shelf_window_watcher_ = base::MakeUnique<ShelfWindowWatcher>(shelf_model()); | |
| 1175 } | |
| 1176 | |
| 1177 bool Shell::CanWindowReceiveEvents(aura::Window* window) { | 1169 bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 1178 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 1170 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 1179 for (RootWindowController* controller : controllers) { | 1171 for (RootWindowController* controller : controllers) { |
| 1180 if (controller->CanWindowReceiveEvents(window)) | 1172 if (controller->CanWindowReceiveEvents(window)) |
| 1181 return true; | 1173 return true; |
| 1182 } | 1174 } |
| 1183 return false; | 1175 return false; |
| 1184 } | 1176 } |
| 1185 | 1177 |
| 1186 //////////////////////////////////////////////////////////////////////////////// | 1178 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 void Shell::OnPrefServiceInitialized( | 1236 void Shell::OnPrefServiceInitialized( |
| 1245 std::unique_ptr<::PrefService> pref_service) { | 1237 std::unique_ptr<::PrefService> pref_service) { |
| 1246 if (!instance_) | 1238 if (!instance_) |
| 1247 return; | 1239 return; |
| 1248 // |pref_service_| is null if can't connect to Chrome (as happens when | 1240 // |pref_service_| is null if can't connect to Chrome (as happens when |
| 1249 // running mash outside of chrome --mash and chrome isn't built). | 1241 // running mash outside of chrome --mash and chrome isn't built). |
| 1250 pref_service_ = std::move(pref_service); | 1242 pref_service_ = std::move(pref_service); |
| 1251 } | 1243 } |
| 1252 | 1244 |
| 1253 } // namespace ash | 1245 } // namespace ash |
| OLD | NEW |