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

Side by Side Diff: ash/shell.cc

Issue 2889673002: chromeos: Refactor shelf to create ShelfView earlier in startup (Closed)
Patch Set: Move ShelfView to initializer list Created 3 years, 7 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
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 412
413 is_touch_hud_projection_enabled_ = enabled; 413 is_touch_hud_projection_enabled_ = enabled;
414 for (auto& observer : shell_observers_) 414 for (auto& observer : shell_observers_)
415 observer.OnTouchHudProjectionToggled(enabled); 415 observer.OnTouchHudProjectionToggled(enabled);
416 } 416 }
417 417
418 FirstRunHelper* Shell::CreateFirstRunHelper() { 418 FirstRunHelper* Shell::CreateFirstRunHelper() {
419 return new FirstRunHelperImpl; 419 return new FirstRunHelperImpl;
420 } 420 }
421 421
422 void Shell::CreateShelfView() {
423 // Must occur after SessionController creation and user login.
424 DCHECK(session_controller());
425 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0);
426
427 // Notify the ShellDelegate that the shelf is being initialized.
428 // TODO(msw): Refine ChromeLauncherController lifetime management.
429 shell_delegate_->ShelfInit();
430
431 if (!shelf_window_watcher_)
432 shelf_window_watcher_ = base::MakeUnique<ShelfWindowWatcher>(shelf_model());
433 for (WmWindow* root_window : shell_port_->GetAllRootWindows())
434 root_window->GetRootWindowController()->CreateShelfView();
435 }
436
437 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { 422 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) {
438 window_tree_host_manager_->cursor_window_controller() 423 window_tree_host_manager_->cursor_window_controller()
439 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); 424 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip);
440 } 425 }
441 426
442 void Shell::SetCursorCompositingEnabled(bool enabled) { 427 void Shell::SetCursorCompositingEnabled(bool enabled) {
443 if (GetAshConfig() == Config::CLASSIC) { 428 if (GetAshConfig() == Config::CLASSIC) {
444 // TODO: needs to work in mus. http://crbug.com/705592. 429 // TODO: needs to work in mus. http://crbug.com/705592.
445 window_tree_host_manager_->cursor_window_controller() 430 window_tree_host_manager_->cursor_window_controller()
446 ->SetCursorCompositingEnabled(enabled); 431 ->SetCursorCompositingEnabled(enabled);
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 void Shell::OnWindowActivated( 1210 void Shell::OnWindowActivated(
1226 aura::client::ActivationChangeObserver::ActivationReason reason, 1211 aura::client::ActivationChangeObserver::ActivationReason reason,
1227 aura::Window* gained_active, 1212 aura::Window* gained_active,
1228 aura::Window* lost_active) { 1213 aura::Window* lost_active) {
1229 WmWindow* gained_active_wm = WmWindow::Get(gained_active); 1214 WmWindow* gained_active_wm = WmWindow::Get(gained_active);
1230 if (gained_active_wm) 1215 if (gained_active_wm)
1231 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); 1216 root_window_for_new_windows_ = gained_active_wm->GetRootWindow();
1232 } 1217 }
1233 1218
1234 void Shell::OnSessionStateChanged(session_manager::SessionState state) { 1219 void Shell::OnSessionStateChanged(session_manager::SessionState state) {
1235 // Create the shelf when a session becomes active. It's safe to do this 1220 // Finalize the shelf when a session becomes active. It's safe to do this
msw 2017/05/16 22:42:00 nit: s/Finalize/Initialize/?
1236 // multiple times (e.g. initial login vs. multiprofile add session). 1221 // multiple times (e.g. initial login vs. multiprofile add session).
1237 if (state == session_manager::SessionState::ACTIVE) { 1222 if (state == session_manager::SessionState::ACTIVE) {
1238 CreateShelfView(); 1223 InitializeShelf();
1239
1240 if (GetAshConfig() != Config::MASH) { 1224 if (GetAshConfig() != Config::MASH) {
1241 // Recreate the keyboard after initial login and after multiprofile login. 1225 // Recreate the keyboard after initial login and after multiprofile login.
1242 CreateKeyboard(); 1226 CreateKeyboard();
1243 } 1227 }
1244 } 1228 }
1245 } 1229 }
1246 1230
1247 void Shell::OnLoginStatusChanged(LoginStatus login_status) { 1231 void Shell::OnLoginStatusChanged(LoginStatus login_status) {
1248 UpdateAfterLoginStatusChange(login_status); 1232 UpdateAfterLoginStatusChange(login_status);
1249 } 1233 }
1250 1234
1251 void Shell::OnLockStateChanged(bool locked) { 1235 void Shell::OnLockStateChanged(bool locked) {
1252 #ifndef NDEBUG 1236 #ifndef NDEBUG
1253 // Make sure that there is no system modal in Lock layer when unlocked. 1237 // Make sure that there is no system modal in Lock layer when unlocked.
1254 if (!locked) { 1238 if (!locked) {
1255 aura::Window::Windows containers = wm::GetContainersFromAllRootWindows( 1239 aura::Window::Windows containers = wm::GetContainersFromAllRootWindows(
1256 kShellWindowId_LockSystemModalContainer, GetPrimaryRootWindow()); 1240 kShellWindowId_LockSystemModalContainer, GetPrimaryRootWindow());
1257 for (aura::Window* container : containers) 1241 for (aura::Window* container : containers)
1258 DCHECK(container->children().empty()); 1242 DCHECK(container->children().empty());
1259 } 1243 }
1260 #endif 1244 #endif
1261 } 1245 }
1262 1246
1247 void Shell::InitializeShelf() {
1248 // Must occur after SessionController creation and user login.
1249 DCHECK(session_controller());
1250 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0);
1251
1252 // Notify the ShellDelegate that the shelf is being initialized.
1253 // TODO(msw): Refine ChromeLauncherController lifetime management.
1254 shell_delegate_->ShelfInit();
1255
1256 if (!shelf_window_watcher_)
1257 shelf_window_watcher_ = base::MakeUnique<ShelfWindowWatcher>(shelf_model());
1258 for (WmWindow* root_window : shell_port_->GetAllRootWindows())
msw 2017/05/16 22:42:00 optional nit: avoid WmWindow usage.
James Cook 2017/05/17 16:16:13 Done.
1259 root_window->GetRootWindowController()->InitializeShelf();
1260 }
1261
1263 void Shell::OnPrefServiceInitialized( 1262 void Shell::OnPrefServiceInitialized(
1264 std::unique_ptr<::PrefService> pref_service) { 1263 std::unique_ptr<::PrefService> pref_service) {
1265 if (!instance_) 1264 if (!instance_)
1266 return; 1265 return;
1267 // |pref_service_| is null if can't connect to Chrome (as happens when 1266 // |pref_service_| is null if can't connect to Chrome (as happens when
1268 // running mash outside of chrome --mash and chrome isn't built). 1267 // running mash outside of chrome --mash and chrome isn't built).
1269 pref_service_ = std::move(pref_service); 1268 pref_service_ = std::move(pref_service);
1270 } 1269 }
1271 1270
1272 } // namespace ash 1271 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698