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

Side by Side Diff: chrome/browser/policy/chrome_browser_policy_connector.cc

Issue 240903002: Add consumer_device_management_service() in BrowserPolicyConnectorChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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
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 DeviceManagementServiceConfiguration(
bartfab (slow) 2014/04/23 12:17:18 Nit: explicit.
davidyu 2014/04/23 12:56:58 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
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 ScopedVector<DeviceManagementService> services;
bartfab (slow) 2014/04/23 12:17:18 Nit: #include "base/memory/scoped_vector.h"
davidyu 2014/04/23 12:56:58 ScopedVector<> removed.
152 new DeviceManagementServiceConfiguration); 157 for (int i = 0; i < NUM_MANAGEMENT_MODES; ++i) {
153 scoped_ptr<DeviceManagementService> device_management_service( 158 scoped_ptr<DeviceManagementService::Configuration> configuration(
154 new DeviceManagementService(configuration.Pass())); 159 new DeviceManagementServiceConfiguration(
155 device_management_service->ScheduleInitialization( 160 static_cast<ManagementMode>(i)));
156 kServiceInitializationStartupDelay); 161 services.push_back(
162 new DeviceManagementService(configuration.Pass()));
163 services.back()->ScheduleInitialization(
164 kServiceInitializationStartupDelay);
165 }
157 166
158 BrowserPolicyConnector::Init( 167 BrowserPolicyConnector::Init(local_state, request_context, services.Pass());
159 local_state, request_context, device_management_service.Pass());
160 } 168 }
161 169
162 ConfigurationPolicyProvider* 170 ConfigurationPolicyProvider*
163 ChromeBrowserPolicyConnector::CreatePlatformProvider() { 171 ChromeBrowserPolicyConnector::CreatePlatformProvider() {
164 #if defined(OS_WIN) 172 #if defined(OS_WIN)
165 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( 173 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create(
166 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), 174 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
167 kRegistryChromePolicyKey)); 175 kRegistryChromePolicyKey));
168 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); 176 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass());
169 #elif defined(OS_MACOSX) 177 #elif defined(OS_MACOSX)
(...skipping 14 matching lines...) Expand all
184 return NULL; 192 return NULL;
185 } 193 }
186 #elif defined(OS_ANDROID) 194 #elif defined(OS_ANDROID)
187 return new PolicyProviderAndroid(); 195 return new PolicyProviderAndroid();
188 #else 196 #else
189 return NULL; 197 return NULL;
190 #endif 198 #endif
191 } 199 }
192 200
193 } // namespace policy 201 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698