| 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/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 VLOG(1) << "Saved avatar index " << local_index << " to sync."; | 163 VLOG(1) << "Saved avatar index " << local_index << " to sync."; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void UserImageSyncObserver::UpdateLocalImageFromSynced() { | 166 void UserImageSyncObserver::UpdateLocalImageFromSynced() { |
| 167 int synced_index; | 167 int synced_index; |
| 168 GetSyncedImageIndex(&synced_index); | 168 GetSyncedImageIndex(&synced_index); |
| 169 int local_index = user_->image_index(); | 169 int local_index = user_->image_index(); |
| 170 if ((synced_index == local_index) || !IsIndexSupported(synced_index)) | 170 if ((synced_index == local_index) || !IsIndexSupported(synced_index)) |
| 171 return; | 171 return; |
| 172 UserImageManager* image_manager = | 172 UserImageManager* image_manager = |
| 173 ChromeUserManager::Get()->GetUserImageManager(user_->email()); | 173 ChromeUserManager::Get()->GetUserImageManager(user_->GetUserID()); |
| 174 if (synced_index == user_manager::User::USER_IMAGE_PROFILE) { | 174 if (synced_index == user_manager::User::USER_IMAGE_PROFILE) { |
| 175 image_manager->SaveUserImageFromProfileImage(); | 175 image_manager->SaveUserImageFromProfileImage(); |
| 176 } else { | 176 } else { |
| 177 image_manager->SaveUserDefaultImageIndex(synced_index); | 177 image_manager->SaveUserDefaultImageIndex(synced_index); |
| 178 } | 178 } |
| 179 VLOG(1) << "Loaded avatar index " << synced_index << " from sync."; | 179 VLOG(1) << "Loaded avatar index " << synced_index << " from sync."; |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool UserImageSyncObserver::GetSyncedImageIndex(int* index) { | 182 bool UserImageSyncObserver::GetSyncedImageIndex(int* index) { |
| 183 *index = user_manager::User::USER_IMAGE_INVALID; | 183 *index = user_manager::User::USER_IMAGE_INVALID; |
| 184 const base::DictionaryValue* dict = prefs_->GetDictionary(kUserImageInfo); | 184 const base::DictionaryValue* dict = prefs_->GetDictionary(kUserImageInfo); |
| 185 return dict && dict->GetInteger(kImageIndex, index); | 185 return dict && dict->GetInteger(kImageIndex, index); |
| 186 } | 186 } |
| 187 | 187 |
| 188 bool UserImageSyncObserver::CanUpdateLocalImageNow() { | 188 bool UserImageSyncObserver::CanUpdateLocalImageNow() { |
| 189 if (WizardController* wizard_controller = | 189 if (WizardController* wizard_controller = |
| 190 WizardController::default_controller()) { | 190 WizardController::default_controller()) { |
| 191 UserImageScreen* screen = UserImageScreen::Get(wizard_controller); | 191 UserImageScreen* screen = UserImageScreen::Get(wizard_controller); |
| 192 if (wizard_controller->current_screen() == screen) { | 192 if (wizard_controller->current_screen() == screen) { |
| 193 if (screen->user_selected_image()) | 193 if (screen->user_selected_image()) |
| 194 return false; | 194 return false; |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 return true; | 197 return true; |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace chromeos | 200 } // namespace chromeos |
| 201 | 201 |
| OLD | NEW |