Commit 5e7a337c authored by Maggie Cai's avatar Maggie Cai Committed by Commit Bot

Parse data_scheme for ARC intent filter.

Currently the data_scheme entry is not parsed for the ARC intent filter.
Parse it to get the scheme data from ARC. The reason for doing this is
to allow the Chrome has all the scheme and url information so that we
can handle the intent query in Chrome instead of sending them to ARC.

This CL doesn't update the Match algorithm for the filters. Modifying
the Match algorithm and the corresponding unit test in a follow up CL.

BUG=853604

Change-Id: I93af12d0db4f48abd3017dbfb4a9e36a0214b7d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1818002
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Reviewed-by: default avatarDavid Jacobo <djacobo@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699604}
parent f6caa6b4
......@@ -24,7 +24,8 @@ IntentFilter GetIntentFilter(const std::string& host,
std::vector<IntentFilter::AuthorityEntry> authorities;
authorities.emplace_back(host, /*port=*/-1);
return IntentFilter(pkg_name, std::move(authorities),
std::vector<IntentFilter::PatternMatcher>());
std::vector<IntentFilter::PatternMatcher>(),
std::vector<std::string>());
}
} // namespace
......
......@@ -19,8 +19,11 @@ IntentFilter::IntentFilter(IntentFilter&& other) = default;
IntentFilter::IntentFilter(
const std::string& package_name,
std::vector<IntentFilter::AuthorityEntry> authorities,
std::vector<IntentFilter::PatternMatcher> paths)
: package_name_(package_name), authorities_(std::move(authorities)) {
std::vector<IntentFilter::PatternMatcher> paths,
std::vector<std::string> schemes)
: package_name_(package_name),
authorities_(std::move(authorities)),
schemes_(std::move(schemes)) {
// In order to register a path we need to have at least one authority.
if (!authorities_.empty())
paths_ = std::move(paths);
......
......@@ -73,7 +73,8 @@ class IntentFilter {
IntentFilter(IntentFilter&& other);
IntentFilter(const std::string& package_name,
std::vector<AuthorityEntry> authorities,
std::vector<PatternMatcher> paths);
std::vector<PatternMatcher> paths,
std::vector<std::string> schemes);
~IntentFilter();
IntentFilter& operator=(IntentFilter&& other);
......@@ -85,6 +86,7 @@ class IntentFilter {
return authorities_;
}
const std::vector<PatternMatcher>& paths() const { return paths_; }
const std::vector<std::string>& schemes() const { return schemes_; }
private:
bool MatchDataAuthority(const GURL& url) const;
......@@ -93,6 +95,7 @@ class IntentFilter {
std::string package_name_;
std::vector<AuthorityEntry> authorities_;
std::vector<PatternMatcher> paths_;
std::vector<std::string> schemes_;
DISALLOW_COPY_AND_ASSIGN(IntentFilter);
};
......
......@@ -27,8 +27,12 @@ bool StructTraits<arc::mojom::IntentFilterDataView, arc::IntentFilter>::Read(
if (!data.ReadPackageName(&package_name))
return false;
*out =
arc::IntentFilter(package_name, std::move(authorities), std::move(paths));
std::vector<std::string> schemes;
if (!data.ReadDataSchemes(&schemes))
return false;
*out = arc::IntentFilter(package_name, std::move(authorities),
std::move(paths), std::move(schemes));
return true;
}
......
......@@ -24,10 +24,9 @@ struct StructTraits<arc::mojom::IntentFilterDataView, arc::IntentFilter> {
// Returns an empty array.
return base::span<std::string>();
}
static const base::span<std::string> data_schemes(
static const std::vector<std::string>& data_schemes(
const arc::IntentFilter& r) {
// Returns an empty array.
return base::span<std::string>();
return r.schemes();
}
static const std::vector<arc::IntentFilter::AuthorityEntry>& data_authorities(
const arc::IntentFilter& r) {
......
......@@ -41,7 +41,7 @@ class IntentFilterBuilder {
operator IntentFilter() {
return IntentFilter(kPackageName, std::move(authorities_),
std::move(paths_));
std::move(paths_), std::vector<std::string>());
}
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment