OLD | NEW |
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/policy/chrome_browser_policy_connector.h" | 5 #include "chrome/browser/policy/chrome_browser_policy_connector.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
16 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h" | 16 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h" |
17 #include "chrome/browser/policy/device_management_service_configuration.h" | 17 #include "chrome/browser/policy/device_management_service_configuration.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "components/policy/core/common/async_policy_provider.h" | 19 #include "components/policy/core/common/async_policy_provider.h" |
20 #include "components/policy/core/common/cloud/device_management_service.h" | 20 #include "components/policy/core/common/cloud/device_management_service.h" |
21 #include "components/policy/core/common/configuration_policy_provider.h" | 21 #include "components/policy/core/common/configuration_policy_provider.h" |
22 #include "components/policy/core/common/policy_map.h" | 22 #include "components/policy/core/common/policy_map.h" |
23 #include "components/policy/core/common/policy_namespace.h" | 23 #include "components/policy/core/common/policy_namespace.h" |
24 #include "components/policy/core/common/policy_service.h" | 24 #include "components/policy/core/common/policy_service.h" |
25 #include "components/policy/core/common/policy_types.h" | 25 #include "components/policy/core/common/policy_types.h" |
26 #include "components/signin/core/common/signin_switches.h" | |
27 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
28 #include "net/url_request/url_request_context_getter.h" | 27 #include "net/url_request/url_request_context_getter.h" |
29 #include "policy/policy_constants.h" | 28 #include "policy/policy_constants.h" |
30 | 29 |
31 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
32 #include "components/policy/core/common/policy_loader_win.h" | 31 #include "components/policy/core/common/policy_loader_win.h" |
33 #elif defined(OS_MACOSX) | 32 #elif defined(OS_MACOSX) |
34 #include <CoreFoundation/CoreFoundation.h> | 33 #include <CoreFoundation/CoreFoundation.h> |
35 #include "components/policy/core/common/policy_loader_mac.h" | 34 #include "components/policy/core/common/policy_loader_mac.h" |
36 #include "components/policy/core/common/preferences_mac.h" | 35 #include "components/policy/core/common/preferences_mac.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 scoped_ptr<DeviceManagementService::Configuration> configuration( | 80 scoped_ptr<DeviceManagementService::Configuration> configuration( |
82 new DeviceManagementServiceConfiguration( | 81 new DeviceManagementServiceConfiguration( |
83 BrowserPolicyConnector::GetDeviceManagementUrl())); | 82 BrowserPolicyConnector::GetDeviceManagementUrl())); |
84 scoped_ptr<DeviceManagementService> device_management_service( | 83 scoped_ptr<DeviceManagementService> device_management_service( |
85 new DeviceManagementService(configuration.Pass())); | 84 new DeviceManagementService(configuration.Pass())); |
86 device_management_service->ScheduleInitialization( | 85 device_management_service->ScheduleInitialization( |
87 kServiceInitializationStartupDelay); | 86 kServiceInitializationStartupDelay); |
88 | 87 |
89 BrowserPolicyConnector::Init( | 88 BrowserPolicyConnector::Init( |
90 local_state, request_context, device_management_service.Pass()); | 89 local_state, request_context, device_management_service.Pass()); |
91 | |
92 AppendExtraFlagPerPolicy(); | |
93 } | 90 } |
94 | 91 |
95 ConfigurationPolicyProvider* | 92 ConfigurationPolicyProvider* |
96 ChromeBrowserPolicyConnector::CreatePlatformProvider() { | 93 ChromeBrowserPolicyConnector::CreatePlatformProvider() { |
97 #if defined(OS_WIN) | 94 #if defined(OS_WIN) |
98 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( | 95 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( |
99 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 96 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
100 kRegistryChromePolicyKey)); | 97 kRegistryChromePolicyKey)); |
101 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); | 98 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
102 #elif defined(OS_MACOSX) | 99 #elif defined(OS_MACOSX) |
(...skipping 13 matching lines...) Expand all Loading... |
116 } else { | 113 } else { |
117 return NULL; | 114 return NULL; |
118 } | 115 } |
119 #elif defined(OS_ANDROID) | 116 #elif defined(OS_ANDROID) |
120 return new PolicyProviderAndroid(); | 117 return new PolicyProviderAndroid(); |
121 #else | 118 #else |
122 return NULL; | 119 return NULL; |
123 #endif | 120 #endif |
124 } | 121 } |
125 | 122 |
126 void ChromeBrowserPolicyConnector::AppendExtraFlagPerPolicy() { | |
127 PolicyService* policy_service = GetPolicyService(); | |
128 PolicyNamespace chrome_ns = PolicyNamespace(POLICY_DOMAIN_CHROME, ""); | |
129 const PolicyMap& chrome_policy = policy_service->GetPolicies(chrome_ns); | |
130 const base::Value* policy_value = | |
131 chrome_policy.GetValue(key::kEnableWebBasedSignin); | |
132 bool enabled = false; | |
133 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
134 if (policy_value && policy_value->GetAsBoolean(&enabled) && enabled && | |
135 !command_line->HasSwitch(switches::kEnableWebBasedSignin)) { | |
136 command_line->AppendSwitch(switches::kEnableWebBasedSignin); | |
137 } | |
138 } | |
139 | |
140 } // namespace policy | 123 } // namespace policy |
OLD | NEW |