Chromium Code Reviews| 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 "components/policy/core/common/cloud/cloud_policy_manager.h" | 5 #include "components/policy/core/common/cloud/cloud_policy_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "components/policy/core/common/cloud/cloud_policy_service.h" | 15 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
| 16 #include "components/policy/core/common/policy_bundle.h" | 16 #include "components/policy/core/common/policy_bundle.h" |
| 17 #include "components/policy/core/common/policy_map.h" | 17 #include "components/policy/core/common/policy_map.h" |
| 18 #include "components/policy/core/common/policy_switches.h" | 18 #include "components/policy/core/common/policy_switches.h" |
| 19 #include "components/policy/policy_constants.h" | |
| 19 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 21 | 22 |
| 22 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 23 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 23 #include "components/policy/core/common/cloud/resource_cache.h" | 24 #include "components/policy/core/common/cloud/resource_cache.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 namespace policy { | 27 namespace policy { |
| 27 | 28 |
| 28 CloudPolicyManager::CloudPolicyManager( | 29 CloudPolicyManager::CloudPolicyManager( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 GetChromePolicy( | 101 GetChromePolicy( |
| 101 &bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))); | 102 &bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))); |
| 102 if (component_policy_service_) | 103 if (component_policy_service_) |
| 103 bundle->MergeFrom(component_policy_service_->policy()); | 104 bundle->MergeFrom(component_policy_service_->policy()); |
| 104 UpdatePolicy(std::move(bundle)); | 105 UpdatePolicy(std::move(bundle)); |
| 105 } | 106 } |
| 106 } | 107 } |
| 107 | 108 |
| 108 void CloudPolicyManager::GetChromePolicy(PolicyMap* policy_map) { | 109 void CloudPolicyManager::GetChromePolicy(PolicyMap* policy_map) { |
| 109 policy_map->CopyFrom(store()->policy_map()); | 110 policy_map->CopyFrom(store()->policy_map()); |
| 111 | |
| 112 // If the store has a verified policy blob received from the server then apply | |
| 113 // the defaults for policies that haven't been configured by the administrator | |
| 114 // given that this is an enterprise user. | |
| 115 if (store()->has_policy()) | |
| 116 SetEnterpriseUsersDefaults(policy_map); | |
|
Marc Treib
2016/08/25 15:52:07
This doesn't quite match the "spec" in the bug: I'
Andrew T Wilson (Slow)
2016/08/26 07:56:50
I'm a bit concerned about this because it will now
Marc Treib
2016/08/26 09:19:19
Yup, this code duplication is what I was trying to
| |
| 110 } | 117 } |
| 111 | 118 |
| 112 void CloudPolicyManager::CreateComponentCloudPolicyService( | 119 void CloudPolicyManager::CreateComponentCloudPolicyService( |
| 113 const base::FilePath& policy_cache_path, | 120 const base::FilePath& policy_cache_path, |
| 114 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 121 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 115 CloudPolicyClient* client) { | 122 CloudPolicyClient* client) { |
| 116 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 123 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 117 // Init() must have been called. | 124 // Init() must have been called. |
| 118 CHECK(schema_registry()); | 125 CHECK(schema_registry()); |
| 119 // Called at most once. | 126 // Called at most once. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 147 } | 154 } |
| 148 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 155 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 149 } | 156 } |
| 150 | 157 |
| 151 void CloudPolicyManager::OnRefreshComplete(bool success) { | 158 void CloudPolicyManager::OnRefreshComplete(bool success) { |
| 152 waiting_for_policy_refresh_ = false; | 159 waiting_for_policy_refresh_ = false; |
| 153 CheckAndPublishPolicy(); | 160 CheckAndPublishPolicy(); |
| 154 } | 161 } |
| 155 | 162 |
| 156 } // namespace policy | 163 } // namespace policy |
| OLD | NEW |