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

Side by Side Diff: remoting/host/policy_hack/policy_watcher.cc

Issue 886913002: Always run PolicyWatcher on UI thread in It2Me host. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Most of this code is copied from: 5 // Most of this code is copied from:
6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} 6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc}
7 7
8 #include "remoting/host/policy_hack/policy_watcher.h" 8 #include "remoting/host/policy_hack/policy_watcher.h"
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 new policy::PolicyServiceImpl(providers)); 271 new policy::PolicyServiceImpl(providers));
272 272
273 policy::PolicyService* borrowed_policy_service = policy_service.get(); 273 policy::PolicyService* borrowed_policy_service = policy_service.get();
274 return make_scoped_ptr(new PolicyWatcher( 274 return make_scoped_ptr(new PolicyWatcher(
275 policy_service_task_runner, borrowed_policy_service, 275 policy_service_task_runner, borrowed_policy_service,
276 policy_service.Pass(), policy_provider.Pass(), schema_registry.Pass())); 276 policy_service.Pass(), policy_provider.Pass(), schema_registry.Pass()));
277 } 277 }
278 278
279 scoped_ptr<PolicyWatcher> PolicyWatcher::Create( 279 scoped_ptr<PolicyWatcher> PolicyWatcher::Create(
280 policy::PolicyService* policy_service, 280 policy::PolicyService* policy_service,
281 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner) { 281 const scoped_refptr<base::SingleThreadTaskRunner>& current_task_runner,
282 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) {
283 DCHECK(current_task_runner->BelongsToCurrentThread());
Łukasz Anforowicz 2015/01/30 05:35:55 It might be possible to avoid explicitly passing c
Sergey Ulanov 2015/01/30 19:33:45 base::ThreadTaskRunnerHandle::Get() is the preferr
284
282 #if defined(OS_CHROMEOS) 285 #if defined(OS_CHROMEOS)
286 // On Chrome OS the PolicyService is owned by the browser.
283 DCHECK(policy_service); 287 DCHECK(policy_service);
284 return make_scoped_ptr( 288 return make_scoped_ptr(
285 new PolicyWatcher(content::BrowserThread::GetMessageLoopProxyForThread( 289 new PolicyWatcher(content::BrowserThread::GetMessageLoopProxyForThread(
286 content::BrowserThread::UI), 290 content::BrowserThread::UI),
Łukasz Anforowicz 2015/01/30 05:35:55 This call to GetMessageLoopProxyForThread should p
Sergey Ulanov 2015/01/30 19:33:45 removed current_task_runner
287 policy_service, nullptr, nullptr, nullptr)); 291 policy_service, nullptr, nullptr, nullptr));
288 #elif defined(OS_WIN) 292 #else // !defined(OS_CHROMEOS)
289 DCHECK(!policy_service); 293 DCHECK(!policy_service);
290 // Always read the Chrome policies (even on Chromium) so that policy 294
291 // enforcement can't be bypassed by running Chromium. 295 // Create platform-specific PolicyLoader. Always read the Chrome policies
292 // Note that this comment applies to all of Win/Mac/Posix branches below. 296 // (even on Chromium) so that policy enforcement can't be bypassed by running
293 static const wchar_t kRegistryKey[] = L"SOFTWARE\\Policies\\Google\\Chrome"; 297 // Chromium.
294 return PolicyWatcher::CreateFromPolicyLoader( 298 scoped_ptr<policy::AsyncPolicyLoader> policy_loader;
295 network_task_runner, 299 #if defined(OS_WIN)
296 policy::PolicyLoaderWin::Create(network_task_runner, kRegistryKey)); 300 policy_loader = policy::PolicyLoaderWin::Create(
301 io_task_runner, L"SOFTWARE\\Policies\\Google\\Chrome");
297 #elif defined(OS_MACOSX) 302 #elif defined(OS_MACOSX)
298 CFStringRef bundle_id = CFSTR("com.google.Chrome"); 303 CFStringRef bundle_id = CFSTR("com.google.Chrome");
299 DCHECK(!policy_service); 304 policy_loader.reset(new policy::PolicyLoaderMac(
300 return PolicyWatcher::CreateFromPolicyLoader( 305 io_task_runner,
301 network_task_runner, 306 policy::PolicyLoaderMac::GetManagedPolicyPath(bundle_id),
302 make_scoped_ptr(new policy::PolicyLoaderMac( 307 new MacPreferences(), bundle_id));
303 network_task_runner,
304 policy::PolicyLoaderMac::GetManagedPolicyPath(bundle_id),
305 new MacPreferences(), bundle_id)));
306 #elif defined(OS_POSIX) && !defined(OS_ANDROID) 308 #elif defined(OS_POSIX) && !defined(OS_ANDROID)
307 DCHECK(!policy_service); 309 policy_loader.reset(new policy::ConfigDirPolicyLoader(
308 static const base::FilePath::CharType kPolicyDir[] = 310 io_task_runner,
309 FILE_PATH_LITERAL("/etc/opt/chrome/policies"); 311 base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")),
310 return PolicyWatcher::CreateFromPolicyLoader( 312 policy::POLICY_SCOPE_MACHINE));
311 network_task_runner, make_scoped_ptr(new policy::ConfigDirPolicyLoader(
312 network_task_runner, base::FilePath(kPolicyDir),
313 policy::POLICY_SCOPE_MACHINE)));
314 #else 313 #else
315 #error OS that is not yet supported by PolicyWatcher code. 314 #error OS that is not yet supported by PolicyWatcher code.
316 #endif 315 #endif
316
317 return PolicyWatcher::CreateFromPolicyLoader(current_task_runner,
318 policy_loader.Pass());
319 #endif // !(OS_CHROMEOS)
317 } 320 }
318 321
319 } // namespace policy_hack 322 } // namespace policy_hack
320 } // namespace remoting 323 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698