| Index: chrome/common/extensions/manifest_handlers/externally_connectable.cc
|
| diff --git a/chrome/common/extensions/manifest_handlers/externally_connectable.cc b/chrome/common/extensions/manifest_handlers/externally_connectable.cc
|
| index 2566b72b1cdd3a6aa8c1d4114e9eb7cef9307386..e4fcb9ae9125b57a560f143576d75ed153a03f6b 100644
|
| --- a/chrome/common/extensions/manifest_handlers/externally_connectable.cc
|
| +++ b/chrome/common/extensions/manifest_handlers/externally_connectable.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include "chrome/common/extensions/manifest_handlers/externally_connectable.h"
|
|
|
| +#include <algorithm>
|
| +
|
| +#include "base/stl_util.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/common/extensions/api/manifest_types.h"
|
| #include "chrome/common/extensions/extension_manifest_constants.h"
|
| @@ -32,7 +35,16 @@ namespace errors = externally_connectable_errors;
|
| using api::manifest_types::ExternallyConnectable;
|
|
|
| namespace {
|
| +
|
| const char kAllIds[] = "*";
|
| +
|
| +template <typename T>
|
| +std::vector<T> Sorted(const std::vector<T>& in) {
|
| + std::vector<T> out = in;
|
| + std::sort(out.begin(), out.end());
|
| + return out;
|
| +}
|
| +
|
| }
|
|
|
| ExternallyConnectableHandler::ExternallyConnectableHandler() {}
|
| @@ -157,6 +169,13 @@ ExternallyConnectableInfo::ExternallyConnectableInfo(
|
| const URLPatternSet& matches,
|
| const std::vector<std::string>& ids,
|
| bool matches_all_ids)
|
| - : matches(matches), ids(ids), matches_all_ids(matches_all_ids) {}
|
| + : matches(matches), ids(Sorted(ids)), matches_all_ids(matches_all_ids) {}
|
| +
|
| +bool ExternallyConnectableInfo::MatchesIdOrAllIds(const std::string& id) {
|
| + if (matches_all_ids)
|
| + return true;
|
| + DCHECK(base::STLIsSorted(ids));
|
| + return std::binary_search(ids.begin(), ids.end(), id);
|
| +}
|
|
|
| } // namespace extensions
|
|
|