Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: components/arc/intent_helper/intent_filter.cc

Issue 2161073004: [arc-intents] Remove SSP matching; add unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/arc/intent_helper/intent_filter.cc
diff --git a/components/arc/intent_helper/intent_filter.cc b/components/arc/intent_helper/intent_filter.cc
index 1a0f79c45de5c93f2c27e2c16b4f3a5ee358290f..ae3ecca024afffaa39531b50f72b82c93831db7c 100644
--- a/components/arc/intent_helper/intent_filter.cc
+++ b/components/arc/intent_helper/intent_filter.cc
@@ -19,10 +19,6 @@ IntentFilter::IntentFilter(const mojom::IntentFilterPtr& mojo_intent_filter) {
mojo_intent_filter->data_paths) {
paths_.emplace_back(pattern);
}
- for (const mojom::PatternMatcherPtr& pattern :
- mojo_intent_filter->data_scheme_specific_parts) {
- scheme_specific_parts_.emplace_back(pattern);
- }
}
IntentFilter::IntentFilter(const IntentFilter& other) = default;
@@ -40,11 +36,7 @@ bool IntentFilter::match(const GURL& url) const {
return false;
}
- if (!scheme_specific_parts_.empty() && hasDataSchemeSpecificPart(url)) {
- return true;
- }
-
- // If there isn't any matching ssp, we need to match an authority.
+ // Match the authority and the path (if any).
if (!authorities_.empty()) {
return matchDataAuthority(url) && (paths_.empty() || hasDataPath(url));
}
@@ -52,21 +44,6 @@ bool IntentFilter::match(const GURL& url) const {
return false;
}
-// Transcribed from android's IntentFilter#hasDataSchemeSpecificPart.
-bool IntentFilter::hasDataSchemeSpecificPart(const GURL& url) const {
- // The scheme-specific-part is the content of the URL minus the ref fragment.
- GURL::Replacements replacements;
- replacements.ClearRef();
- const std::string ssp = url.ReplaceComponents(replacements).GetContent();
-
- for (const PatternMatcher& pattern : scheme_specific_parts_) {
- if (pattern.match(ssp)) {
- return true;
- }
- }
- return false;
-}
-
// Transcribed from android's IntentFilter#hasDataPath.
bool IntentFilter::hasDataPath(const GURL& url) const {
const std::string path = url.path();
@@ -103,8 +80,9 @@ IntentFilter::AuthorityEntry::AuthorityEntry(
// Transcribed from android's IntentFilter.AuthorityEntry#match.
bool IntentFilter::AuthorityEntry::match(const GURL& url) const {
- if (!url.has_host())
+ if (!url.has_host()) {
return false;
+ }
if (port_ >= 0 && port_ != url.IntPort()) {
return false;
@@ -143,7 +121,7 @@ bool IntentFilter::PatternMatcher::match(const std::string& str) const {
// Transcribed from android's PatternMatcher#matchPattern.
bool IntentFilter::PatternMatcher::matchGlob(const std::string& str) const {
-#define GET_CHAR(s, i) (UNLIKELY(i >= s.length())) ? '\0' : s[i]
+#define GET_CHAR(s, i) ((UNLIKELY(i >= s.length())) ? '\0' : s[i])
const size_t NP = pattern_.length();
const size_t NS = str.length();
« no previous file with comments | « components/arc/intent_helper/intent_filter.h ('k') | components/arc/intent_helper/intent_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698