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

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

Issue 2511883003: Use mojo typemaps to simplify arc::IntentFilter::IntentFilter() (Closed)
Patch Set: Created 4 years 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 7dea60f1ed08c7c02ae7dd100d99ce48fc362536..6a20d7b51274776ee625591458c342e2ed86af88 100644
--- a/components/arc/intent_helper/intent_filter.cc
+++ b/components/arc/intent_helper/intent_filter.cc
@@ -6,28 +6,19 @@
#include "base/compiler_specific.h"
#include "base/strings/string_util.h"
+#include "components/arc/common/intent_helper.mojom.h"
#include "url/gurl.h"
namespace arc {
-IntentFilter::IntentFilter(const mojom::IntentFilterPtr& mojo_intent_filter) {
- // TODO(yusukes): Use mojo typemaps to simplify the constructor.
- if (mojo_intent_filter->data_authorities.has_value()) {
- for (const mojom::AuthorityEntryPtr& authorityptr :
- *mojo_intent_filter->data_authorities) {
- authorities_.emplace_back(authorityptr);
- }
- }
- if (mojo_intent_filter->data_paths.has_value()) {
- for (const mojom::PatternMatcherPtr& pattern :
- *mojo_intent_filter->data_paths) {
- paths_.emplace_back(pattern);
- }
- }
-}
-
+IntentFilter::IntentFilter() = default;
IntentFilter::IntentFilter(const IntentFilter& other) = default;
+IntentFilter::IntentFilter(
+ std::vector<IntentFilter::AuthorityEntry> authorities,
+ std::vector<IntentFilter::PatternMatcher> paths)
+ : authorities_(std::move(authorities)), paths_(std::move(paths)) {}
Yusuke Sato 2016/11/30 21:47:15 Please merge https://codereview.chromium.org/25339
djacobo 2016/11/30 23:46:04 The IntentFilter::Match() method by itself should
yoshiki 2016/12/02 19:34:27 Done.
+
IntentFilter::~IntentFilter() = default;
// Logically, this maps to IntentFilter#match, but this code only deals with
@@ -70,9 +61,10 @@ bool IntentFilter::MatchDataAuthority(const GURL& url) const {
return false;
}
-IntentFilter::AuthorityEntry::AuthorityEntry(
- const mojom::AuthorityEntryPtr& entry)
- : host_(entry->host), port_(entry->port) {
+IntentFilter::AuthorityEntry::AuthorityEntry() = default;
+
+IntentFilter::AuthorityEntry::AuthorityEntry(std::string host, int port)
+ : host_(std::move(host)), port_(port) {
// Wildcards are only allowed at the front of the host string.
wild_ = !host_.empty() && host_[0] == '*';
if (wild_) {
@@ -115,9 +107,11 @@ bool IntentFilter::AuthorityEntry::Match(const GURL& url) const {
}
}
-IntentFilter::PatternMatcher::PatternMatcher(
- const mojom::PatternMatcherPtr& pattern)
- : pattern_(pattern->pattern), match_type_(pattern->type) {}
+IntentFilter::PatternMatcher::PatternMatcher() = default;
+
+IntentFilter::PatternMatcher::PatternMatcher(std::string pattern,
+ mojom::PatternType match_type)
+ : pattern_(std::move(pattern)), match_type_(match_type) {}
// Transcribed from android's PatternMatcher#matchPattern.
bool IntentFilter::PatternMatcher::Match(const std::string& str) const {

Powered by Google App Engine
This is Rietveld 408576698