Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: components/policy/core/common/config_dir_policy_loader.cc

Issue 2414663002: Fix log spew for "_comment..." policies. (Closed)
Patch Set: Rename EraseGeneric() to FilterErase(). Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/config_dir_policy_loader.h" 5 #include "components/policy/core/common/config_dir_policy_loader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/files/file_enumerator.h" 15 #include "base/files/file_enumerator.h"
16 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
17 #include "base/json/json_file_value_serializer.h" 17 #include "base/json/json_file_value_serializer.h"
18 #include "base/json/json_reader.h" 18 #include "base/json/json_reader.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/stl_util.h" 21 #include "base/stl_util.h"
22 #include "components/policy/core/common/policy_bundle.h" 22 #include "components/policy/core/common/policy_bundle.h"
23 #include "components/policy/core/common/policy_load_status.h" 23 #include "components/policy/core/common/policy_load_status.h"
24 #include "components/policy/core/common/policy_types.h" 24 #include "components/policy/core/common/policy_types.h"
25 #include "components/policy/policy_constants.h"
26 25
27 namespace policy { 26 namespace policy {
28 27
29 namespace { 28 namespace {
30 29
31 // Subdirectories that contain the mandatory and recommended policies. 30 // Subdirectories that contain the mandatory and recommended policies.
32 const base::FilePath::CharType kMandatoryConfigDir[] = 31 const base::FilePath::CharType kMandatoryConfigDir[] =
33 FILE_PATH_LITERAL("managed"); 32 FILE_PATH_LITERAL("managed");
34 const base::FilePath::CharType kRecommendedConfigDir[] = 33 const base::FilePath::CharType kRecommendedConfigDir[] =
35 FILE_PATH_LITERAL("recommended"); 34 FILE_PATH_LITERAL("recommended");
(...skipping 16 matching lines...) Expand all
52 case base::JSONReader::JSON_UNQUOTED_DICTIONARY_KEY: 51 case base::JSONReader::JSON_UNQUOTED_DICTIONARY_KEY:
53 return POLICY_LOAD_STATUS_PARSE_ERROR; 52 return POLICY_LOAD_STATUS_PARSE_ERROR;
54 case base::JSONReader::JSON_NO_ERROR: 53 case base::JSONReader::JSON_NO_ERROR:
55 NOTREACHED(); 54 NOTREACHED();
56 return POLICY_LOAD_STATUS_STARTED; 55 return POLICY_LOAD_STATUS_STARTED;
57 } 56 }
58 NOTREACHED() << "Invalid status " << status; 57 NOTREACHED() << "Invalid status " << status;
59 return POLICY_LOAD_STATUS_PARSE_ERROR; 58 return POLICY_LOAD_STATUS_PARSE_ERROR;
60 } 59 }
61 60
62 bool IsUserPolicy(const PolicyMap::const_iterator iter) {
63 const PolicyDetails* policy_details = GetChromePolicyDetails(iter->first);
64 if (!policy_details) {
65 LOG(ERROR) << "Ignoring unknown platform policy: " << iter->first;
66 return false;
67 }
68 if (policy_details->is_device_policy) {
69 // Device Policy is only implemented as Cloud Policy (not Platform Policy).
70 LOG(ERROR) << "Ignoring device platform policy: " << iter->first;
71 return false;
72 }
73 return true;
74 }
75
76 } // namespace 61 } // namespace
77 62
78 ConfigDirPolicyLoader::ConfigDirPolicyLoader( 63 ConfigDirPolicyLoader::ConfigDirPolicyLoader(
79 scoped_refptr<base::SequencedTaskRunner> task_runner, 64 scoped_refptr<base::SequencedTaskRunner> task_runner,
80 const base::FilePath& config_dir, 65 const base::FilePath& config_dir,
81 PolicyScope scope) 66 PolicyScope scope)
82 : AsyncPolicyLoader(task_runner), config_dir_(config_dir), scope_(scope) {} 67 : AsyncPolicyLoader(task_runner), config_dir_(config_dir), scope_(scope) {}
83 68
84 ConfigDirPolicyLoader::~ConfigDirPolicyLoader() {} 69 ConfigDirPolicyLoader::~ConfigDirPolicyLoader() {}
85 70
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 164
180 // Detach the "3rdparty" node. 165 // Detach the "3rdparty" node.
181 std::unique_ptr<base::Value> third_party; 166 std::unique_ptr<base::Value> third_party;
182 if (dictionary_value->Remove("3rdparty", &third_party)) 167 if (dictionary_value->Remove("3rdparty", &third_party))
183 Merge3rdPartyPolicy(third_party.get(), level, bundle); 168 Merge3rdPartyPolicy(third_party.get(), level, bundle);
184 169
185 // Add chrome policy. 170 // Add chrome policy.
186 PolicyMap policy_map; 171 PolicyMap policy_map;
187 policy_map.LoadFrom(dictionary_value, level, scope_, 172 policy_map.LoadFrom(dictionary_value, level, scope_,
188 POLICY_SOURCE_PLATFORM); 173 POLICY_SOURCE_PLATFORM);
189 policy_map.EraseNonmatching(base::Bind(&IsUserPolicy));
190 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 174 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
191 .MergeFrom(policy_map); 175 .MergeFrom(policy_map);
192 } 176 }
193 } 177 }
194 178
195 void ConfigDirPolicyLoader::Merge3rdPartyPolicy( 179 void ConfigDirPolicyLoader::Merge3rdPartyPolicy(
196 const base::Value* policies, 180 const base::Value* policies,
197 PolicyLevel level, 181 PolicyLevel level,
198 PolicyBundle* bundle) { 182 PolicyBundle* bundle) {
199 // The first-level entries in |policies| are PolicyDomains. The second-level 183 // The first-level entries in |policies| are PolicyDomains. The second-level
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 227 }
244 } 228 }
245 229
246 void ConfigDirPolicyLoader::OnFileUpdated(const base::FilePath& path, 230 void ConfigDirPolicyLoader::OnFileUpdated(const base::FilePath& path,
247 bool error) { 231 bool error) {
248 if (!error) 232 if (!error)
249 Reload(false); 233 Reload(false);
250 } 234 }
251 235
252 } // namespace policy 236 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698