Chromium Code Reviews| Index: remoting/host/policy_hack/policy_watcher.cc |
| diff --git a/remoting/host/policy_hack/policy_watcher.cc b/remoting/host/policy_hack/policy_watcher.cc |
| index ff0da0e6215753a43618da8682e62042da1b2899..2d20f203b91465394d87d43816bd88a6bdb02152 100644 |
| --- a/remoting/host/policy_hack/policy_watcher.cc |
| +++ b/remoting/host/policy_hack/policy_watcher.cc |
| @@ -278,42 +278,45 @@ scoped_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoader( |
| scoped_ptr<PolicyWatcher> PolicyWatcher::Create( |
| policy::PolicyService* policy_service, |
| - const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner) { |
| + const scoped_refptr<base::SingleThreadTaskRunner>& current_task_runner, |
| + const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) { |
| + 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
|
| + |
| #if defined(OS_CHROMEOS) |
| + // On Chrome OS the PolicyService is owned by the browser. |
| DCHECK(policy_service); |
| return make_scoped_ptr( |
| new PolicyWatcher(content::BrowserThread::GetMessageLoopProxyForThread( |
| 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
|
| policy_service, nullptr, nullptr, nullptr)); |
| -#elif defined(OS_WIN) |
| +#else // !defined(OS_CHROMEOS) |
| DCHECK(!policy_service); |
| - // Always read the Chrome policies (even on Chromium) so that policy |
| - // enforcement can't be bypassed by running Chromium. |
| - // Note that this comment applies to all of Win/Mac/Posix branches below. |
| - static const wchar_t kRegistryKey[] = L"SOFTWARE\\Policies\\Google\\Chrome"; |
| - return PolicyWatcher::CreateFromPolicyLoader( |
| - network_task_runner, |
| - policy::PolicyLoaderWin::Create(network_task_runner, kRegistryKey)); |
| + |
| + // Create platform-specific PolicyLoader. Always read the Chrome policies |
| + // (even on Chromium) so that policy enforcement can't be bypassed by running |
| + // Chromium. |
| + scoped_ptr<policy::AsyncPolicyLoader> policy_loader; |
| +#if defined(OS_WIN) |
| + policy_loader = policy::PolicyLoaderWin::Create( |
| + io_task_runner, L"SOFTWARE\\Policies\\Google\\Chrome"); |
| #elif defined(OS_MACOSX) |
| CFStringRef bundle_id = CFSTR("com.google.Chrome"); |
| - DCHECK(!policy_service); |
| - return PolicyWatcher::CreateFromPolicyLoader( |
| - network_task_runner, |
| - make_scoped_ptr(new policy::PolicyLoaderMac( |
| - network_task_runner, |
| - policy::PolicyLoaderMac::GetManagedPolicyPath(bundle_id), |
| - new MacPreferences(), bundle_id))); |
| + policy_loader.reset(new policy::PolicyLoaderMac( |
| + io_task_runner, |
| + policy::PolicyLoaderMac::GetManagedPolicyPath(bundle_id), |
| + new MacPreferences(), bundle_id)); |
| #elif defined(OS_POSIX) && !defined(OS_ANDROID) |
| - DCHECK(!policy_service); |
| - static const base::FilePath::CharType kPolicyDir[] = |
| - FILE_PATH_LITERAL("/etc/opt/chrome/policies"); |
| - return PolicyWatcher::CreateFromPolicyLoader( |
| - network_task_runner, make_scoped_ptr(new policy::ConfigDirPolicyLoader( |
| - network_task_runner, base::FilePath(kPolicyDir), |
| - policy::POLICY_SCOPE_MACHINE))); |
| + policy_loader.reset(new policy::ConfigDirPolicyLoader( |
| + io_task_runner, |
| + base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")), |
| + policy::POLICY_SCOPE_MACHINE)); |
| #else |
| #error OS that is not yet supported by PolicyWatcher code. |
| #endif |
| + |
| + return PolicyWatcher::CreateFromPolicyLoader(current_task_runner, |
| + policy_loader.Pass()); |
| +#endif // !(OS_CHROMEOS) |
| } |
| } // namespace policy_hack |