| 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_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 429 |
| 430 parent_->OnJobChangedUserImage(); | 430 parent_->OnJobChangedUserImage(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void UserImageManagerImpl::Job::SaveImageAndUpdateLocalState() { | 433 void UserImageManagerImpl::Job::SaveImageAndUpdateLocalState() { |
| 434 base::FilePath user_data_dir; | 434 base::FilePath user_data_dir; |
| 435 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 435 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 436 image_path_ = user_data_dir.Append(user_id() + kSafeImagePathExtension); | 436 image_path_ = user_data_dir.Append(user_id() + kSafeImagePathExtension); |
| 437 | 437 |
| 438 base::PostTaskAndReplyWithResult( | 438 base::PostTaskAndReplyWithResult( |
| 439 parent_->background_task_runner_, | 439 parent_->background_task_runner_.get(), |
| 440 FROM_HERE, | 440 FROM_HERE, |
| 441 base::Bind(&SaveImage, user_image_, image_path_), | 441 base::Bind(&SaveImage, user_image_, image_path_), |
| 442 base::Bind(&Job::OnSaveImageDone, weak_factory_.GetWeakPtr())); | 442 base::Bind(&Job::OnSaveImageDone, weak_factory_.GetWeakPtr())); |
| 443 } | 443 } |
| 444 | 444 |
| 445 void UserImageManagerImpl::Job::OnSaveImageDone(bool success) { | 445 void UserImageManagerImpl::Job::OnSaveImageDone(bool success) { |
| 446 if (success || image_index_ == user_manager::User::USER_IMAGE_PROFILE) | 446 if (success || image_index_ == user_manager::User::USER_IMAGE_PROFILE) |
| 447 UpdateLocalState(); | 447 UpdateLocalState(); |
| 448 NotifyJobDone(); | 448 NotifyJobDone(); |
| 449 } | 449 } |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 | 1021 |
| 1022 bool UserImageManagerImpl::IsUserLoggedInAndRegular() const { | 1022 bool UserImageManagerImpl::IsUserLoggedInAndRegular() const { |
| 1023 const user_manager::User* user = GetUser(); | 1023 const user_manager::User* user = GetUser(); |
| 1024 if (!user) | 1024 if (!user) |
| 1025 return false; | 1025 return false; |
| 1026 return user->is_logged_in() && | 1026 return user->is_logged_in() && |
| 1027 user->GetType() == user_manager::USER_TYPE_REGULAR; | 1027 user->GetType() == user_manager::USER_TYPE_REGULAR; |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 } // namespace chromeos | 1030 } // namespace chromeos |
| OLD | NEW |