OLD | NEW |
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/chromeos/login/users/avatar/user_image_sync_observer.h" | 5 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_change_registrar.h" | 8 #include "base/prefs/pref_change_registrar.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 VLOG(1) << "Saved avatar index " << local_index << " to sync."; | 174 VLOG(1) << "Saved avatar index " << local_index << " to sync."; |
175 } | 175 } |
176 | 176 |
177 void UserImageSyncObserver::UpdateLocalImageFromSynced() { | 177 void UserImageSyncObserver::UpdateLocalImageFromSynced() { |
178 int synced_index; | 178 int synced_index; |
179 GetSyncedImageIndex(&synced_index); | 179 GetSyncedImageIndex(&synced_index); |
180 int local_index = user_->image_index(); | 180 int local_index = user_->image_index(); |
181 if ((synced_index == local_index) || !IsIndexSupported(synced_index)) | 181 if ((synced_index == local_index) || !IsIndexSupported(synced_index)) |
182 return; | 182 return; |
183 UserImageManager* image_manager = | 183 UserImageManager* image_manager = |
184 UserManager::Get()->GetUserImageManager(user_->email()); | 184 GetUserManager()->GetUserImageManager(user_->email()); |
185 if (synced_index == User::kProfileImageIndex) { | 185 if (synced_index == User::kProfileImageIndex) { |
186 image_manager->SaveUserImageFromProfileImage(); | 186 image_manager->SaveUserImageFromProfileImage(); |
187 } else { | 187 } else { |
188 image_manager->SaveUserDefaultImageIndex(synced_index); | 188 image_manager->SaveUserDefaultImageIndex(synced_index); |
189 } | 189 } |
190 VLOG(1) << "Loaded avatar index " << synced_index << " from sync."; | 190 VLOG(1) << "Loaded avatar index " << synced_index << " from sync."; |
191 } | 191 } |
192 | 192 |
193 bool UserImageSyncObserver::GetSyncedImageIndex(int* index) { | 193 bool UserImageSyncObserver::GetSyncedImageIndex(int* index) { |
194 *index = User::kInvalidImageIndex; | 194 *index = User::kInvalidImageIndex; |
195 const base::DictionaryValue* dict = prefs_->GetDictionary(kUserImageInfo); | 195 const base::DictionaryValue* dict = prefs_->GetDictionary(kUserImageInfo); |
196 return dict && dict->GetInteger(kImageIndex, index); | 196 return dict && dict->GetInteger(kImageIndex, index); |
197 } | 197 } |
198 | 198 |
199 bool UserImageSyncObserver::CanUpdateLocalImageNow() { | 199 bool UserImageSyncObserver::CanUpdateLocalImageNow() { |
200 if (WizardController* wizard_controller = | 200 if (WizardController* wizard_controller = |
201 WizardController::default_controller()) { | 201 WizardController::default_controller()) { |
202 UserImageScreen* screen = wizard_controller->GetUserImageScreen(); | 202 UserImageScreen* screen = wizard_controller->GetUserImageScreen(); |
203 if (wizard_controller->current_screen() == screen) { | 203 if (wizard_controller->current_screen() == screen) { |
204 if (screen->user_selected_image()) | 204 if (screen->user_selected_image()) |
205 return false; | 205 return false; |
206 } | 206 } |
207 } | 207 } |
208 return true; | 208 return true; |
209 } | 209 } |
210 | 210 |
211 } // namespace chromeos | 211 } // namespace chromeos |
212 | 212 |
OLD | NEW |