OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 global_user_cloud_policy_provider_.Shutdown(); | 380 global_user_cloud_policy_provider_.Shutdown(); |
381 #endif | 381 #endif |
382 | 382 |
383 device_management_service_.reset(); | 383 device_management_service_.reset(); |
384 | 384 |
385 request_context_ = NULL; | 385 request_context_ = NULL; |
386 } | 386 } |
387 | 387 |
388 PolicyService* BrowserPolicyConnector::GetPolicyService() { | 388 PolicyService* BrowserPolicyConnector::GetPolicyService() { |
389 if (!policy_service_) { | 389 if (!policy_service_) { |
| 390 // |providers| in decreasing order of priority. |
390 std::vector<ConfigurationPolicyProvider*> providers; | 391 std::vector<ConfigurationPolicyProvider*> providers; |
| 392 if (g_testing_provider) { |
| 393 providers.push_back(g_testing_provider); |
| 394 } else { |
| 395 if (platform_provider_) |
| 396 providers.push_back(platform_provider_.get()); |
391 #if defined(OS_CHROMEOS) | 397 #if defined(OS_CHROMEOS) |
392 providers.push_back(&global_user_cloud_policy_provider_); | 398 if (device_cloud_policy_manager_) |
| 399 providers.push_back(device_cloud_policy_manager_.get()); |
| 400 providers.push_back(&global_user_cloud_policy_provider_); |
393 #endif | 401 #endif |
394 policy_service_ = CreatePolicyService(providers); | 402 } |
| 403 policy_service_.reset(new PolicyServiceImpl(providers)); |
395 } | 404 } |
396 return policy_service_.get(); | 405 return policy_service_.get(); |
397 } | 406 } |
398 | 407 |
399 const Schema& BrowserPolicyConnector::GetChromeSchema() const { | 408 const Schema& BrowserPolicyConnector::GetChromeSchema() const { |
400 return chrome_schema_; | 409 return chrome_schema_; |
401 } | 410 } |
402 | 411 |
403 CombinedSchemaRegistry* BrowserPolicyConnector::GetSchemaRegistry() { | 412 CombinedSchemaRegistry* BrowserPolicyConnector::GetSchemaRegistry() { |
404 return &schema_registry_; | 413 return &schema_registry_; |
405 } | 414 } |
406 | 415 |
| 416 ConfigurationPolicyProvider* BrowserPolicyConnector::GetPlatformProvider() { |
| 417 if (g_testing_provider) |
| 418 return g_testing_provider; |
| 419 return platform_provider_.get(); |
| 420 } |
| 421 |
407 #if defined(OS_CHROMEOS) | 422 #if defined(OS_CHROMEOS) |
408 bool BrowserPolicyConnector::IsEnterpriseManaged() { | 423 bool BrowserPolicyConnector::IsEnterpriseManaged() { |
409 return install_attributes_ && install_attributes_->IsEnterpriseDevice(); | 424 return install_attributes_ && install_attributes_->IsEnterpriseDevice(); |
410 } | 425 } |
411 | 426 |
412 std::string BrowserPolicyConnector::GetEnterpriseDomain() { | 427 std::string BrowserPolicyConnector::GetEnterpriseDomain() { |
413 return install_attributes_ ? install_attributes_->GetDomain() : std::string(); | 428 return install_attributes_ ? install_attributes_->GetDomain() : std::string(); |
414 } | 429 } |
415 | 430 |
416 DeviceMode BrowserPolicyConnector::GetDeviceMode() { | 431 DeviceMode BrowserPolicyConnector::GetDeviceMode() { |
417 return install_attributes_ ? install_attributes_->GetMode() | 432 return install_attributes_ ? install_attributes_->GetMode() |
418 : DEVICE_MODE_NOT_SET; | 433 : DEVICE_MODE_NOT_SET; |
419 } | 434 } |
420 #endif | 435 #endif |
421 | 436 |
422 void BrowserPolicyConnector::ScheduleServiceInitialization( | 437 void BrowserPolicyConnector::ScheduleServiceInitialization( |
423 int64 delay_milliseconds) { | 438 int64 delay_milliseconds) { |
424 // Skip device initialization if the BrowserPolicyConnector was never | 439 // Skip device initialization if the BrowserPolicyConnector was never |
425 // initialized (unit tests). | 440 // initialized (unit tests). |
426 if (device_management_service_) | 441 if (device_management_service_) |
427 device_management_service_->ScheduleInitialization(delay_milliseconds); | 442 device_management_service_->ScheduleInitialization(delay_milliseconds); |
428 } | 443 } |
429 | 444 |
430 scoped_ptr<PolicyService> BrowserPolicyConnector::CreatePolicyService( | |
431 const std::vector<ConfigurationPolicyProvider*>& additional_providers) { | |
432 std::vector<ConfigurationPolicyProvider*> providers; | |
433 if (g_testing_provider) { | |
434 providers.push_back(g_testing_provider); | |
435 } else { | |
436 // |providers| in decreasing order of priority. | |
437 if (platform_provider_) | |
438 providers.push_back(platform_provider_.get()); | |
439 #if defined(OS_CHROMEOS) | |
440 if (device_cloud_policy_manager_) | |
441 providers.push_back(device_cloud_policy_manager_.get()); | |
442 #endif | |
443 std::copy(additional_providers.begin(), additional_providers.end(), | |
444 std::back_inserter(providers)); | |
445 } | |
446 return scoped_ptr<PolicyService>(new PolicyServiceImpl(providers)); | |
447 } | |
448 | |
449 const ConfigurationPolicyHandlerList* | 445 const ConfigurationPolicyHandlerList* |
450 BrowserPolicyConnector::GetHandlerList() const { | 446 BrowserPolicyConnector::GetHandlerList() const { |
451 return handler_list_.get(); | 447 return handler_list_.get(); |
452 } | 448 } |
453 | 449 |
454 UserAffiliation BrowserPolicyConnector::GetUserAffiliation( | 450 UserAffiliation BrowserPolicyConnector::GetUserAffiliation( |
455 const std::string& user_name) { | 451 const std::string& user_name) { |
456 #if defined(OS_CHROMEOS) | 452 #if defined(OS_CHROMEOS) |
457 // An empty username means incognito user in case of ChromiumOS and | 453 // An empty username means incognito user in case of ChromiumOS and |
458 // no logged-in user in case of Chromium (SigninService). Many tests use | 454 // no logged-in user in case of Chromium (SigninService). Many tests use |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); | 603 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
608 } else { | 604 } else { |
609 return NULL; | 605 return NULL; |
610 } | 606 } |
611 #else | 607 #else |
612 return NULL; | 608 return NULL; |
613 #endif | 609 #endif |
614 } | 610 } |
615 | 611 |
616 } // namespace policy | 612 } // namespace policy |
OLD | NEW |