Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.cc

Issue 444903002: [cros] user_manager component - move UserManagerBase and UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop_proxy.h" 12 #include "base/message_loop/message_loop_proxy.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/prefs/pref_registry_simple.h" 15 #include "base/prefs/pref_registry_simple.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/prefs/scoped_user_pref_update.h" 17 #include "base/prefs/scoped_user_pref_update.h"
18 #include "base/rand_util.h" 18 #include "base/rand_util.h"
19 #include "base/sequenced_task_runner.h" 19 #include "base/sequenced_task_runner.h"
20 #include "base/task_runner_util.h" 20 #include "base/task_runner_util.h"
21 #include "base/threading/sequenced_worker_pool.h" 21 #include "base/threading/sequenced_worker_pool.h"
22 #include "base/time/time.h" 22 #include "base/time/time.h"
23 #include "base/values.h" 23 #include "base/values.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/chrome_notification_types.h" 25 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/chromeos/login/helper.h" 26 #include "chrome/browser/chromeos/login/helper.h"
27 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h" 27 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h"
28 #include "chrome/browser/chromeos/login/users/user_manager.h"
29 #include "chrome/browser/chromeos/profiles/profile_helper.h" 28 #include "chrome/browser/chromeos/profiles/profile_helper.h"
30 #include "chrome/browser/profiles/profile_downloader.h" 29 #include "chrome/browser/profiles/profile_downloader.h"
31 #include "chrome/browser/profiles/profile_manager.h" 30 #include "chrome/browser/profiles/profile_manager.h"
32 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
33 #include "chrome/grit/theme_resources.h" 32 #include "chrome/grit/theme_resources.h"
34 #include "components/user_manager/user_image/default_user_images.h" 33 #include "components/user_manager/user_image/default_user_images.h"
35 #include "components/user_manager/user_image/user_image.h" 34 #include "components/user_manager/user_image/user_image.h"
35 #include "components/user_manager/user_manager.h"
36 #include "components/user_manager/user_type.h" 36 #include "components/user_manager/user_type.h"
37 #include "content/public/browser/browser_thread.h" 37 #include "content/public/browser/browser_thread.h"
38 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
39 #include "policy/policy_constants.h" 39 #include "policy/policy_constants.h"
40 #include "ui/base/resource/resource_bundle.h" 40 #include "ui/base/resource/resource_bundle.h"
41 #include "ui/gfx/image/image_skia.h" 41 #include "ui/gfx/image/image_skia.h"
42 42
43 namespace chromeos { 43 namespace chromeos {
44 44
45 namespace { 45 namespace {
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 kUserImageProperties); 463 kUserImageProperties);
464 update->SetWithoutPathExpansion(user_id(), entry.release()); 464 update->SetWithoutPathExpansion(user_id(), entry.release());
465 465
466 parent_->user_manager_->NotifyLocalStateChanged(); 466 parent_->user_manager_->NotifyLocalStateChanged();
467 } 467 }
468 468
469 void UserImageManagerImpl::Job::NotifyJobDone() { 469 void UserImageManagerImpl::Job::NotifyJobDone() {
470 parent_->OnJobDone(); 470 parent_->OnJobDone();
471 } 471 }
472 472
473 UserImageManagerImpl::UserImageManagerImpl(const std::string& user_id, 473 UserImageManagerImpl::UserImageManagerImpl(
474 UserManager* user_manager) 474 const std::string& user_id,
475 user_manager::UserManager* user_manager)
475 : UserImageManager(user_id), 476 : UserImageManager(user_id),
476 user_manager_(user_manager), 477 user_manager_(user_manager),
477 downloading_profile_image_(false), 478 downloading_profile_image_(false),
478 profile_image_requested_(false), 479 profile_image_requested_(false),
479 has_managed_image_(false), 480 has_managed_image_(false),
480 user_needs_migration_(false), 481 user_needs_migration_(false),
481 weak_factory_(this) { 482 weak_factory_(this) {
482 base::SequencedWorkerPool* blocking_pool = 483 base::SequencedWorkerPool* blocking_pool =
483 content::BrowserThread::GetBlockingPool(); 484 content::BrowserThread::GetBlockingPool();
484 background_task_runner_ = 485 background_task_runner_ =
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 757
757 void UserImageManagerImpl::OnProfileDownloadSuccess( 758 void UserImageManagerImpl::OnProfileDownloadSuccess(
758 ProfileDownloader* downloader) { 759 ProfileDownloader* downloader) {
759 // Ensure that the |profile_downloader_| is deleted when this method returns. 760 // Ensure that the |profile_downloader_| is deleted when this method returns.
760 scoped_ptr<ProfileDownloader> profile_downloader( 761 scoped_ptr<ProfileDownloader> profile_downloader(
761 profile_downloader_.release()); 762 profile_downloader_.release());
762 DCHECK_EQ(downloader, profile_downloader.get()); 763 DCHECK_EQ(downloader, profile_downloader.get());
763 764
764 user_manager_->UpdateUserAccountData( 765 user_manager_->UpdateUserAccountData(
765 user_id(), 766 user_id(),
766 UserManager::UserAccountData(downloader->GetProfileFullName(), 767 user_manager::UserManager::UserAccountData(
767 downloader->GetProfileGivenName(), 768 downloader->GetProfileFullName(),
768 downloader->GetProfileLocale())); 769 downloader->GetProfileGivenName(),
770 downloader->GetProfileLocale()));
769 if (!downloading_profile_image_) 771 if (!downloading_profile_image_)
770 return; 772 return;
771 773
772 ProfileDownloadResult result = kDownloadFailure; 774 ProfileDownloadResult result = kDownloadFailure;
773 switch (downloader->GetProfilePictureStatus()) { 775 switch (downloader->GetProfilePictureStatus()) {
774 case ProfileDownloader::PICTURE_SUCCESS: 776 case ProfileDownloader::PICTURE_SUCCESS:
775 result = kDownloadSuccess; 777 result = kDownloadSuccess;
776 break; 778 break;
777 case ProfileDownloader::PICTURE_CACHED: 779 case ProfileDownloader::PICTURE_CACHED:
778 result = kDownloadCached; 780 result = kDownloadCached;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 1021
1020 bool UserImageManagerImpl::IsUserLoggedInAndRegular() const { 1022 bool UserImageManagerImpl::IsUserLoggedInAndRegular() const {
1021 const user_manager::User* user = GetUser(); 1023 const user_manager::User* user = GetUser();
1022 if (!user) 1024 if (!user)
1023 return false; 1025 return false;
1024 return user->is_logged_in() && 1026 return user->is_logged_in() &&
1025 user->GetType() == user_manager::USER_TYPE_REGULAR; 1027 user->GetType() == user_manager::USER_TYPE_REGULAR;
1026 } 1028 }
1027 1029
1028 } // namespace chromeos 1030 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698