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

Side by Side Diff: chrome/browser/ui/ash/session_state_delegate_chromeos.cc

Issue 445353004: GetProfileByUser deprecated and renamed to GetProfileByUserUnsafe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/session_state_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h"
6 6
7 #include "ash/multi_profile_uma.h" 7 #include "ash/multi_profile_uma.h"
8 #include "ash/session/session_state_observer.h" 8 #include "ash/session/session_state_observer.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 if (chromeos::LoginState::IsInitialized()) 45 if (chromeos::LoginState::IsInitialized())
46 chromeos::LoginState::Get()->RemoveObserver(this); 46 chromeos::LoginState::Get()->RemoveObserver(this);
47 } 47 }
48 48
49 content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex( 49 content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex(
50 ash::MultiProfileIndex index) { 50 ash::MultiProfileIndex index) {
51 DCHECK_LT(index, NumberOfLoggedInUsers()); 51 DCHECK_LT(index, NumberOfLoggedInUsers());
52 user_manager::User* user = 52 user_manager::User* user =
53 chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]; 53 chromeos::UserManager::Get()->GetLRULoggedInUsers()[index];
54 DCHECK(user); 54 DCHECK(user);
55 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); 55 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user);
56 } 56 }
57 57
58 content::BrowserContext* 58 content::BrowserContext*
59 SessionStateDelegateChromeos::GetBrowserContextForWindow( 59 SessionStateDelegateChromeos::GetBrowserContextForWindow(
60 aura::Window* window) { 60 aura::Window* window) {
61 const std::string& user_id = 61 const std::string& user_id =
62 chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window); 62 chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window);
63 const user_manager::User* user = 63 const user_manager::User* user =
64 chromeos::UserManager::Get()->FindUser(user_id); 64 chromeos::UserManager::Get()->FindUser(user_id);
65 DCHECK(user); 65 DCHECK(user);
66 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); 66 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user);
67 } 67 }
68 68
69 int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const { 69 int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const {
70 // We limit list of logged in users to 10 due to memory constraints. 70 // We limit list of logged in users to 10 due to memory constraints.
71 // Note that 10 seems excessive, but we want to test how many users are 71 // Note that 10 seems excessive, but we want to test how many users are
72 // actually added to a session. 72 // actually added to a session.
73 // TODO(nkostylev): Adjust this limitation based on device capabilites. 73 // TODO(nkostylev): Adjust this limitation based on device capabilites.
74 // http://crbug.com/230865 74 // http://crbug.com/230865
75 return 10; 75 return 10;
76 } 76 }
(...skipping 17 matching lines...) Expand all
94 chromeos::ScreenLocker::default_screen_locker()->locked(); 94 chromeos::ScreenLocker::default_screen_locker()->locked();
95 } 95 }
96 96
97 bool SessionStateDelegateChromeos::ShouldLockScreenBeforeSuspending() const { 97 bool SessionStateDelegateChromeos::ShouldLockScreenBeforeSuspending() const {
98 const user_manager::UserList logged_in_users = 98 const user_manager::UserList logged_in_users =
99 chromeos::UserManager::Get()->GetLoggedInUsers(); 99 chromeos::UserManager::Get()->GetLoggedInUsers();
100 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); 100 for (user_manager::UserList::const_iterator it = logged_in_users.begin();
101 it != logged_in_users.end(); 101 it != logged_in_users.end();
102 ++it) { 102 ++it) {
103 user_manager::User* user = (*it); 103 user_manager::User* user = (*it);
104 Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(user); 104 Profile* profile =
105 chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user);
105 if (profile->GetPrefs()->GetBoolean(prefs::kEnableAutoScreenLock)) 106 if (profile->GetPrefs()->GetBoolean(prefs::kEnableAutoScreenLock))
106 return true; 107 return true;
107 } 108 }
108 return false; 109 return false;
109 } 110 }
110 111
111 void SessionStateDelegateChromeos::LockScreen() { 112 void SessionStateDelegateChromeos::LockScreen() {
112 if (!CanLockScreen()) 113 if (!CanLockScreen())
113 return; 114 return;
114 115
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 252
252 session_state_ = new_state; 253 session_state_ = new_state;
253 NotifySessionStateChanged(); 254 NotifySessionStateChanged();
254 } 255 }
255 256
256 void SessionStateDelegateChromeos::NotifySessionStateChanged() { 257 void SessionStateDelegateChromeos::NotifySessionStateChanged() {
257 FOR_EACH_OBSERVER(ash::SessionStateObserver, 258 FOR_EACH_OBSERVER(ash::SessionStateObserver,
258 session_state_observer_list_, 259 session_state_observer_list_,
259 SessionStateChanged(session_state_)); 260 SessionStateChanged(session_state_));
260 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698