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

Side by Side Diff: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc

Issue 890293002: Fixing crash upon window manager creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" 5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/multi_profile_uma.h" 8 #include "ash/multi_profile_uma.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/session/session_state_delegate.h" 10 #include "ash/session/session_state_delegate.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 DISALLOW_COPY_AND_ASSIGN(AppObserver); 208 DISALLOW_COPY_AND_ASSIGN(AppObserver);
209 }; 209 };
210 210
211 MultiUserWindowManagerChromeOS::MultiUserWindowManagerChromeOS( 211 MultiUserWindowManagerChromeOS::MultiUserWindowManagerChromeOS(
212 const std::string& current_user_id) 212 const std::string& current_user_id)
213 : current_user_id_(current_user_id), 213 : current_user_id_(current_user_id),
214 notification_blocker_(new MultiUserNotificationBlockerChromeOS( 214 notification_blocker_(new MultiUserNotificationBlockerChromeOS(
215 message_center::MessageCenter::Get(), current_user_id)), 215 message_center::MessageCenter::Get(), current_user_id)),
216 suppress_visibility_changes_(false), 216 suppress_visibility_changes_(false),
217 animation_speed_(ANIMATION_SPEED_NORMAL) { 217 animation_speed_(ANIMATION_SPEED_NORMAL) {
218 // Add a session state observer to be able to monitor session changes.
219 if (ash::Shell::HasInstance())
220 ash::Shell::GetInstance()->session_state_delegate()->
221 AddSessionStateObserver(this);
222
223 // The BrowserListObserver would have been better to use then the old
224 // notification system, but that observer fires before the window got created.
225 registrar_.Add(this, NOTIFICATION_BROWSER_WINDOW_READY,
226 content::NotificationService::AllSources());
227
228 // Add an app window observer & all already running apps.
229 Profile* profile = multi_user_util::GetProfileFromUserID(current_user_id);
230 if (profile)
231 AddUser(profile);
232 } 218 }
233 219
234 MultiUserWindowManagerChromeOS::~MultiUserWindowManagerChromeOS() { 220 MultiUserWindowManagerChromeOS::~MultiUserWindowManagerChromeOS() {
235 // When the MultiUserWindowManager gets destroyed, ash::Shell is mostly gone. 221 // When the MultiUserWindowManager gets destroyed, ash::Shell is mostly gone.
236 // As such we should not try to finalize any outstanding user animations. 222 // As such we should not try to finalize any outstanding user animations.
237 // Note that the destruction of the object can be done later. 223 // Note that the destruction of the object can be done later.
238 if (animation_.get()) 224 if (animation_.get())
239 animation_->CancelAnimation(); 225 animation_->CancelAnimation();
240 226
241 // Remove all window observers. 227 // Remove all window observers.
(...skipping 15 matching lines...) Expand all
257 delete app_observer_iterator->second; 243 delete app_observer_iterator->second;
258 user_id_to_app_observer_.erase(app_observer_iterator); 244 user_id_to_app_observer_.erase(app_observer_iterator);
259 app_observer_iterator = user_id_to_app_observer_.begin(); 245 app_observer_iterator = user_id_to_app_observer_.begin();
260 } 246 }
261 247
262 if (ash::Shell::HasInstance()) 248 if (ash::Shell::HasInstance())
263 ash::Shell::GetInstance()->session_state_delegate()-> 249 ash::Shell::GetInstance()->session_state_delegate()->
264 RemoveSessionStateObserver(this); 250 RemoveSessionStateObserver(this);
265 } 251 }
266 252
253 void MultiUserWindowManagerChromeOS::Init() {
254 // We should call this function only once.
255 DCHECK(user_id_to_app_observer_.find(current_user_id_) ==
256 user_id_to_app_observer_.end());
stevenjb 2015/02/03 01:31:58 nit: This only actually ensures that we don't call
Mr4D (OOO till 08-26) 2015/02/03 02:06:05 We add the observer as well - so it is not only th
257
258 // Add a session state observer to be able to monitor session changes.
259 if (ash::Shell::HasInstance())
260 ash::Shell::GetInstance()->session_state_delegate()->
261 AddSessionStateObserver(this);
stevenjb 2015/02/03 01:31:58 nit: {}
Mr4D (OOO till 08-26) 2015/02/03 02:06:05 Done.
262
263 // The BrowserListObserver would have been better to use then the old
264 // notification system, but that observer fires before the window got created.
265 registrar_.Add(this, NOTIFICATION_BROWSER_WINDOW_READY,
266 content::NotificationService::AllSources());
267
268 // Add an app window observer & all already running apps.
269 Profile* profile = multi_user_util::GetProfileFromUserID(current_user_id_);
270 if (profile)
271 AddUser(profile);
272 }
273
267 void MultiUserWindowManagerChromeOS::SetWindowOwner( 274 void MultiUserWindowManagerChromeOS::SetWindowOwner(
268 aura::Window* window, 275 aura::Window* window,
269 const std::string& user_id) { 276 const std::string& user_id) {
270 // Make sure the window is valid and there was no owner yet. 277 // Make sure the window is valid and there was no owner yet.
271 DCHECK(window); 278 DCHECK(window);
272 DCHECK(!user_id.empty()); 279 DCHECK(!user_id.empty());
273 if (GetWindowOwner(window) == user_id) 280 if (GetWindowOwner(window) == user_id)
274 return; 281 return;
275 DCHECK(GetWindowOwner(window).empty()); 282 DCHECK(GetWindowOwner(window).empty());
276 window_to_entry_[window] = new WindowEntry(user_id); 283 window_to_entry_[window] = new WindowEntry(user_id);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 DCHECK_EQ(visible, window->IsVisible()); 736 DCHECK_EQ(visible, window->IsVisible());
730 } 737 }
731 738
732 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS( 739 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS(
733 int default_time_in_ms) const { 740 int default_time_in_ms) const {
734 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms : 741 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms :
735 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0); 742 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0);
736 } 743 }
737 744
738 } // namespace chrome 745 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698