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

Side by Side Diff: components/user_manager/user_manager_base.cc

Issue 1025663002: Implement oauth token external handler checking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update fake user manager Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/user_manager/user_manager_base.h" 5 #include "components/user_manager/user_manager_base.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 964
965 DictionaryPrefUpdate prefs_display_email_update(prefs, kUserDisplayEmail); 965 DictionaryPrefUpdate prefs_display_email_update(prefs, kUserDisplayEmail);
966 prefs_display_email_update->RemoveWithoutPathExpansion(user_id, NULL); 966 prefs_display_email_update->RemoveWithoutPathExpansion(user_id, NULL);
967 967
968 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); 968 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus);
969 prefs_oauth_update->RemoveWithoutPathExpansion(user_id, NULL); 969 prefs_oauth_update->RemoveWithoutPathExpansion(user_id, NULL);
970 970
971 DictionaryPrefUpdate prefs_force_online_update(prefs, kUserForceOnlineSignin); 971 DictionaryPrefUpdate prefs_force_online_update(prefs, kUserForceOnlineSignin);
972 prefs_force_online_update->RemoveWithoutPathExpansion(user_id, NULL); 972 prefs_force_online_update->RemoveWithoutPathExpansion(user_id, NULL);
973 973
974 RemoveKnowUserPrefs(user_id); 974 RemoveKnownUserPrefs(user_id);
975 975
976 std::string last_active_user = GetLocalState()->GetString(kLastActiveUser); 976 std::string last_active_user = GetLocalState()->GetString(kLastActiveUser);
977 if (user_id == last_active_user) 977 if (user_id == last_active_user)
978 GetLocalState()->SetString(kLastActiveUser, std::string()); 978 GetLocalState()->SetString(kLastActiveUser, std::string());
979 } 979 }
980 980
981 bool UserManagerBase::FindKnowUserPrefs( 981 bool UserManagerBase::FindKnownUserPrefs(
982 const UserID& user_id, 982 const UserID& user_id,
983 const base::DictionaryValue** out_value) { 983 const base::DictionaryValue** out_value) {
984 PrefService* local_state = GetLocalState(); 984 PrefService* local_state = GetLocalState();
985 const base::ListValue* known_users = local_state->GetList(kKnownUsers); 985 const base::ListValue* known_users = local_state->GetList(kKnownUsers);
986 for (size_t i = 0; i < known_users->GetSize(); ++i) { 986 for (size_t i = 0; i < known_users->GetSize(); ++i) {
987 const base::DictionaryValue* element = nullptr; 987 const base::DictionaryValue* element = nullptr;
988 if (known_users->GetDictionary(i, &element)) { 988 if (known_users->GetDictionary(i, &element)) {
989 if (UserMatches(user_id, *element)) { 989 if (UserMatches(user_id, *element)) {
990 known_users->GetDictionary(i, out_value); 990 known_users->GetDictionary(i, out_value);
991 return true; 991 return true;
992 } 992 }
993 } 993 }
994 } 994 }
995 return false; 995 return false;
996 } 996 }
997 997
998 void UserManagerBase::UpdateKnowUserPrefs(const UserID& user_id, 998 void UserManagerBase::UpdateKnownUserPrefs(const UserID& user_id,
999 const base::DictionaryValue& values, 999 const base::DictionaryValue& values,
1000 bool clear) { 1000 bool clear) {
1001 ListPrefUpdate update(GetLocalState(), kKnownUsers); 1001 ListPrefUpdate update(GetLocalState(), kKnownUsers);
1002 for (size_t i = 0; i < update->GetSize(); ++i) { 1002 for (size_t i = 0; i < update->GetSize(); ++i) {
1003 base::DictionaryValue* element = nullptr; 1003 base::DictionaryValue* element = nullptr;
1004 if (update->GetDictionary(i, &element)) { 1004 if (update->GetDictionary(i, &element)) {
1005 if (UserMatches(user_id, *element)) { 1005 if (UserMatches(user_id, *element)) {
1006 if (clear) 1006 if (clear)
1007 element->Clear(); 1007 element->Clear();
1008 element->MergeDictionary(&values); 1008 element->MergeDictionary(&values);
1009 UpdateIdentity(user_id, *element); 1009 UpdateIdentity(user_id, *element);
1010 return; 1010 return;
(...skipping 18 matching lines...) Expand all
1029 it = users_.erase(it); 1029 it = users_.erase(it);
1030 } else { 1030 } else {
1031 if ((*it)->HasGaiaAccount() || (*it)->IsSupervised()) 1031 if ((*it)->HasGaiaAccount() || (*it)->IsSupervised())
1032 prefs_users_update->Append(new base::StringValue(user_email)); 1032 prefs_users_update->Append(new base::StringValue(user_email));
1033 ++it; 1033 ++it;
1034 } 1034 }
1035 } 1035 }
1036 return user; 1036 return user;
1037 } 1037 }
1038 1038
1039 void UserManagerBase::RemoveKnowUserPrefs(const UserID& user_id) { 1039 void UserManagerBase::RemoveKnownUserPrefs(const UserID& user_id) {
1040 ListPrefUpdate update(GetLocalState(), kKnownUsers); 1040 ListPrefUpdate update(GetLocalState(), kKnownUsers);
1041 for (size_t i = 0; i < update->GetSize(); ++i) { 1041 for (size_t i = 0; i < update->GetSize(); ++i) {
1042 base::DictionaryValue* element = nullptr; 1042 base::DictionaryValue* element = nullptr;
1043 if (update->GetDictionary(i, &element)) { 1043 if (update->GetDictionary(i, &element)) {
1044 if (UserMatches(user_id, *element)) { 1044 if (UserMatches(user_id, *element)) {
1045 update->Remove(i, nullptr); 1045 update->Remove(i, nullptr);
1046 break; 1046 break;
1047 } 1047 }
1048 } 1048 }
1049 } 1049 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 } 1177 }
1178 1178
1179 void UserManagerBase::DeleteUser(User* user) { 1179 void UserManagerBase::DeleteUser(User* user) {
1180 const bool is_active_user = (user == active_user_); 1180 const bool is_active_user = (user == active_user_);
1181 delete user; 1181 delete user;
1182 if (is_active_user) 1182 if (is_active_user)
1183 active_user_ = NULL; 1183 active_user_ = NULL;
1184 } 1184 }
1185 1185
1186 } // namespace user_manager 1186 } // namespace user_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698