Chromium Code Reviews| 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" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 if (!bundle_id) | 72 if (!bundle_id) |
| 73 return base::FilePath(); | 73 return base::FilePath(); |
| 74 | 74 |
| 75 return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist"); | 75 return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist"); |
| 76 } | 76 } |
| 77 #endif // defined(OS_MACOSX) | 77 #endif // defined(OS_MACOSX) |
| 78 | 78 |
| 79 class DeviceManagementServiceConfiguration | 79 class DeviceManagementServiceConfiguration |
| 80 : public DeviceManagementService::Configuration { | 80 : public DeviceManagementService::Configuration { |
| 81 public: | 81 public: |
| 82 DeviceManagementServiceConfiguration() {} | 82 explicit DeviceManagementServiceConfiguration( |
|
Mattias Nissler (ping if slow)
2014/04/23 14:32:39
Note that this file is the cross-platform BrowserP
davidyu
2014/04/23 15:22:50
I don't think we will make this feature available
Mattias Nissler (ping if slow)
2014/04/23 15:25:18
Yes, everything related to consumer management sho
davidyu
2014/04/24 04:52:41
Done.
| |
| 83 BrowserPolicyConnector::ManagementMode management_mode) | |
| 84 : management_mode_(management_mode) {} | |
| 83 virtual ~DeviceManagementServiceConfiguration() {} | 85 virtual ~DeviceManagementServiceConfiguration() {} |
| 84 | 86 |
| 85 virtual std::string GetServerUrl() OVERRIDE { | 87 virtual std::string GetServerUrl() OVERRIDE { |
| 86 return BrowserPolicyConnector::GetDeviceManagementUrl(); | 88 return BrowserPolicyConnector::GetDeviceManagementUrl(management_mode_); |
| 87 } | 89 } |
| 88 | 90 |
| 89 virtual std::string GetAgentParameter() OVERRIDE { | 91 virtual std::string GetAgentParameter() OVERRIDE { |
| 90 chrome::VersionInfo version_info; | 92 chrome::VersionInfo version_info; |
| 91 return base::StringPrintf("%s %s(%s)", | 93 return base::StringPrintf("%s %s(%s)", |
| 92 version_info.Name().c_str(), | 94 version_info.Name().c_str(), |
| 93 version_info.Version().c_str(), | 95 version_info.Version().c_str(), |
| 94 version_info.LastChange().c_str()); | 96 version_info.LastChange().c_str()); |
| 95 } | 97 } |
| 96 | 98 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 121 &os_bugfix_version); | 123 &os_bugfix_version); |
| 122 os_version = base::StringPrintf("%d.%d.%d", | 124 os_version = base::StringPrintf("%d.%d.%d", |
| 123 os_major_version, | 125 os_major_version, |
| 124 os_minor_version, | 126 os_minor_version, |
| 125 os_bugfix_version); | 127 os_bugfix_version); |
| 126 #endif | 128 #endif |
| 127 | 129 |
| 128 return base::StringPrintf( | 130 return base::StringPrintf( |
| 129 "%s|%s|%s", os_name.c_str(), os_hardware.c_str(), os_version.c_str()); | 131 "%s|%s|%s", os_name.c_str(), os_hardware.c_str(), os_version.c_str()); |
| 130 } | 132 } |
| 133 | |
| 134 private: | |
| 135 BrowserPolicyConnector::ManagementMode management_mode_; | |
| 131 }; | 136 }; |
| 132 | 137 |
| 133 } // namespace | 138 } // namespace |
| 134 | 139 |
| 135 ChromeBrowserPolicyConnector::ChromeBrowserPolicyConnector() | 140 ChromeBrowserPolicyConnector::ChromeBrowserPolicyConnector() |
| 136 : BrowserPolicyConnector(base::Bind(&BuildHandlerList)) { | 141 : BrowserPolicyConnector(base::Bind(&BuildHandlerList)) { |
| 137 ConfigurationPolicyProvider* platform_provider = CreatePlatformProvider(); | 142 ConfigurationPolicyProvider* platform_provider = CreatePlatformProvider(); |
| 138 if (platform_provider) | 143 if (platform_provider) |
| 139 SetPlatformPolicyProvider(make_scoped_ptr(platform_provider)); | 144 SetPlatformPolicyProvider(make_scoped_ptr(platform_provider)); |
| 140 } | 145 } |
| 141 | 146 |
| 142 ChromeBrowserPolicyConnector::~ChromeBrowserPolicyConnector() {} | 147 ChromeBrowserPolicyConnector::~ChromeBrowserPolicyConnector() {} |
| 143 | 148 |
| 144 void ChromeBrowserPolicyConnector::Init( | 149 void ChromeBrowserPolicyConnector::Init( |
| 145 PrefService* local_state, | 150 PrefService* local_state, |
| 146 scoped_refptr<net::URLRequestContextGetter> request_context) { | 151 scoped_refptr<net::URLRequestContextGetter> request_context) { |
| 147 // Initialization of some of the providers requires the FILE thread; make | 152 // Initialization of some of the providers requires the FILE thread; make |
| 148 // sure that threading is ready at this point. | 153 // sure that threading is ready at this point. |
| 149 DCHECK(BrowserThread::IsThreadInitialized(BrowserThread::FILE)); | 154 DCHECK(BrowserThread::IsThreadInitialized(BrowserThread::FILE)); |
| 150 | 155 |
| 151 scoped_ptr<DeviceManagementService::Configuration> configuration( | 156 scoped_ptr<DeviceManagementService::Configuration> enterprise_configuration( |
| 152 new DeviceManagementServiceConfiguration); | 157 new DeviceManagementServiceConfiguration(ENTERPRISE_MANAGED)); |
| 153 scoped_ptr<DeviceManagementService> device_management_service( | 158 scoped_ptr<DeviceManagementService> enterprise_service( |
| 154 new DeviceManagementService(configuration.Pass())); | 159 new DeviceManagementService(enterprise_configuration.Pass())); |
| 155 device_management_service->ScheduleInitialization( | 160 enterprise_service->ScheduleInitialization( |
| 156 kServiceInitializationStartupDelay); | 161 kServiceInitializationStartupDelay); |
| 157 | 162 |
| 158 BrowserPolicyConnector::Init( | 163 scoped_ptr<DeviceManagementService::Configuration> consumer_configuration( |
| 159 local_state, request_context, device_management_service.Pass()); | 164 new DeviceManagementServiceConfiguration(CONSUMER_MANAGED)); |
| 165 scoped_ptr<DeviceManagementService> consumer_service( | |
| 166 new DeviceManagementService(consumer_configuration.Pass())); | |
| 167 consumer_service->ScheduleInitialization( | |
| 168 kServiceInitializationStartupDelay); | |
| 169 | |
| 170 BrowserPolicyConnector::Init(local_state, | |
| 171 request_context, | |
| 172 enterprise_service.Pass(), | |
| 173 consumer_service.Pass()); | |
| 160 } | 174 } |
| 161 | 175 |
| 162 ConfigurationPolicyProvider* | 176 ConfigurationPolicyProvider* |
| 163 ChromeBrowserPolicyConnector::CreatePlatformProvider() { | 177 ChromeBrowserPolicyConnector::CreatePlatformProvider() { |
| 164 #if defined(OS_WIN) | 178 #if defined(OS_WIN) |
| 165 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( | 179 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( |
| 166 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 180 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 167 kRegistryChromePolicyKey)); | 181 kRegistryChromePolicyKey)); |
| 168 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); | 182 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
| 169 #elif defined(OS_MACOSX) | 183 #elif defined(OS_MACOSX) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 184 return NULL; | 198 return NULL; |
| 185 } | 199 } |
| 186 #elif defined(OS_ANDROID) | 200 #elif defined(OS_ANDROID) |
| 187 return new PolicyProviderAndroid(); | 201 return new PolicyProviderAndroid(); |
| 188 #else | 202 #else |
| 189 return NULL; | 203 return NULL; |
| 190 #endif | 204 #endif |
| 191 } | 205 } |
| 192 | 206 |
| 193 } // namespace policy | 207 } // namespace policy |
| OLD | NEW |