| OLD | NEW |
| 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/chromeos/login/multi_profile_user_controller.h" | 5 #include "chrome/browser/chromeos/login/multi_profile_user_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 DictionaryPrefUpdate update(local_state_, | 175 DictionaryPrefUpdate update(local_state_, |
| 176 prefs::kCachedMultiProfileUserBehavior); | 176 prefs::kCachedMultiProfileUserBehavior); |
| 177 update->SetStringWithoutPathExpansion(user_email, | 177 update->SetStringWithoutPathExpansion(user_email, |
| 178 SanitizeBehaviorValue(behavior)); | 178 SanitizeBehaviorValue(behavior)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void MultiProfileUserController::CheckSessionUsers() { | 181 void MultiProfileUserController::CheckSessionUsers() { |
| 182 const UserList& users = UserManager::Get()->GetLoggedInUsers(); | 182 const UserList& users = UserManager::Get()->GetLoggedInUsers(); |
| 183 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 183 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
| 184 if (!IsUserAllowedInSession((*it)->email())) { | 184 if (!IsUserAllowedInSession((*it)->email())) { |
| 185 delegate_->OnUserNotAllowed(); | 185 delegate_->OnUserNotAllowed((*it)->email()); |
| 186 return; | 186 return; |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 void MultiProfileUserController::OnUserPrefChanged( | 191 void MultiProfileUserController::OnUserPrefChanged( |
| 192 Profile* user_profile) { | 192 Profile* user_profile) { |
| 193 std::string user_email = user_profile->GetProfileName(); | 193 std::string user_email = user_profile->GetProfileName(); |
| 194 CHECK(!user_email.empty()); | 194 CHECK(!user_email.empty()); |
| 195 user_email = gaia::CanonicalizeEmail(user_email); | 195 user_email = gaia::CanonicalizeEmail(user_email); |
| 196 | 196 |
| 197 PrefService* prefs = user_profile->GetPrefs(); | 197 PrefService* prefs = user_profile->GetPrefs(); |
| 198 if (prefs->FindPreference(prefs::kMultiProfileUserBehavior) | 198 if (prefs->FindPreference(prefs::kMultiProfileUserBehavior) |
| 199 ->IsDefaultValue()) { | 199 ->IsDefaultValue()) { |
| 200 // Migration code to clear cached default behavior. | 200 // Migration code to clear cached default behavior. |
| 201 // TODO(xiyuan): Remove this after M35. | 201 // TODO(xiyuan): Remove this after M35. |
| 202 DictionaryPrefUpdate update(local_state_, | 202 DictionaryPrefUpdate update(local_state_, |
| 203 prefs::kCachedMultiProfileUserBehavior); | 203 prefs::kCachedMultiProfileUserBehavior); |
| 204 update->RemoveWithoutPathExpansion(user_email, NULL); | 204 update->RemoveWithoutPathExpansion(user_email, NULL); |
| 205 } else { | 205 } else { |
| 206 const std::string behavior = | 206 const std::string behavior = |
| 207 prefs->GetString(prefs::kMultiProfileUserBehavior); | 207 prefs->GetString(prefs::kMultiProfileUserBehavior); |
| 208 SetCachedValue(user_email, behavior); | 208 SetCachedValue(user_email, behavior); |
| 209 } | 209 } |
| 210 | 210 |
| 211 CheckSessionUsers(); | 211 CheckSessionUsers(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 } // namespace chromeos | 214 } // namespace chromeos |
| OLD | NEW |