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