| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // BrowserProcessImpl::StartTearDown() wasn't invoked. | 109 // BrowserProcessImpl::StartTearDown() wasn't invoked. |
| 110 // Cleanup properly in those cases and avoid crashing the ToastCrasher test. | 110 // Cleanup properly in those cases and avoid crashing the ToastCrasher test. |
| 111 Shutdown(); | 111 Shutdown(); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 void BrowserPolicyConnector::Init() { | 115 void BrowserPolicyConnector::Init() { |
| 116 DCHECK(!is_initialized()) << "BrowserPolicyConnector::Init() called twice."; | 116 DCHECK(!is_initialized()) << "BrowserPolicyConnector::Init() called twice."; |
| 117 platform_provider_.reset(CreatePlatformProvider()); | 117 platform_provider_.reset(CreatePlatformProvider()); |
| 118 | 118 |
| 119 device_management_service_.reset( | 119 if (!device_management_service_.get()) { |
| 120 new DeviceManagementService(GetDeviceManagementUrl())); | 120 device_management_service_.reset( |
| 121 new DeviceManagementService(GetDeviceManagementUrl())); |
| 122 } |
| 121 | 123 |
| 122 #if defined(OS_CHROMEOS) | 124 #if defined(OS_CHROMEOS) |
| 123 chromeos::CryptohomeLibrary* cryptohome = | 125 chromeos::CryptohomeLibrary* cryptohome = |
| 124 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); | 126 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); |
| 125 install_attributes_.reset(new EnterpriseInstallAttributes(cryptohome)); | 127 install_attributes_.reset(new EnterpriseInstallAttributes(cryptohome)); |
| 126 | 128 |
| 127 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 129 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 128 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { | 130 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { |
| 129 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_cloud_policy_store( | 131 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_cloud_policy_store( |
| 130 new DeviceCloudPolicyStoreChromeOS( | 132 new DeviceCloudPolicyStoreChromeOS( |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 network_configuration_updater_.reset(new NetworkConfigurationUpdater( | 508 network_configuration_updater_.reset(new NetworkConfigurationUpdater( |
| 507 g_browser_process->policy_service(), | 509 g_browser_process->policy_service(), |
| 508 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); | 510 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); |
| 509 } | 511 } |
| 510 return network_configuration_updater_.get(); | 512 return network_configuration_updater_.get(); |
| 511 #else | 513 #else |
| 512 return NULL; | 514 return NULL; |
| 513 #endif | 515 #endif |
| 514 } | 516 } |
| 515 | 517 |
| 518 void BrowserPolicyConnector::SetDeviceManagementServiceForTesting( |
| 519 scoped_ptr<DeviceManagementService> service) { |
| 520 device_management_service_ = service.Pass(); |
| 521 } |
| 522 |
| 516 // static | 523 // static |
| 517 void BrowserPolicyConnector::SetPolicyProviderForTesting( | 524 void BrowserPolicyConnector::SetPolicyProviderForTesting( |
| 518 ConfigurationPolicyProvider* provider) { | 525 ConfigurationPolicyProvider* provider) { |
| 519 CHECK(!g_browser_process) << "Must be invoked before the browser is created"; | 526 CHECK(!g_browser_process) << "Must be invoked before the browser is created"; |
| 520 DCHECK(!g_testing_provider); | 527 DCHECK(!g_testing_provider); |
| 521 g_testing_provider = provider; | 528 g_testing_provider = provider; |
| 522 } | 529 } |
| 523 | 530 |
| 524 // static | 531 // static |
| 525 std::string BrowserPolicyConnector::GetDeviceManagementUrl() { | 532 std::string BrowserPolicyConnector::GetDeviceManagementUrl() { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 return new AsyncPolicyProvider(loader.Pass()); | 742 return new AsyncPolicyProvider(loader.Pass()); |
| 736 } else { | 743 } else { |
| 737 return NULL; | 744 return NULL; |
| 738 } | 745 } |
| 739 #else | 746 #else |
| 740 return NULL; | 747 return NULL; |
| 741 #endif | 748 #endif |
| 742 } | 749 } |
| 743 | 750 |
| 744 } // namespace policy | 751 } // namespace policy |
| OLD | NEW |