Chromium Code Reviews| 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..2843e326729bf8de2f5896d61c03ea5a09781af8 |
| --- /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 |
|
Yusuke Sato
2016/07/11 04:38:32
..._FILTER_H_
Ben Kwa
2016/07/11 21:22:58
Done.
|
| +#define COMPONENTS_ARC_INTENT_HELPER_INTENT_FILTER_H |
|
Yusuke Sato
2016/07/11 04:38:32
same. the trailing underscore missing.
Ben Kwa
2016/07/11 21:22:58
Done.
|
| + |
| +#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: |
| + IntentFilter(const mojom::IntentFilterPtr& mojo_intent_filter); |
|
Yusuke Sato
2016/07/11 04:38:32
explicit
Ben Kwa
2016/07/11 21:22:58
Done.
|
| + 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: |
| + AuthorityEntry(const mojom::AuthorityEntryPtr& entry); |
|
Yusuke Sato
2016/07/11 04:38:32
explicit
Ben Kwa
2016/07/11 21:22:58
Done.
|
| + 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: |
| + PatternMatcher(const mojom::PatternMatcherPtr& pattern); |
|
Yusuke Sato
2016/07/11 04:38:32
explicit
Ben Kwa
2016/07/11 21:22:58
Done.
|
| + 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 |
|
Yusuke Sato
2016/07/11 04:38:32
#endif // COMPONENTS_ARC_INTENT_HELPER_INTENT_FIL
Ben Kwa
2016/07/11 21:22:58
Done.
|