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

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

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
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/chrome_user_manager_impl.h" 5 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8
8 #include <cstddef> 9 #include <cstddef>
9 #include <set> 10 #include <set>
10 #include <utility> 11 #include <utility>
11 12
12 #include "ash/multi_profile_uma.h" 13 #include "ash/multi_profile_uma.h"
13 #include "base/bind.h" 14 #include "base/bind.h"
14 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
17 #include "base/format_macros.h" 18 #include "base/format_macros.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/memory/ptr_util.h"
19 #include "base/metrics/histogram.h" 21 #include "base/metrics/histogram.h"
20 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
23 #include "base/sys_info.h" 25 #include "base/sys_info.h"
24 #include "base/task_runner.h" 26 #include "base/task_runner.h"
25 #include "base/thread_task_runner_handle.h" 27 #include "base/thread_task_runner_handle.h"
26 #include "base/values.h" 28 #include "base/values.h"
27 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/chrome_notification_types.h" 30 #include "chrome/browser/chrome_notification_types.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 registry->RegisterListPref(kPublicAccounts); 137 registry->RegisterListPref(kPublicAccounts);
136 registry->RegisterStringPref(kPublicAccountPendingDataRemoval, std::string()); 138 registry->RegisterStringPref(kPublicAccountPendingDataRemoval, std::string());
137 registry->RegisterListPref(kReportingUsers); 139 registry->RegisterListPref(kReportingUsers);
138 140
139 SupervisedUserManager::RegisterPrefs(registry); 141 SupervisedUserManager::RegisterPrefs(registry);
140 SessionLengthLimiter::RegisterPrefs(registry); 142 SessionLengthLimiter::RegisterPrefs(registry);
141 BootstrapManager::RegisterPrefs(registry); 143 BootstrapManager::RegisterPrefs(registry);
142 } 144 }
143 145
144 // static 146 // static
145 scoped_ptr<ChromeUserManager> ChromeUserManagerImpl::CreateChromeUserManager() { 147 std::unique_ptr<ChromeUserManager>
146 return scoped_ptr<ChromeUserManager>(new ChromeUserManagerImpl()); 148 ChromeUserManagerImpl::CreateChromeUserManager() {
149 return std::unique_ptr<ChromeUserManager>(new ChromeUserManagerImpl());
147 } 150 }
148 151
149 ChromeUserManagerImpl::ChromeUserManagerImpl() 152 ChromeUserManagerImpl::ChromeUserManagerImpl()
150 : ChromeUserManager(base::ThreadTaskRunnerHandle::Get()), 153 : ChromeUserManager(base::ThreadTaskRunnerHandle::Get()),
151 cros_settings_(CrosSettings::Get()), 154 cros_settings_(CrosSettings::Get()),
152 device_local_account_policy_service_(NULL), 155 device_local_account_policy_service_(NULL),
153 supervised_user_manager_(new SupervisedUserManagerImpl(this)), 156 supervised_user_manager_(new SupervisedUserManagerImpl(this)),
154 bootstrap_manager_(new BootstrapManager(this)), 157 bootstrap_manager_(new BootstrapManager(this)),
155 weak_factory_(this) { 158 weak_factory_(this) {
156 UpdateNumberOfUsers(); 159 UpdateNumberOfUsers();
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 GetUserImageManager(account_id)->OnExternalDataCleared(policy); 489 GetUserImageManager(account_id)->OnExternalDataCleared(policy);
487 else if (policy == policy::key::kWallpaperImage) 490 else if (policy == policy::key::kWallpaperImage)
488 WallpaperManager::Get()->OnPolicyCleared(policy, account_id); 491 WallpaperManager::Get()->OnPolicyCleared(policy, account_id);
489 else 492 else
490 NOTREACHED(); 493 NOTREACHED();
491 } 494 }
492 495
493 void ChromeUserManagerImpl::OnExternalDataFetched( 496 void ChromeUserManagerImpl::OnExternalDataFetched(
494 const std::string& policy, 497 const std::string& policy,
495 const std::string& user_id, 498 const std::string& user_id,
496 scoped_ptr<std::string> data) { 499 std::unique_ptr<std::string> data) {
497 const AccountId account_id = 500 const AccountId account_id =
498 user_manager::known_user::GetAccountId(user_id, std::string()); 501 user_manager::known_user::GetAccountId(user_id, std::string());
499 if (policy == policy::key::kUserAvatarImage) 502 if (policy == policy::key::kUserAvatarImage)
500 GetUserImageManager(account_id) 503 GetUserImageManager(account_id)
501 ->OnExternalDataFetched(policy, std::move(data)); 504 ->OnExternalDataFetched(policy, std::move(data));
502 else if (policy == policy::key::kWallpaperImage) 505 else if (policy == policy::key::kWallpaperImage)
503 WallpaperManager::Get()->OnPolicyFetched(policy, account_id, 506 WallpaperManager::Get()->OnPolicyFetched(policy, account_id,
504 std::move(data)); 507 std::move(data));
505 else 508 else
506 NOTREACHED(); 509 NOTREACHED();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 } 684 }
682 685
683 void ChromeUserManagerImpl::GuestUserLoggedIn() { 686 void ChromeUserManagerImpl::GuestUserLoggedIn() {
684 DCHECK_CURRENTLY_ON(BrowserThread::UI); 687 DCHECK_CURRENTLY_ON(BrowserThread::UI);
685 ChromeUserManager::GuestUserLoggedIn(); 688 ChromeUserManager::GuestUserLoggedIn();
686 689
687 // TODO(nkostylev): Add support for passing guest session cryptohome 690 // TODO(nkostylev): Add support for passing guest session cryptohome
688 // mount point. Legacy (--login-profile) value will be used for now. 691 // mount point. Legacy (--login-profile) value will be used for now.
689 // http://crosbug.com/230859 692 // http://crosbug.com/230859
690 active_user_->SetStubImage( 693 active_user_->SetStubImage(
691 make_scoped_ptr(new user_manager::UserImage( 694 base::WrapUnique(new user_manager::UserImage(
692 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 695 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
693 IDR_PROFILE_PICTURE_LOADING))), 696 IDR_PROFILE_PICTURE_LOADING))),
694 user_manager::User::USER_IMAGE_INVALID, false); 697 user_manager::User::USER_IMAGE_INVALID, false);
695 698
696 // Initializes wallpaper after active_user_ is set. 699 // Initializes wallpaper after active_user_ is set.
697 WallpaperManager::Get()->SetUserWallpaperNow(login::GuestAccountId()); 700 WallpaperManager::Get()->SetUserWallpaperNow(login::GuestAccountId());
698 } 701 }
699 702
700 void ChromeUserManagerImpl::RegularUserLoggedIn(const AccountId& account_id) { 703 void ChromeUserManagerImpl::RegularUserLoggedIn(const AccountId& account_id) {
701 ChromeUserManager::RegularUserLoggedIn(account_id); 704 ChromeUserManager::RegularUserLoggedIn(account_id);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 const AccountId& kiosk_app_account_id) { 793 const AccountId& kiosk_app_account_id) {
791 DCHECK_CURRENTLY_ON(BrowserThread::UI); 794 DCHECK_CURRENTLY_ON(BrowserThread::UI);
792 policy::DeviceLocalAccount::Type device_local_account_type; 795 policy::DeviceLocalAccount::Type device_local_account_type;
793 DCHECK(policy::IsDeviceLocalAccountUser(kiosk_app_account_id.GetUserEmail(), 796 DCHECK(policy::IsDeviceLocalAccountUser(kiosk_app_account_id.GetUserEmail(),
794 &device_local_account_type)); 797 &device_local_account_type));
795 DCHECK_EQ(policy::DeviceLocalAccount::TYPE_KIOSK_APP, 798 DCHECK_EQ(policy::DeviceLocalAccount::TYPE_KIOSK_APP,
796 device_local_account_type); 799 device_local_account_type);
797 800
798 active_user_ = user_manager::User::CreateKioskAppUser(kiosk_app_account_id); 801 active_user_ = user_manager::User::CreateKioskAppUser(kiosk_app_account_id);
799 active_user_->SetStubImage( 802 active_user_->SetStubImage(
800 make_scoped_ptr(new user_manager::UserImage( 803 base::WrapUnique(new user_manager::UserImage(
801 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 804 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
802 IDR_PROFILE_PICTURE_LOADING))), 805 IDR_PROFILE_PICTURE_LOADING))),
803 user_manager::User::USER_IMAGE_INVALID, false); 806 user_manager::User::USER_IMAGE_INVALID, false);
804 807
805 WallpaperManager::Get()->SetUserWallpaperNow(kiosk_app_account_id); 808 WallpaperManager::Get()->SetUserWallpaperNow(kiosk_app_account_id);
806 809
807 // TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like 810 // TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like
808 // the kiosk_app_id in these objects, removing the need to re-parse the 811 // the kiosk_app_id in these objects, removing the need to re-parse the
809 // device-local account list here to extract the kiosk_app_id. 812 // device-local account list here to extract the kiosk_app_id.
810 const std::vector<policy::DeviceLocalAccount> device_local_accounts = 813 const std::vector<policy::DeviceLocalAccount> device_local_accounts =
(...skipping 23 matching lines...) Expand all
834 837
835 // Disable window animation since kiosk app runs in a single full screen 838 // Disable window animation since kiosk app runs in a single full screen
836 // window and window animation causes start-up janks. 839 // window and window animation causes start-up janks.
837 command_line->AppendSwitch(wm::switches::kWindowAnimationsDisabled); 840 command_line->AppendSwitch(wm::switches::kWindowAnimationsDisabled);
838 } 841 }
839 842
840 void ChromeUserManagerImpl::DemoAccountLoggedIn() { 843 void ChromeUserManagerImpl::DemoAccountLoggedIn() {
841 DCHECK_CURRENTLY_ON(BrowserThread::UI); 844 DCHECK_CURRENTLY_ON(BrowserThread::UI);
842 active_user_ = user_manager::User::CreateKioskAppUser(login::DemoAccountId()); 845 active_user_ = user_manager::User::CreateKioskAppUser(login::DemoAccountId());
843 active_user_->SetStubImage( 846 active_user_->SetStubImage(
844 make_scoped_ptr(new user_manager::UserImage( 847 base::WrapUnique(new user_manager::UserImage(
845 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 848 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
846 IDR_PROFILE_PICTURE_LOADING))), 849 IDR_PROFILE_PICTURE_LOADING))),
847 user_manager::User::USER_IMAGE_INVALID, false); 850 user_manager::User::USER_IMAGE_INVALID, false);
848 WallpaperManager::Get()->SetUserWallpaperNow(login::DemoAccountId()); 851 WallpaperManager::Get()->SetUserWallpaperNow(login::DemoAccountId());
849 852
850 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 853 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
851 command_line->AppendSwitch(::switches::kForceAppMode); 854 command_line->AppendSwitch(::switches::kForceAppMode);
852 command_line->AppendSwitchASCII(::switches::kAppId, 855 command_line->AppendSwitchASCII(::switches::kAppId,
853 DemoAppLauncher::kDemoAppId); 856 DemoAppLauncher::kDemoAppId);
854 857
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 base::Bind(ResolveLocale, locale, base::Unretained(out_resolved_locale)), 1292 base::Bind(ResolveLocale, locale, base::Unretained(out_resolved_locale)),
1290 on_resolved_callback); 1293 on_resolved_callback);
1291 } 1294 }
1292 1295
1293 bool ChromeUserManagerImpl::IsValidDefaultUserImageId(int image_index) const { 1296 bool ChromeUserManagerImpl::IsValidDefaultUserImageId(int image_index) const {
1294 return image_index >= 0 && 1297 return image_index >= 0 &&
1295 image_index < chromeos::default_user_image::kDefaultImagesCount; 1298 image_index < chromeos::default_user_image::kDefaultImagesCount;
1296 } 1299 }
1297 1300
1298 } // namespace chromeos 1301 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698