| OLD | NEW |
| 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 "components/policy/core/browser/browser_policy_connector.h" | 5 #include "components/policy/core/browser/browser_policy_connector.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | |
| 13 #include "base/message_loop/message_loop_proxy.h" | |
| 14 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 15 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
| 16 #include "base/prefs/pref_registry_simple.h" | 14 #include "base/prefs/pref_registry_simple.h" |
| 17 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 19 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 17 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
| 20 #include "components/policy/core/common/cloud/device_management_service.h" | 18 #include "components/policy/core/common/cloud/device_management_service.h" |
| 21 #include "components/policy/core/common/configuration_policy_provider.h" | 19 #include "components/policy/core/common/configuration_policy_provider.h" |
| 22 #include "components/policy/core/common/policy_namespace.h" | 20 #include "components/policy/core/common/policy_namespace.h" |
| 23 #include "components/policy/core/common/policy_pref_names.h" | 21 #include "components/policy/core/common/policy_pref_names.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 scoped_ptr<DeviceManagementService> device_management_service) { | 125 scoped_ptr<DeviceManagementService> device_management_service) { |
| 128 DCHECK(!is_initialized()); | 126 DCHECK(!is_initialized()); |
| 129 | 127 |
| 130 device_management_service_ = device_management_service.Pass(); | 128 device_management_service_ = device_management_service.Pass(); |
| 131 | 129 |
| 132 if (g_testing_provider) | 130 if (g_testing_provider) |
| 133 g_testing_provider->Init(GetSchemaRegistry()); | 131 g_testing_provider->Init(GetSchemaRegistry()); |
| 134 for (size_t i = 0; i < policy_providers_.size(); ++i) | 132 for (size_t i = 0; i < policy_providers_.size(); ++i) |
| 135 policy_providers_[i]->Init(GetSchemaRegistry()); | 133 policy_providers_[i]->Init(GetSchemaRegistry()); |
| 136 | 134 |
| 137 policy_statistics_collector_.reset( | 135 policy_statistics_collector_.reset(new policy::PolicyStatisticsCollector( |
| 138 new policy::PolicyStatisticsCollector( | 136 base::Bind(&GetChromePolicyDetails), GetChromeSchema(), |
| 139 base::Bind(&GetChromePolicyDetails), | 137 GetPolicyService(), local_state, |
| 140 GetChromeSchema(), | 138 base::MessageLoop::current()->task_runner())); |
| 141 GetPolicyService(), | |
| 142 local_state, | |
| 143 base::MessageLoop::current()->message_loop_proxy())); | |
| 144 policy_statistics_collector_->Initialize(); | 139 policy_statistics_collector_->Initialize(); |
| 145 | 140 |
| 146 is_initialized_ = true; | 141 is_initialized_ = true; |
| 147 } | 142 } |
| 148 | 143 |
| 149 void BrowserPolicyConnector::Shutdown() { | 144 void BrowserPolicyConnector::Shutdown() { |
| 150 is_initialized_ = false; | 145 is_initialized_ = false; |
| 151 if (g_testing_provider) | 146 if (g_testing_provider) |
| 152 g_testing_provider->Shutdown(); | 147 g_testing_provider->Shutdown(); |
| 153 for (size_t i = 0; i < policy_providers_.size(); ++i) | 148 for (size_t i = 0; i < policy_providers_.size(); ++i) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 249 } |
| 255 | 250 |
| 256 void BrowserPolicyConnector::SetPlatformPolicyProvider( | 251 void BrowserPolicyConnector::SetPlatformPolicyProvider( |
| 257 scoped_ptr<ConfigurationPolicyProvider> provider) { | 252 scoped_ptr<ConfigurationPolicyProvider> provider) { |
| 258 CHECK(!platform_policy_provider_); | 253 CHECK(!platform_policy_provider_); |
| 259 platform_policy_provider_ = provider.get(); | 254 platform_policy_provider_ = provider.get(); |
| 260 AddPolicyProvider(provider.Pass()); | 255 AddPolicyProvider(provider.Pass()); |
| 261 } | 256 } |
| 262 | 257 |
| 263 } // namespace policy | 258 } // namespace policy |
| OLD | NEW |