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

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

Issue 8586030: Added ConfigurationPolicyProvider::RefreshPolicies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser_policy_connector.h" 5 #include "chrome/browser/policy/browser_policy_connector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 const char* kMachineInfoSerialNumberKeys[] = { 74 const char* kMachineInfoSerialNumberKeys[] = {
75 "sn", // ZGB 75 "sn", // ZGB
76 "Product_S/N", // Alex 76 "Product_S/N", // Alex
77 "Product_SN", // Mario 77 "Product_SN", // Mario
78 "serial_number" // VPD v2+ devices 78 "serial_number" // VPD v2+ devices
79 }; 79 };
80 #endif 80 #endif
81 81
82 } // namespace 82 } // namespace
83 83
84 // static 84 BrowserPolicyConnector::BrowserPolicyConnector()
85 BrowserPolicyConnector* BrowserPolicyConnector::Create() { 85 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {}
86 return new BrowserPolicyConnector();
87 }
88 86
89 BrowserPolicyConnector::~BrowserPolicyConnector() { 87 BrowserPolicyConnector::~BrowserPolicyConnector() {
90 // Shutdown device cloud policy. 88 // Shutdown device cloud policy.
91 #if defined(OS_CHROMEOS) 89 #if defined(OS_CHROMEOS)
92 if (device_cloud_policy_subsystem_.get()) 90 if (device_cloud_policy_subsystem_.get())
93 device_cloud_policy_subsystem_->Shutdown(); 91 device_cloud_policy_subsystem_->Shutdown();
94 device_cloud_policy_subsystem_.reset(); 92 device_cloud_policy_subsystem_.reset();
95 device_data_store_.reset(); 93 device_data_store_.reset();
96 #endif 94 #endif
97 95
98 // Shutdown user cloud policy. 96 // Shutdown user cloud policy.
99 if (user_cloud_policy_subsystem_.get()) 97 if (user_cloud_policy_subsystem_.get())
100 user_cloud_policy_subsystem_->Shutdown(); 98 user_cloud_policy_subsystem_->Shutdown();
101 user_cloud_policy_subsystem_.reset(); 99 user_cloud_policy_subsystem_.reset();
102 user_policy_token_cache_.reset(); 100 user_policy_token_cache_.reset();
103 user_data_store_.reset(); 101 user_data_store_.reset();
104 } 102 }
105 103
104 void BrowserPolicyConnector::Init() {
105 managed_platform_provider_.reset(CreateManagedPlatformProvider());
106 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider());
107
108 managed_cloud_provider_.reset(new CloudPolicyProviderImpl(
109 this,
110 GetChromePolicyDefinitionList(),
111 CloudPolicyCacheBase::POLICY_LEVEL_MANDATORY));
112 recommended_cloud_provider_.reset(new CloudPolicyProviderImpl(
113 this,
114 GetChromePolicyDefinitionList(),
115 CloudPolicyCacheBase::POLICY_LEVEL_RECOMMENDED));
116
117 #if defined(OS_CHROMEOS)
118 InitializeDevicePolicy();
119
120 network_configuration_updater_.reset(
121 new NetworkConfigurationUpdater(
122 managed_cloud_provider_.get(),
123 chromeos::CrosLibrary::Get()->GetNetworkLibrary()));
124 #endif
125 }
126
106 ConfigurationPolicyProvider* 127 ConfigurationPolicyProvider*
107 BrowserPolicyConnector::GetManagedPlatformProvider() const { 128 BrowserPolicyConnector::GetManagedPlatformProvider() const {
108 return managed_platform_provider_.get(); 129 return managed_platform_provider_.get();
109 } 130 }
110 131
111 ConfigurationPolicyProvider* 132 ConfigurationPolicyProvider*
112 BrowserPolicyConnector::GetManagedCloudProvider() const { 133 BrowserPolicyConnector::GetManagedCloudProvider() const {
113 return managed_cloud_provider_.get(); 134 return managed_cloud_provider_.get();
114 } 135 }
115 136
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return std::string(); 216 return std::string();
196 } 217 }
197 218
198 void BrowserPolicyConnector::ResetDevicePolicy() { 219 void BrowserPolicyConnector::ResetDevicePolicy() {
199 #if defined(OS_CHROMEOS) 220 #if defined(OS_CHROMEOS)
200 if (device_cloud_policy_subsystem_.get()) 221 if (device_cloud_policy_subsystem_.get())
201 device_cloud_policy_subsystem_->Reset(); 222 device_cloud_policy_subsystem_->Reset();
202 #endif 223 #endif
203 } 224 }
204 225
205 void BrowserPolicyConnector::FetchDevicePolicy() { 226 void BrowserPolicyConnector::FetchCloudPolicy() {
206 #if defined(OS_CHROMEOS) 227 #if defined(OS_CHROMEOS)
207 if (device_data_store_.get()) { 228 if (device_data_store_.get())
208 device_data_store_->NotifyDeviceTokenChanged(); 229 device_data_store_->NotifyDeviceTokenChanged();
209 } 230 if (user_data_store_.get())
231 user_data_store_->NotifyDeviceTokenChanged();
210 #endif 232 #endif
211 } 233 }
212 234
213 void BrowserPolicyConnector::FetchUserPolicy() { 235 void BrowserPolicyConnector::RefreshPolicies() {
214 #if defined(OS_CHROMEOS) 236 if (managed_platform_provider_.get())
215 if (user_data_store_.get()) { 237 managed_platform_provider_->RefreshPolicies();
216 user_data_store_->NotifyDeviceTokenChanged(); 238 if (recommended_platform_provider_.get())
217 } 239 recommended_platform_provider_->RefreshPolicies();
218 #endif 240 if (managed_cloud_provider_.get())
241 managed_cloud_provider_->RefreshPolicies();
242 if (recommended_cloud_provider_.get())
243 recommended_cloud_provider_->RefreshPolicies();
219 } 244 }
220 245
221 void BrowserPolicyConnector::ScheduleServiceInitialization( 246 void BrowserPolicyConnector::ScheduleServiceInitialization(
222 int64 delay_milliseconds) { 247 int64 delay_milliseconds) {
223 if (user_cloud_policy_subsystem_.get()) { 248 if (user_cloud_policy_subsystem_.get()) {
224 user_cloud_policy_subsystem_-> 249 user_cloud_policy_subsystem_->
225 ScheduleServiceInitialization(delay_milliseconds); 250 ScheduleServiceInitialization(delay_milliseconds);
226 } 251 }
227 #if defined(OS_CHROMEOS) 252 #if defined(OS_CHROMEOS)
228 if (device_cloud_policy_subsystem_.get()) { 253 if (device_cloud_policy_subsystem_.get()) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (pos != std::string::npos && 365 if (pos != std::string::npos &&
341 user_name.substr(pos + 1) == install_attributes_->GetDomain()) { 366 user_name.substr(pos + 1) == install_attributes_->GetDomain()) {
342 return CloudPolicyDataStore::USER_AFFILIATION_MANAGED; 367 return CloudPolicyDataStore::USER_AFFILIATION_MANAGED;
343 } 368 }
344 } 369 }
345 #endif 370 #endif
346 371
347 return CloudPolicyDataStore::USER_AFFILIATION_NONE; 372 return CloudPolicyDataStore::USER_AFFILIATION_NONE;
348 } 373 }
349 374
350 BrowserPolicyConnector::BrowserPolicyConnector()
351 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
352 managed_platform_provider_.reset(CreateManagedPlatformProvider());
353 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider());
354
355 managed_cloud_provider_.reset(new CloudPolicyProviderImpl(
356 GetChromePolicyDefinitionList(),
357 CloudPolicyCacheBase::POLICY_LEVEL_MANDATORY));
358 recommended_cloud_provider_.reset(new CloudPolicyProviderImpl(
359 GetChromePolicyDefinitionList(),
360 CloudPolicyCacheBase::POLICY_LEVEL_RECOMMENDED));
361
362 #if defined(OS_CHROMEOS)
363 InitializeDevicePolicy();
364
365 network_configuration_updater_.reset(
366 new NetworkConfigurationUpdater(
367 managed_cloud_provider_.get(),
368 chromeos::CrosLibrary::Get()->GetNetworkLibrary()));
369 #endif
370 }
371
372 BrowserPolicyConnector::BrowserPolicyConnector(
373 ConfigurationPolicyProvider* managed_platform_provider,
374 ConfigurationPolicyProvider* recommended_platform_provider,
375 CloudPolicyProvider* managed_cloud_provider,
376 CloudPolicyProvider* recommended_cloud_provider)
377 : managed_platform_provider_(managed_platform_provider),
378 recommended_platform_provider_(recommended_platform_provider),
379 managed_cloud_provider_(managed_cloud_provider),
380 recommended_cloud_provider_(recommended_cloud_provider),
381 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
382 }
383
384 void BrowserPolicyConnector::Observe( 375 void BrowserPolicyConnector::Observe(
385 int type, 376 int type,
386 const content::NotificationSource& source, 377 const content::NotificationSource& source,
387 const content::NotificationDetails& details) { 378 const content::NotificationDetails& details) {
388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
389 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) { 380 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) {
390 const TokenService* token_source = 381 const TokenService* token_source =
391 content::Source<const TokenService>(source).ptr(); 382 content::Source<const TokenService>(source).ptr();
392 DCHECK_EQ(token_service_, token_source); 383 DCHECK_EQ(token_service_, token_source);
393 const TokenService::TokenAvailableDetails* token_details = 384 const TokenService::TokenAvailableDetails* token_details =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 #if defined(OS_CHROMEOS) 430 #if defined(OS_CHROMEOS)
440 if (device_cloud_policy_subsystem_.get()) { 431 if (device_cloud_policy_subsystem_.get()) {
441 device_cloud_policy_subsystem_->CompleteInitialization( 432 device_cloud_policy_subsystem_->CompleteInitialization(
442 prefs::kDevicePolicyRefreshRate, 433 prefs::kDevicePolicyRefreshRate,
443 kServiceInitializationStartupDelay); 434 kServiceInitializationStartupDelay);
444 } 435 }
445 #endif 436 #endif
446 } 437 }
447 438
448 // static 439 // static
449 BrowserPolicyConnector* BrowserPolicyConnector::CreateForTests() {
450 return new BrowserPolicyConnector(NULL, NULL, NULL, NULL);
451 }
452
453 // static
454 ConfigurationPolicyProvider* 440 ConfigurationPolicyProvider*
455 BrowserPolicyConnector::CreateManagedPlatformProvider() { 441 BrowserPolicyConnector::CreateManagedPlatformProvider() {
456 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); 442 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList();
457 #if defined(OS_WIN) 443 #if defined(OS_WIN)
458 return new ConfigurationPolicyProviderWin(policy_list); 444 return new ConfigurationPolicyProviderWin(policy_list);
459 #elif defined(OS_MACOSX) 445 #elif defined(OS_MACOSX)
460 return new ConfigurationPolicyProviderMac(policy_list); 446 return new ConfigurationPolicyProviderMac(policy_list);
461 #elif defined(OS_POSIX) 447 #elif defined(OS_POSIX)
462 FilePath config_dir_path; 448 FilePath config_dir_path;
463 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { 449 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) {
(...skipping 20 matching lines...) Expand all
484 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); 470 config_dir_path.Append(FILE_PATH_LITERAL("recommended")));
485 } else { 471 } else {
486 return NULL; 472 return NULL;
487 } 473 }
488 #else 474 #else
489 return NULL; 475 return NULL;
490 #endif 476 #endif
491 } 477 }
492 478
493 } // namespace policy 479 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.h ('k') | chrome/browser/policy/cloud_policy_cache_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698