Chromium Code Reviews| 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 de104aeccb3a48dca94cc78be020d330f4fb0199..93a8d694d8f0403718f23108b90442a2c9d1f550 100644 |
| --- a/components/arc/intent_helper/intent_filter.cc |
| +++ b/components/arc/intent_helper/intent_filter.cc |
| @@ -6,28 +6,22 @@ |
| #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); |
| - } |
| - } |
| - // In order to register a path we need to have at least one authority. |
| - if (!authorities_.empty() && 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(IntentFilter&& other) = default; |
| +// IntentFilter& IntentFilter::operator=(IntentFilter&& other) = default; |
|
Yusuke Sato
2016/12/02 20:10:34
remove
yoshiki
2016/12/06 07:07:38
Done.
|
| -IntentFilter::IntentFilter(const IntentFilter& other) = default; |
| +IntentFilter::IntentFilter( |
| + std::vector<IntentFilter::AuthorityEntry> authorities, |
| + std::vector<IntentFilter::PatternMatcher> paths) |
| + : authorities_(std::move(authorities)) { |
| + if (!authorities_.empty()) |
|
Yusuke Sato
2016/12/02 20:10:34
Please copy the comment at L21 on the left.
// I
yoshiki
2016/12/06 07:07:38
Done.
|
| + paths_ = std::move(paths); |
| +} |
| IntentFilter::~IntentFilter() = default; |
| @@ -73,9 +67,12 @@ bool IntentFilter::MatchDataAuthority(const GURL& url) const { |
| return false; |
| } |
| +IntentFilter::AuthorityEntry::AuthorityEntry() = default; |
| IntentFilter::AuthorityEntry::AuthorityEntry( |
| - const mojom::AuthorityEntryPtr& entry) |
| - : host_(entry->host), port_(entry->port) { |
| + IntentFilter::AuthorityEntry&& other) = default; |
| + |
| +IntentFilter::AuthorityEntry::AuthorityEntry(std::string host, int port) |
| + : host_(std::move(host)), port_(port) { |
|
Yusuke Sato
2016/12/03 02:05:22
remove std::move()
yoshiki
2016/12/06 07:07:38
Done.
|
| // Wildcards are only allowed at the front of the host string. |
| wild_ = !host_.empty() && host_[0] == '*'; |
| if (wild_) { |
| @@ -118,9 +115,13 @@ bool IntentFilter::AuthorityEntry::Match(const GURL& url) const { |
| } |
| } |
| +IntentFilter::PatternMatcher::PatternMatcher() = default; |
| IntentFilter::PatternMatcher::PatternMatcher( |
| - const mojom::PatternMatcherPtr& pattern) |
| - : pattern_(pattern->pattern), match_type_(pattern->type) {} |
| + IntentFilter::PatternMatcher&& other) = default; |
| + |
| +IntentFilter::PatternMatcher::PatternMatcher(std::string pattern, |
| + mojom::PatternType match_type) |
| + : pattern_(std::move(pattern)), match_type_(match_type) {} |
|
Yusuke Sato
2016/12/03 02:05:22
same
yoshiki
2016/12/06 07:07:38
Done.
|
| // Transcribed from android's PatternMatcher#matchPattern. |
| bool IntentFilter::PatternMatcher::Match(const std::string& str) const { |