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 "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" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 NOTREACHED(); | 62 NOTREACHED(); |
63 return false; | 63 return false; |
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(), | 72 errors->AddError(policy_name(), entry - list_value->begin(), |
73 entry - list_value->begin(), | |
74 IDS_POLICY_TYPE_ERROR, | 73 IDS_POLICY_TYPE_ERROR, |
75 ValueTypeToString(base::Value::TYPE_STRING)); | 74 base::Value::GetTypeName(base::Value::TYPE_STRING)); |
76 continue; | 75 continue; |
77 } | 76 } |
78 if (!(allow_wildcards_ && name == "*") && | 77 if (!(allow_wildcards_ && name == "*") && |
79 !NativeMessagingHostManifest::IsValidName(name)) { | 78 !NativeMessagingHostManifest::IsValidName(name)) { |
80 errors->AddError(policy_name(), | 79 errors->AddError(policy_name(), |
81 entry - list_value->begin(), | 80 entry - list_value->begin(), |
82 IDS_POLICY_VALUE_FORMAT_ERROR); | 81 IDS_POLICY_VALUE_FORMAT_ERROR); |
83 continue; | 82 continue; |
84 } | 83 } |
85 filtered_list->AppendString(name); | 84 filtered_list->AppendString(name); |
86 } | 85 } |
87 | 86 |
88 if (names) | 87 if (names) |
89 *names = std::move(filtered_list); | 88 *names = std::move(filtered_list); |
90 | 89 |
91 return true; | 90 return true; |
92 } | 91 } |
93 | 92 |
94 } // namespace extensions | 93 } // namespace extensions |
OLD | NEW |