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

Side by Side Diff: chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.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 (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/policy/user_cloud_policy_manager_factory_chrom eos.h" 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 // static 81 // static
82 UserCloudPolicyManagerChromeOS* 82 UserCloudPolicyManagerChromeOS*
83 UserCloudPolicyManagerFactoryChromeOS::GetForProfile( 83 UserCloudPolicyManagerFactoryChromeOS::GetForProfile(
84 Profile* profile) { 84 Profile* profile) {
85 return GetInstance()->GetManagerForProfile(profile); 85 return GetInstance()->GetManagerForProfile(profile);
86 } 86 }
87 87
88 // static 88 // static
89 scoped_ptr<UserCloudPolicyManagerChromeOS> 89 std::unique_ptr<UserCloudPolicyManagerChromeOS>
90 UserCloudPolicyManagerFactoryChromeOS::CreateForProfile( 90 UserCloudPolicyManagerFactoryChromeOS::CreateForProfile(
91 Profile* profile, 91 Profile* profile,
92 bool force_immediate_load, 92 bool force_immediate_load,
93 scoped_refptr<base::SequencedTaskRunner> background_task_runner) { 93 scoped_refptr<base::SequencedTaskRunner> background_task_runner) {
94 return GetInstance()->CreateManagerForProfile( 94 return GetInstance()->CreateManagerForProfile(
95 profile, force_immediate_load, background_task_runner); 95 profile, force_immediate_load, background_task_runner);
96 } 96 }
97 97
98 UserCloudPolicyManagerFactoryChromeOS::UserCloudPolicyManagerFactoryChromeOS() 98 UserCloudPolicyManagerFactoryChromeOS::UserCloudPolicyManagerFactoryChromeOS()
99 : BrowserContextKeyedBaseFactory( 99 : BrowserContextKeyedBaseFactory(
100 "UserCloudPolicyManagerChromeOS", 100 "UserCloudPolicyManagerChromeOS",
101 BrowserContextDependencyManager::GetInstance()) { 101 BrowserContextDependencyManager::GetInstance()) {
102 DependsOn(SchemaRegistryServiceFactory::GetInstance()); 102 DependsOn(SchemaRegistryServiceFactory::GetInstance());
103 } 103 }
104 104
105 UserCloudPolicyManagerFactoryChromeOS:: 105 UserCloudPolicyManagerFactoryChromeOS::
106 ~UserCloudPolicyManagerFactoryChromeOS() {} 106 ~UserCloudPolicyManagerFactoryChromeOS() {}
107 107
108 UserCloudPolicyManagerChromeOS* 108 UserCloudPolicyManagerChromeOS*
109 UserCloudPolicyManagerFactoryChromeOS::GetManagerForProfile( 109 UserCloudPolicyManagerFactoryChromeOS::GetManagerForProfile(
110 Profile* profile) { 110 Profile* profile) {
111 // Get the manager for the original profile, since the PolicyService is 111 // Get the manager for the original profile, since the PolicyService is
112 // also shared between the incognito Profile and the original Profile. 112 // also shared between the incognito Profile and the original Profile.
113 ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile()); 113 ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile());
114 return it != managers_.end() ? it->second : NULL; 114 return it != managers_.end() ? it->second : NULL;
115 } 115 }
116 116
117 scoped_ptr<UserCloudPolicyManagerChromeOS> 117 std::unique_ptr<UserCloudPolicyManagerChromeOS>
118 UserCloudPolicyManagerFactoryChromeOS::CreateManagerForProfile( 118 UserCloudPolicyManagerFactoryChromeOS::CreateManagerForProfile(
119 Profile* profile, 119 Profile* profile,
120 bool force_immediate_load, 120 bool force_immediate_load,
121 scoped_refptr<base::SequencedTaskRunner> background_task_runner) { 121 scoped_refptr<base::SequencedTaskRunner> background_task_runner) {
122 const base::CommandLine* command_line = 122 const base::CommandLine* command_line =
123 base::CommandLine::ForCurrentProcess(); 123 base::CommandLine::ForCurrentProcess();
124 // Don't initialize cloud policy for the signin profile. 124 // Don't initialize cloud policy for the signin profile.
125 if (chromeos::ProfileHelper::IsSigninProfile(profile)) 125 if (chromeos::ProfileHelper::IsSigninProfile(profile))
126 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); 126 return std::unique_ptr<UserCloudPolicyManagerChromeOS>();
127 127
128 // |user| should never be NULL except for the signin profile. This object is 128 // |user| should never be NULL except for the signin profile. This object is
129 // created as part of the Profile creation, which happens right after 129 // created as part of the Profile creation, which happens right after
130 // sign-in. The just-signed-in User is the active user during that time. 130 // sign-in. The just-signed-in User is the active user during that time.
131 const user_manager::User* user = 131 const user_manager::User* user =
132 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); 132 chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
133 CHECK(user); 133 CHECK(user);
134 134
135 // User policy exists for enterprise accounts only: 135 // User policy exists for enterprise accounts only:
136 // - For regular enterprise users (those who have a GAIA account), a 136 // - For regular enterprise users (those who have a GAIA account), a
137 // |UserCloudPolicyManagerChromeOS| is created here. 137 // |UserCloudPolicyManagerChromeOS| is created here.
138 // - For device-local accounts, policy is provided by 138 // - For device-local accounts, policy is provided by
139 // |DeviceLocalAccountPolicyService|. 139 // |DeviceLocalAccountPolicyService|.
140 // All other user types do not have user policy. 140 // All other user types do not have user policy.
141 const AccountId account_id = user->GetAccountId(); 141 const AccountId account_id = user->GetAccountId();
142 if (!user->HasGaiaAccount() || user->IsSupervised() || 142 if (!user->HasGaiaAccount() || user->IsSupervised() ||
143 BrowserPolicyConnector::IsNonEnterpriseUser(account_id.GetUserEmail())) { 143 BrowserPolicyConnector::IsNonEnterpriseUser(account_id.GetUserEmail())) {
144 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); 144 return std::unique_ptr<UserCloudPolicyManagerChromeOS>();
145 } 145 }
146 146
147 policy::BrowserPolicyConnectorChromeOS* connector = 147 policy::BrowserPolicyConnectorChromeOS* connector =
148 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 148 g_browser_process->platform_part()->browser_policy_connector_chromeos();
149 const bool is_browser_restart = 149 const bool is_browser_restart =
150 command_line->HasSwitch(chromeos::switches::kLoginUser); 150 command_line->HasSwitch(chromeos::switches::kLoginUser);
151 const user_manager::UserManager* const user_manager = 151 const user_manager::UserManager* const user_manager =
152 user_manager::UserManager::Get(); 152 user_manager::UserManager::Get();
153 153
154 // We want to block for policy in a few situations: if the user is new, or 154 // We want to block for policy in a few situations: if the user is new, or
(...skipping 28 matching lines...) Expand all
183 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); 183 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir);
184 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); 184 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy);
185 const base::FilePath token_cache_file = legacy_dir.Append(kToken); 185 const base::FilePath token_cache_file = legacy_dir.Append(kToken);
186 const base::FilePath component_policy_cache_dir = 186 const base::FilePath component_policy_cache_dir =
187 profile_dir.Append(kPolicy).Append(kComponentsDir); 187 profile_dir.Append(kPolicy).Append(kComponentsDir);
188 const base::FilePath external_data_dir = 188 const base::FilePath external_data_dir =
189 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); 189 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir);
190 base::FilePath policy_key_dir; 190 base::FilePath policy_key_dir;
191 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir)); 191 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir));
192 192
193 scoped_ptr<UserCloudPolicyStoreChromeOS> store( 193 std::unique_ptr<UserCloudPolicyStoreChromeOS> store(
194 new UserCloudPolicyStoreChromeOS( 194 new UserCloudPolicyStoreChromeOS(
195 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), 195 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(),
196 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), 196 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
197 background_task_runner, account_id, policy_key_dir, token_cache_file, 197 background_task_runner, account_id, policy_key_dir, token_cache_file,
198 policy_cache_file)); 198 policy_cache_file));
199 199
200 scoped_refptr<base::SequencedTaskRunner> backend_task_runner = 200 scoped_refptr<base::SequencedTaskRunner> backend_task_runner =
201 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( 201 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
202 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); 202 content::BrowserThread::GetBlockingPool()->GetSequenceToken());
203 scoped_refptr<base::SequencedTaskRunner> io_task_runner = 203 scoped_refptr<base::SequencedTaskRunner> io_task_runner =
204 content::BrowserThread::GetMessageLoopProxyForThread( 204 content::BrowserThread::GetMessageLoopProxyForThread(
205 content::BrowserThread::IO); 205 content::BrowserThread::IO);
206 scoped_ptr<CloudExternalDataManager> external_data_manager( 206 std::unique_ptr<CloudExternalDataManager> external_data_manager(
207 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails), 207 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails),
208 backend_task_runner, 208 backend_task_runner, io_task_runner,
209 io_task_runner, 209 external_data_dir, store.get()));
210 external_data_dir,
211 store.get()));
212 if (force_immediate_load) 210 if (force_immediate_load)
213 store->LoadImmediately(); 211 store->LoadImmediately();
214 212
215 scoped_refptr<base::SequencedTaskRunner> file_task_runner = 213 scoped_refptr<base::SequencedTaskRunner> file_task_runner =
216 content::BrowserThread::GetMessageLoopProxyForThread( 214 content::BrowserThread::GetMessageLoopProxyForThread(
217 content::BrowserThread::FILE); 215 content::BrowserThread::FILE);
218 216
219 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( 217 std::unique_ptr<UserCloudPolicyManagerChromeOS> manager(
220 new UserCloudPolicyManagerChromeOS( 218 new UserCloudPolicyManagerChromeOS(
221 std::move(store), std::move(external_data_manager), 219 std::move(store), std::move(external_data_manager),
222 component_policy_cache_dir, wait_for_policy_fetch, 220 component_policy_cache_dir, wait_for_policy_fetch,
223 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(), 221 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(),
224 file_task_runner, io_task_runner)); 222 file_task_runner, io_task_runner));
225 223
226 bool wildcard_match = false; 224 bool wildcard_match = false;
227 if (connector->IsEnterpriseManaged() && 225 if (connector->IsEnterpriseManaged() &&
228 chromeos::CrosSettings::IsWhitelisted(account_id.GetUserEmail(), 226 chromeos::CrosSettings::IsWhitelisted(account_id.GetUserEmail(),
229 &wildcard_match) && 227 &wildcard_match) &&
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 262
265 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( 263 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory(
266 content::BrowserContext* context) { 264 content::BrowserContext* context) {
267 return false; 265 return false;
268 } 266 }
269 267
270 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( 268 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow(
271 content::BrowserContext* context) {} 269 content::BrowserContext* context) {}
272 270
273 } // namespace policy 271 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698