| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // BrowserProcessImpl::StartTearDown() wasn't invoked. | 108 // BrowserProcessImpl::StartTearDown() wasn't invoked. |
| 109 // Cleanup properly in those cases and avoid crashing the ToastCrasher test. | 109 // Cleanup properly in those cases and avoid crashing the ToastCrasher test. |
| 110 Shutdown(); | 110 Shutdown(); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void BrowserPolicyConnector::Init() { | 114 void BrowserPolicyConnector::Init() { |
| 115 DCHECK(!is_initialized()) << "BrowserPolicyConnector::Init() called twice."; | 115 DCHECK(!is_initialized()) << "BrowserPolicyConnector::Init() called twice."; |
| 116 platform_provider_.reset(CreatePlatformProvider()); | 116 platform_provider_.reset(CreatePlatformProvider()); |
| 117 | 117 |
| 118 device_management_service_.reset( | 118 if (!device_management_service_.get()) { |
| 119 new DeviceManagementService(GetDeviceManagementUrl())); | 119 device_management_service_.reset( |
| 120 new DeviceManagementService(GetDeviceManagementUrl())); |
| 121 } |
| 120 | 122 |
| 121 #if defined(OS_CHROMEOS) | 123 #if defined(OS_CHROMEOS) |
| 122 chromeos::CryptohomeLibrary* cryptohome = | 124 chromeos::CryptohomeLibrary* cryptohome = |
| 123 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); | 125 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); |
| 124 install_attributes_.reset(new EnterpriseInstallAttributes(cryptohome)); | 126 install_attributes_.reset(new EnterpriseInstallAttributes(cryptohome)); |
| 125 | 127 |
| 126 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 128 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 127 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { | 129 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { |
| 128 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_cloud_policy_store( | 130 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_cloud_policy_store( |
| 129 new DeviceCloudPolicyStoreChromeOS( | 131 new DeviceCloudPolicyStoreChromeOS( |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 network_configuration_updater_.reset(new NetworkConfigurationUpdater( | 507 network_configuration_updater_.reset(new NetworkConfigurationUpdater( |
| 506 g_browser_process->policy_service(), | 508 g_browser_process->policy_service(), |
| 507 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); | 509 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); |
| 508 } | 510 } |
| 509 return network_configuration_updater_.get(); | 511 return network_configuration_updater_.get(); |
| 510 #else | 512 #else |
| 511 return NULL; | 513 return NULL; |
| 512 #endif | 514 #endif |
| 513 } | 515 } |
| 514 | 516 |
| 517 void BrowserPolicyConnector::SetDeviceManagementServiceForTest( |
| 518 scoped_ptr<DeviceManagementService> service) { |
| 519 device_management_service_ = service.Pass(); |
| 520 } |
| 521 |
| 515 // static | 522 // static |
| 516 void BrowserPolicyConnector::SetPolicyProviderForTesting( | 523 void BrowserPolicyConnector::SetPolicyProviderForTesting( |
| 517 ConfigurationPolicyProvider* provider) { | 524 ConfigurationPolicyProvider* provider) { |
| 518 CHECK(!g_browser_process) << "Must be invoked before the browser is created"; | 525 CHECK(!g_browser_process) << "Must be invoked before the browser is created"; |
| 519 DCHECK(!g_testing_provider); | 526 DCHECK(!g_testing_provider); |
| 520 g_testing_provider = provider; | 527 g_testing_provider = provider; |
| 521 } | 528 } |
| 522 | 529 |
| 523 // static | 530 // static |
| 524 std::string BrowserPolicyConnector::GetDeviceManagementUrl() { | 531 std::string BrowserPolicyConnector::GetDeviceManagementUrl() { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 return new AsyncPolicyProvider(loader.Pass()); | 720 return new AsyncPolicyProvider(loader.Pass()); |
| 714 } else { | 721 } else { |
| 715 return NULL; | 722 return NULL; |
| 716 } | 723 } |
| 717 #else | 724 #else |
| 718 return NULL; | 725 return NULL; |
| 719 #endif | 726 #endif |
| 720 } | 727 } |
| 721 | 728 |
| 722 } // namespace policy | 729 } // namespace policy |
| OLD | NEW |