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" |
| 11 #include "components/crx_file/id_util.h" |
11 #include "extensions/common/api/extensions_manifest_types.h" | 12 #include "extensions/common/api/extensions_manifest_types.h" |
12 #include "extensions/common/error_utils.h" | 13 #include "extensions/common/error_utils.h" |
13 #include "extensions/common/manifest_constants.h" | 14 #include "extensions/common/manifest_constants.h" |
14 #include "extensions/common/manifest_handlers/permissions_parser.h" | 15 #include "extensions/common/manifest_handlers/permissions_parser.h" |
15 #include "extensions/common/permissions/api_permission_set.h" | 16 #include "extensions/common/permissions/api_permission_set.h" |
16 #include "extensions/common/url_pattern.h" | 17 #include "extensions/common/url_pattern.h" |
17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 namespace rcd = net::registry_controlled_domains; | 21 namespace rcd = net::registry_controlled_domains; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 std::vector<std::string> ids; | 166 std::vector<std::string> ids; |
166 bool all_ids = false; | 167 bool all_ids = false; |
167 | 168 |
168 if (externally_connectable->ids) { | 169 if (externally_connectable->ids) { |
169 for (std::vector<std::string>::iterator it = | 170 for (std::vector<std::string>::iterator it = |
170 externally_connectable->ids->begin(); | 171 externally_connectable->ids->begin(); |
171 it != externally_connectable->ids->end(); | 172 it != externally_connectable->ids->end(); |
172 ++it) { | 173 ++it) { |
173 if (*it == kAllIds) { | 174 if (*it == kAllIds) { |
174 all_ids = true; | 175 all_ids = true; |
175 } else if (Extension::IdIsValid(*it)) { | 176 } else if (crx_file::id_util::IdIsValid(*it)) { |
176 ids.push_back(*it); | 177 ids.push_back(*it); |
177 } else { | 178 } else { |
178 *error = | 179 *error = |
179 ErrorUtils::FormatErrorMessageUTF16(errors::kErrorInvalidId, *it); | 180 ErrorUtils::FormatErrorMessageUTF16(errors::kErrorInvalidId, *it); |
180 return scoped_ptr<ExternallyConnectableInfo>(); | 181 return scoped_ptr<ExternallyConnectableInfo>(); |
181 } | 182 } |
182 } | 183 } |
183 } | 184 } |
184 | 185 |
185 if (!externally_connectable->matches && !externally_connectable->ids) { | 186 if (!externally_connectable->matches && !externally_connectable->ids) { |
(...skipping 23 matching lines...) Expand all Loading... |
209 } | 210 } |
210 | 211 |
211 bool ExternallyConnectableInfo::IdCanConnect(const std::string& id) { | 212 bool ExternallyConnectableInfo::IdCanConnect(const std::string& id) { |
212 if (all_ids) | 213 if (all_ids) |
213 return true; | 214 return true; |
214 DCHECK(base::STLIsSorted(ids)); | 215 DCHECK(base::STLIsSorted(ids)); |
215 return std::binary_search(ids.begin(), ids.end(), id); | 216 return std::binary_search(ids.begin(), ids.end(), id); |
216 } | 217 } |
217 | 218 |
218 } // namespace extensions | 219 } // namespace extensions |
OLD | NEW |