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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_sync_service.cc

Issue 402133003: [cros, user_manager] Move default user images constants and helper functions out of src/chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-format Created 6 years, 5 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 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 "chrome/browser/supervised_user/supervised_user_sync_service.h" 5 #include "chrome/browser/supervised_user/supervised_user_sync_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 13 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "components/pref_registry/pref_registry_syncable.h" 15 #include "components/pref_registry/pref_registry_syncable.h"
16 #include "sync/api/sync_change.h" 16 #include "sync/api/sync_change.h"
17 #include "sync/api/sync_data.h" 17 #include "sync/api/sync_data.h"
18 #include "sync/api/sync_error.h" 18 #include "sync/api/sync_error.h"
19 #include "sync/api/sync_error_factory.h" 19 #include "sync/api/sync_error_factory.h"
20 #include "sync/api/sync_merge_result.h" 20 #include "sync/api/sync_merge_result.h"
21 #include "sync/protocol/sync.pb.h" 21 #include "sync/protocol/sync.pb.h"
22 22
23 #if defined(OS_CHROMEOS) 23 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/chromeos/login/users/avatar/default_user_images.h" 24 #include "components/user_manager/user_image/default_user_images.h"
25 #endif 25 #endif
26 26
27 using base::DictionaryValue; 27 using base::DictionaryValue;
28 using user_prefs::PrefRegistrySyncable; 28 using user_prefs::PrefRegistrySyncable;
29 using syncer::SUPERVISED_USERS; 29 using syncer::SUPERVISED_USERS;
30 using syncer::ModelType; 30 using syncer::ModelType;
31 using syncer::SyncChange; 31 using syncer::SyncChange;
32 using syncer::SyncChangeList; 32 using syncer::SyncChangeList;
33 using syncer::SyncChangeProcessor; 33 using syncer::SyncChangeProcessor;
34 using syncer::SyncData; 34 using syncer::SyncData;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return false; 159 return false;
160 } 160 }
161 161
162 if (!base::StringToInt(avatar_str.substr(prefix_len), avatar_index)) 162 if (!base::StringToInt(avatar_str.substr(prefix_len), avatar_index))
163 return false; 163 return false;
164 164
165 const int kChromeOSDummyAvatarIndex = -111; 165 const int kChromeOSDummyAvatarIndex = -111;
166 166
167 #if defined(OS_CHROMEOS) 167 #if defined(OS_CHROMEOS)
168 return (*avatar_index == kChromeOSDummyAvatarIndex || 168 return (*avatar_index == kChromeOSDummyAvatarIndex ||
169 (*avatar_index >= chromeos::kFirstDefaultImageIndex && 169 (*avatar_index >= user_manager::kFirstDefaultImageIndex &&
170 *avatar_index < chromeos::kDefaultImagesCount)); 170 *avatar_index < user_manager::kDefaultImagesCount));
171 #else 171 #else
172 // Check if the Chrome avatar index is set to a dummy value. Some early 172 // Check if the Chrome avatar index is set to a dummy value. Some early
173 // supervised user profiles on ChromeOS stored a dummy avatar index as a 173 // supervised user profiles on ChromeOS stored a dummy avatar index as a
174 // Chrome Avatar before there was logic to sync the ChromeOS avatar 174 // Chrome Avatar before there was logic to sync the ChromeOS avatar
175 // separately. Handle this as if the Chrome Avatar was not chosen yet (which 175 // separately. Handle this as if the Chrome Avatar was not chosen yet (which
176 // is correct for these profiles). 176 // is correct for these profiles).
177 if (*avatar_index == kChromeOSDummyAvatarIndex) 177 if (*avatar_index == kChromeOSDummyAvatarIndex)
178 *avatar_index = kNoAvatar; 178 *avatar_index = kNoAvatar;
179 return (*avatar_index == kNoAvatar || 179 return (*avatar_index == kNoAvatar ||
180 (*avatar_index >= 0 && 180 (*avatar_index >= 0 &&
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 568
569 void SupervisedUserSyncService::DispatchCallbacks() { 569 void SupervisedUserSyncService::DispatchCallbacks() {
570 const base::DictionaryValue* supervised_users = 570 const base::DictionaryValue* supervised_users =
571 prefs_->GetDictionary(prefs::kSupervisedUsers); 571 prefs_->GetDictionary(prefs::kSupervisedUsers);
572 for (std::vector<SupervisedUsersCallback>::iterator it = callbacks_.begin(); 572 for (std::vector<SupervisedUsersCallback>::iterator it = callbacks_.begin();
573 it != callbacks_.end(); ++it) { 573 it != callbacks_.end(); ++it) {
574 it->Run(supervised_users); 574 it->Run(supervised_users);
575 } 575 }
576 callbacks_.clear(); 576 callbacks_.clear();
577 } 577 }
OLDNEW
« no previous file with comments | « chrome/browser/supervised_user/DEPS ('k') | chrome/browser/supervised_user/supervised_user_sync_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698