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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_messaging_policy_handler.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 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 "chrome/browser/extensions/api/messaging/native_messaging_policy_handle r.h" 5 #include "chrome/browser/extensions/api/messaging/native_messaging_policy_handle r.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h" 10 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h"
11 #include "chrome/browser/extensions/external_policy_loader.h" 11 #include "chrome/browser/extensions/external_policy_loader.h"
12 #include "components/policy/core/browser/policy_error_map.h" 12 #include "components/policy/core/browser/policy_error_map.h"
13 #include "components/policy/core/common/policy_map.h" 13 #include "components/policy/core/common/policy_map.h"
14 #include "components/policy/policy_constants.h" 14 #include "components/policy/policy_constants.h"
15 #include "components/prefs/pref_value_map.h" 15 #include "components/prefs/pref_value_map.h"
16 #include "components/strings/grit/components_strings.h" 16 #include "components/strings/grit/components_strings.h"
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 NativeMessagingHostListPolicyHandler::NativeMessagingHostListPolicyHandler( 20 NativeMessagingHostListPolicyHandler::NativeMessagingHostListPolicyHandler(
21 const char* policy_name, 21 const char* policy_name,
22 const char* pref_path, 22 const char* pref_path,
23 bool allow_wildcards) 23 bool allow_wildcards)
24 : policy::TypeCheckingPolicyHandler(policy_name, base::Value::TYPE_LIST), 24 : policy::TypeCheckingPolicyHandler(policy_name, base::Value::Type::LIST),
25 pref_path_(pref_path), 25 pref_path_(pref_path),
26 allow_wildcards_(allow_wildcards) {} 26 allow_wildcards_(allow_wildcards) {}
27 27
28 NativeMessagingHostListPolicyHandler::~NativeMessagingHostListPolicyHandler() {} 28 NativeMessagingHostListPolicyHandler::~NativeMessagingHostListPolicyHandler() {}
29 29
30 bool NativeMessagingHostListPolicyHandler::CheckPolicySettings( 30 bool NativeMessagingHostListPolicyHandler::CheckPolicySettings(
31 const policy::PolicyMap& policies, 31 const policy::PolicyMap& policies,
32 policy::PolicyErrorMap* errors) { 32 policy::PolicyErrorMap* errors) {
33 return CheckAndGetList(policies, errors, NULL); 33 return CheckAndGetList(policies, errors, NULL);
34 } 34 }
(...skipping 29 matching lines...) Expand all
64 } 64 }
65 65
66 // Filter the list, rejecting any invalid native messaging host names. 66 // Filter the list, rejecting any invalid native messaging host names.
67 std::unique_ptr<base::ListValue> filtered_list(new base::ListValue()); 67 std::unique_ptr<base::ListValue> filtered_list(new base::ListValue());
68 for (base::ListValue::const_iterator entry(list_value->begin()); 68 for (base::ListValue::const_iterator entry(list_value->begin());
69 entry != list_value->end(); ++entry) { 69 entry != list_value->end(); ++entry) {
70 std::string name; 70 std::string name;
71 if (!(*entry)->GetAsString(&name)) { 71 if (!(*entry)->GetAsString(&name)) {
72 errors->AddError(policy_name(), entry - list_value->begin(), 72 errors->AddError(policy_name(), entry - list_value->begin(),
73 IDS_POLICY_TYPE_ERROR, 73 IDS_POLICY_TYPE_ERROR,
74 base::Value::GetTypeName(base::Value::TYPE_STRING)); 74 base::Value::GetTypeName(base::Value::Type::STRING));
75 continue; 75 continue;
76 } 76 }
77 if (!(allow_wildcards_ && name == "*") && 77 if (!(allow_wildcards_ && name == "*") &&
78 !NativeMessagingHostManifest::IsValidName(name)) { 78 !NativeMessagingHostManifest::IsValidName(name)) {
79 errors->AddError(policy_name(), 79 errors->AddError(policy_name(),
80 entry - list_value->begin(), 80 entry - list_value->begin(),
81 IDS_POLICY_VALUE_FORMAT_ERROR); 81 IDS_POLICY_VALUE_FORMAT_ERROR);
82 continue; 82 continue;
83 } 83 }
84 filtered_list->AppendString(name); 84 filtered_list->AppendString(name);
85 } 85 }
86 86
87 if (names) 87 if (names)
88 *names = std::move(filtered_list); 88 *names = std::move(filtered_list);
89 89
90 return true; 90 return true;
91 } 91 }
92 92
93 } // namespace extensions 93 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698