| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/user_image_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 void UserImageManagerImpl::Job::UpdateLocalState() { | 440 void UserImageManagerImpl::Job::UpdateLocalState() { |
| 441 // Ignore if data stored or cached outside the user's cryptohome is to be | 441 // Ignore if data stored or cached outside the user's cryptohome is to be |
| 442 // treated as ephemeral. | 442 // treated as ephemeral. |
| 443 if (parent_->user_manager_->IsUserNonCryptohomeDataEphemeral(user_id_)) | 443 if (parent_->user_manager_->IsUserNonCryptohomeDataEphemeral(user_id_)) |
| 444 return; | 444 return; |
| 445 | 445 |
| 446 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 446 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 447 entry->Set(kImagePathNodeName, new base::StringValue(image_path_.value())); | 447 entry->Set(kImagePathNodeName, new base::StringValue(image_path_.value())); |
| 448 entry->Set(kImageIndexNodeName, new base::FundamentalValue(image_index_)); | 448 entry->Set(kImageIndexNodeName, new base::FundamentalValue(image_index_)); |
| 449 if (!image_url_.is_empty()) | 449 if (!image_url_.is_empty()) |
| 450 entry->Set(kImageURLNodeName, new StringValue(image_url_.spec())); | 450 entry->Set(kImageURLNodeName, new base::StringValue(image_url_.spec())); |
| 451 DictionaryPrefUpdate update(g_browser_process->local_state(), | 451 DictionaryPrefUpdate update(g_browser_process->local_state(), |
| 452 kUserImageProperties); | 452 kUserImageProperties); |
| 453 update->SetWithoutPathExpansion(user_id_, entry.release()); | 453 update->SetWithoutPathExpansion(user_id_, entry.release()); |
| 454 | 454 |
| 455 parent_->user_manager_->NotifyLocalStateChanged(); | 455 parent_->user_manager_->NotifyLocalStateChanged(); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void UserImageManagerImpl::Job::NotifyJobDone() { | 458 void UserImageManagerImpl::Job::NotifyJobDone() { |
| 459 parent_->OnJobDone(user_id_); | 459 parent_->OnJobDone(user_id_); |
| 460 } | 460 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 483 policy::key::kUserAvatarImage, | 483 policy::key::kUserAvatarImage, |
| 484 this)); | 484 this)); |
| 485 policy_observer_->Init(); | 485 policy_observer_->Init(); |
| 486 } | 486 } |
| 487 | 487 |
| 488 UserImageManagerImpl::~UserImageManagerImpl() { | 488 UserImageManagerImpl::~UserImageManagerImpl() { |
| 489 } | 489 } |
| 490 | 490 |
| 491 void UserImageManagerImpl::LoadUserImages(const UserList& users) { | 491 void UserImageManagerImpl::LoadUserImages(const UserList& users) { |
| 492 PrefService* local_state = g_browser_process->local_state(); | 492 PrefService* local_state = g_browser_process->local_state(); |
| 493 const DictionaryValue* prefs_images_unsafe = | 493 const base::DictionaryValue* prefs_images_unsafe = |
| 494 local_state->GetDictionary(kUserImages); | 494 local_state->GetDictionary(kUserImages); |
| 495 const DictionaryValue* prefs_images = | 495 const base::DictionaryValue* prefs_images = |
| 496 local_state->GetDictionary(kUserImageProperties); | 496 local_state->GetDictionary(kUserImageProperties); |
| 497 if (!prefs_images && !prefs_images_unsafe) | 497 if (!prefs_images && !prefs_images_unsafe) |
| 498 return; | 498 return; |
| 499 | 499 |
| 500 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 500 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
| 501 User* user = *it; | 501 User* user = *it; |
| 502 const std::string& user_id = user->email(); | 502 const std::string& user_id = user->email(); |
| 503 bool needs_migration = false; | 503 bool needs_migration = false; |
| 504 | 504 |
| 505 // If entries are found in both |prefs_images_unsafe| and |prefs_images|, | 505 // If entries are found in both |prefs_images_unsafe| and |prefs_images|, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 if (user_is_new) { | 572 if (user_is_new) { |
| 573 if (!user_is_local) | 573 if (!user_is_local) |
| 574 SetInitialUserImage(user_id); | 574 SetInitialUserImage(user_id); |
| 575 } else { | 575 } else { |
| 576 UMA_HISTOGRAM_ENUMERATION("UserImage.LoggedIn", | 576 UMA_HISTOGRAM_ENUMERATION("UserImage.LoggedIn", |
| 577 ImageIndexToHistogramIndex(user->image_index()), | 577 ImageIndexToHistogramIndex(user->image_index()), |
| 578 kHistogramImagesCount); | 578 kHistogramImagesCount); |
| 579 | 579 |
| 580 if (!IsUserImageManaged(user_id) && | 580 if (!IsUserImageManaged(user_id) && |
| 581 ContainsKey(users_to_migrate_, user_id)) { | 581 ContainsKey(users_to_migrate_, user_id)) { |
| 582 const DictionaryValue* prefs_images_unsafe = | 582 const base::DictionaryValue* prefs_images_unsafe = |
| 583 g_browser_process->local_state()->GetDictionary(kUserImages); | 583 g_browser_process->local_state()->GetDictionary(kUserImages); |
| 584 const base::DictionaryValue* image_properties = NULL; | 584 const base::DictionaryValue* image_properties = NULL; |
| 585 if (prefs_images_unsafe->GetDictionaryWithoutPathExpansion( | 585 if (prefs_images_unsafe->GetDictionaryWithoutPathExpansion( |
| 586 user_id, &image_properties)) { | 586 user_id, &image_properties)) { |
| 587 std::string image_path; | 587 std::string image_path; |
| 588 image_properties->GetString(kImagePathNodeName, &image_path); | 588 image_properties->GetString(kImagePathNodeName, &image_path); |
| 589 linked_ptr<Job>& job = jobs_[user_id]; | 589 linked_ptr<Job>& job = jobs_[user_id]; |
| 590 job.reset(new Job(this, user_id)); | 590 job.reset(new Job(this, user_id)); |
| 591 if (!image_path.empty()) { | 591 if (!image_path.empty()) { |
| 592 VLOG(0) << "Loading old user image, then migrating it."; | 592 VLOG(0) << "Loading old user image, then migrating it."; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 jobs_.erase(it); | 970 jobs_.erase(it); |
| 971 } else { | 971 } else { |
| 972 NOTREACHED(); | 972 NOTREACHED(); |
| 973 } | 973 } |
| 974 | 974 |
| 975 if (!ContainsKey(users_to_migrate_, user_id)) | 975 if (!ContainsKey(users_to_migrate_, user_id)) |
| 976 return; | 976 return; |
| 977 // Migration completed for |user_id|. | 977 // Migration completed for |user_id|. |
| 978 users_to_migrate_.erase(user_id); | 978 users_to_migrate_.erase(user_id); |
| 979 | 979 |
| 980 const DictionaryValue* prefs_images_unsafe = | 980 const base::DictionaryValue* prefs_images_unsafe = |
| 981 g_browser_process->local_state()->GetDictionary(kUserImages); | 981 g_browser_process->local_state()->GetDictionary(kUserImages); |
| 982 const base::DictionaryValue* image_properties = NULL; | 982 const base::DictionaryValue* image_properties = NULL; |
| 983 if (!prefs_images_unsafe->GetDictionaryWithoutPathExpansion( | 983 if (!prefs_images_unsafe->GetDictionaryWithoutPathExpansion( |
| 984 user_id, &image_properties)) { | 984 user_id, &image_properties)) { |
| 985 NOTREACHED(); | 985 NOTREACHED(); |
| 986 return; | 986 return; |
| 987 } | 987 } |
| 988 | 988 |
| 989 int image_index = User::kInvalidImageIndex; | 989 int image_index = User::kInvalidImageIndex; |
| 990 image_properties->GetInteger(kImageIndexNodeName, &image_index); | 990 image_properties->GetInteger(kImageIndexNodeName, &image_index); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 if (!user_image_sync_observer_ && | 1028 if (!user_image_sync_observer_ && |
| 1029 user && user->CanSyncImage() && | 1029 user && user->CanSyncImage() && |
| 1030 !IsUserImageManaged(user->email()) && | 1030 !IsUserImageManaged(user->email()) && |
| 1031 !CommandLine::ForCurrentProcess()->HasSwitch( | 1031 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 1032 chromeos::switches::kDisableUserImageSync)) { | 1032 chromeos::switches::kDisableUserImageSync)) { |
| 1033 user_image_sync_observer_.reset(new UserImageSyncObserver(user)); | 1033 user_image_sync_observer_.reset(new UserImageSyncObserver(user)); |
| 1034 } | 1034 } |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 } // namespace chromeos | 1037 } // namespace chromeos |
| OLD | NEW |