| 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 "extensions/common/manifest_handlers/externally_connectable.h" | 5 #include "extensions/common/manifest_handlers/externally_connectable.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 "nothing will be able to connect"; | 30 "nothing will be able to connect"; |
| 31 const char kErrorTopLevelDomainsNotAllowed[] = | 31 const char kErrorTopLevelDomainsNotAllowed[] = |
| 32 "\"*\" is an effective top level domain for which wildcard subdomains such " | 32 "\"*\" is an effective top level domain for which wildcard subdomains such " |
| 33 "as \"*\" are not allowed"; | 33 "as \"*\" are not allowed"; |
| 34 const char kErrorWildcardHostsNotAllowed[] = | 34 const char kErrorWildcardHostsNotAllowed[] = |
| 35 "Wildcard domain patterns such as \"*\" are not allowed"; | 35 "Wildcard domain patterns such as \"*\" are not allowed"; |
| 36 } // namespace externally_connectable_errors | 36 } // namespace externally_connectable_errors |
| 37 | 37 |
| 38 namespace keys = extensions::manifest_keys; | 38 namespace keys = extensions::manifest_keys; |
| 39 namespace errors = externally_connectable_errors; | 39 namespace errors = externally_connectable_errors; |
| 40 using core_api::extensions_manifest_types::ExternallyConnectable; | 40 using api::extensions_manifest_types::ExternallyConnectable; |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 const char kAllIds[] = "*"; | 44 const char kAllIds[] = "*"; |
| 45 | 45 |
| 46 template <typename T> | 46 template <typename T> |
| 47 std::vector<T> Sorted(const std::vector<T>& in) { | 47 std::vector<T> Sorted(const std::vector<T>& in) { |
| 48 std::vector<T> out = in; | 48 std::vector<T> out = in; |
| 49 std::sort(out.begin(), out.end()); | 49 std::sort(out.begin(), out.end()); |
| 50 return out; | 50 return out; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool ExternallyConnectableInfo::IdCanConnect(const std::string& id) { | 220 bool ExternallyConnectableInfo::IdCanConnect(const std::string& id) { |
| 221 if (all_ids) | 221 if (all_ids) |
| 222 return true; | 222 return true; |
| 223 DCHECK(base::STLIsSorted(ids)); | 223 DCHECK(base::STLIsSorted(ids)); |
| 224 return std::binary_search(ids.begin(), ids.end(), id); | 224 return std::binary_search(ids.begin(), ids.end(), id); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // namespace extensions | 227 } // namespace extensions |
| OLD | NEW |