Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 12 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 13 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 13 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 14 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | |
| 14 #include "chrome/browser/chromeos/login/users/user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 16 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | |
| 17 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | |
| 15 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 21 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 19 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 20 #include "chromeos/chromeos_switches.h" | 23 #include "chromeos/chromeos_switches.h" |
| 21 #include "chromeos/dbus/dbus_thread_manager.h" | 24 #include "chromeos/dbus/dbus_thread_manager.h" |
| 22 #include "chromeos/dbus/session_manager_client.h" | 25 #include "chromeos/dbus/session_manager_client.h" |
| 23 #include "chromeos/login/login_state.h" | 26 #include "chromeos/login/login_state.h" |
| 24 #include "components/user_manager/user.h" | 27 #include "components/user_manager/user.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 if (it == logged_in_users.begin()) | 203 if (it == logged_in_users.begin()) |
| 201 it = logged_in_users.end(); | 204 it = logged_in_users.end(); |
| 202 user_id = (*(--it))->email(); | 205 user_id = (*(--it))->email(); |
| 203 break; | 206 break; |
| 204 } | 207 } |
| 205 | 208 |
| 206 // Switch using the transformed |user_id|. | 209 // Switch using the transformed |user_id|. |
| 207 chromeos::UserManager::Get()->SwitchActiveUser(user_id); | 210 chromeos::UserManager::Get()->SwitchActiveUser(user_id); |
| 208 } | 211 } |
| 209 | 212 |
| 213 ash::SessionStateDelegate::PrimaryUserPolicy | |
| 214 SessionStateDelegateChromeos::GetPrimaryUserPolicy() const { | |
|
dzhioev (left Google)
2014/08/06 12:37:39
This method is identical to the part of MultiProfi
Roman Sorokin (ftl)
2014/08/08 09:22:00
Done.
| |
| 215 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | |
| 216 CHECK(user_manager); | |
| 217 | |
| 218 const user_manager::User* primary_user = user_manager->GetPrimaryUser(); | |
| 219 if (!primary_user) | |
| 220 return ash::SessionStateDelegate::PRIMARY_USER_POLICY_ALLOW; | |
| 221 Profile* primary_user_profile = | |
| 222 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); | |
| 223 const std::string primary_user_behavior = | |
| 224 primary_user_profile->GetPrefs()->GetString( | |
| 225 prefs::kMultiProfileUserBehavior); | |
| 226 if (primary_user_behavior == | |
| 227 chromeos::MultiProfileUserController::kBehaviorNotAllowed) | |
| 228 return ash::SessionStateDelegate::PRIMARY_USER_POLICY_FORBIDS; | |
| 229 | |
| 230 policy::PolicyCertService* service = | |
| 231 policy::PolicyCertServiceFactory::GetForProfile(primary_user_profile); | |
| 232 if (service && service->has_policy_certificates()) | |
| 233 return ash::SessionStateDelegate::PRIMARY_USER_POLICY_CERT_TAINTED; | |
| 234 | |
| 235 return ash::SessionStateDelegate::PRIMARY_USER_POLICY_ALLOW; | |
| 236 } | |
| 237 | |
| 210 void SessionStateDelegateChromeos::AddSessionStateObserver( | 238 void SessionStateDelegateChromeos::AddSessionStateObserver( |
| 211 ash::SessionStateObserver* observer) { | 239 ash::SessionStateObserver* observer) { |
| 212 session_state_observer_list_.AddObserver(observer); | 240 session_state_observer_list_.AddObserver(observer); |
| 213 } | 241 } |
| 214 | 242 |
| 215 void SessionStateDelegateChromeos::RemoveSessionStateObserver( | 243 void SessionStateDelegateChromeos::RemoveSessionStateObserver( |
| 216 ash::SessionStateObserver* observer) { | 244 ash::SessionStateObserver* observer) { |
| 217 session_state_observer_list_.RemoveObserver(observer); | 245 session_state_observer_list_.RemoveObserver(observer); |
| 218 } | 246 } |
| 219 | 247 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 | 279 |
| 252 session_state_ = new_state; | 280 session_state_ = new_state; |
| 253 NotifySessionStateChanged(); | 281 NotifySessionStateChanged(); |
| 254 } | 282 } |
| 255 | 283 |
| 256 void SessionStateDelegateChromeos::NotifySessionStateChanged() { | 284 void SessionStateDelegateChromeos::NotifySessionStateChanged() { |
| 257 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 285 FOR_EACH_OBSERVER(ash::SessionStateObserver, |
| 258 session_state_observer_list_, | 286 session_state_observer_list_, |
| 259 SessionStateChanged(session_state_)); | 287 SessionStateChanged(session_state_)); |
| 260 } | 288 } |
| OLD | NEW |