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

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

Issue 2128913002: Implement chrome-side intent filtering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply CL feedback. 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
« no previous file with comments | « components/arc/common/intent_helper.mojom ('k') | components/arc/intent_helper/intent_filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/intent_helper/intent_filter.h
diff --git a/components/arc/intent_helper/intent_filter.h b/components/arc/intent_helper/intent_filter.h
new file mode 100644
index 0000000000000000000000000000000000000000..71366571dc5489a921b443721fcbc477ea9b0a19
--- /dev/null
+++ b/components/arc/intent_helper/intent_filter.h
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_ARC_INTENT_HELPER_INTENT_FILTER_H_
+#define COMPONENTS_ARC_INTENT_HELPER_INTENT_FILTER_H_
+
+#include <string>
+#include <vector>
+
+#include "components/arc/common/intent_helper.mojom.h"
+
+class GURL;
+
+namespace arc {
+
+// A chrome-side implementation of Android's IntentFilter class. This is used
+// to approximate the intent filtering and determine whether a given URL is
+// likely to be handled by any android-side apps, prior to making expensive IPC
+// calls.
+class IntentFilter {
+ public:
+ explicit IntentFilter(const mojom::IntentFilterPtr& mojo_intent_filter);
+ IntentFilter(const IntentFilter& other);
+ ~IntentFilter();
+
+ bool match(const GURL& url) const;
+
+ private:
+ // A helper class for handling matching of the host part of the URL.
+ class AuthorityEntry {
+ public:
+ explicit AuthorityEntry(const mojom::AuthorityEntryPtr& entry);
+ bool match(const GURL& url) const;
+
+ private:
+ std::string host_;
+ bool wild_;
+ int port_;
+ };
+
+ // A helper class for handling matching of various patterns in the URL.
+ class PatternMatcher {
+ public:
+ explicit PatternMatcher(const mojom::PatternMatcherPtr& pattern);
+ bool match(const std::string& match) const;
+
+ private:
+ bool matchGlob(const std::string& match) const;
+
+ std::string pattern_;
+ mojom::PatternType match_type_;
+ };
+
+ bool matchDataAuthority(const GURL& url) const;
+ bool hasDataPath(const GURL& url) const;
+ bool hasDataSchemeSpecificPart(const GURL& url) const;
+
+ std::vector<AuthorityEntry> authorities_;
+ std::vector<PatternMatcher> paths_;
+ std::vector<PatternMatcher> scheme_specific_parts_;
+};
+
+} // namespace arc
+
+#endif // COMPONENTS_ARC_INTENT_HELPER_INTENT_FILTER_H_
« no previous file with comments | « components/arc/common/intent_helper.mojom ('k') | components/arc/intent_helper/intent_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698