Chromium Code Reviews| Index: components/arc/intent_helper/local_activity_resolver.cc |
| diff --git a/components/arc/intent_helper/local_activity_resolver.cc b/components/arc/intent_helper/local_activity_resolver.cc |
| index 568cd8829435d14068bb497ac75da576645f16bf..29dbe4fef23620cd6ac56487f18ca22fa706b31e 100644 |
| --- a/components/arc/intent_helper/local_activity_resolver.cc |
| +++ b/components/arc/intent_helper/local_activity_resolver.cc |
| @@ -8,9 +8,72 @@ |
| namespace arc { |
| +LocalActivityResolver::LocalActivityResolver() {} |
|
Yusuke Sato
2016/06/22 19:45:51
= default;
zentaro
2016/06/22 20:16:14
I had it in the .h but then it complained about in
|
| + |
| +LocalActivityResolver::~LocalActivityResolver() {} |
|
Yusuke Sato
2016/06/22 19:45:52
same
zentaro
2016/06/22 20:16:14
Done.
|
| + |
| bool LocalActivityResolver::ShouldChromeHandleUrl(const GURL& url) { |
| - // Stub implementation for now. |
| + if (!url.SchemeIsHTTPOrHTTPS()) { |
| + // Chrome will handle everything that is not http and https. |
| + return true; |
| + } |
| + |
| + for (const mojom::IntentFilterPtr& filter : intent_filters_) { |
| + if (IsRelevantIntentFilter(filter)) { |
| + // For now err on the side of caution and let Android |
| + // handle cases where there are possible matching intent |
| + // filters. |
| + return false; |
| + } |
| + } |
| + |
| + // Didn't find any matches for Android so let Chrome handle it. |
| return true; |
| } |
| +void LocalActivityResolver::UpdateIntentFilters( |
| + mojo::Array<mojom::IntentFilterPtr> intent_filters) { |
| + intent_filters_ = std::move(intent_filters); |
| +} |
| + |
| +bool LocalActivityResolver::IsRelevantIntentFilter( |
| + const mojom::IntentFilterPtr& intent_filter) { |
| + return FilterHasViewAction(intent_filter) && |
| + FilterCategoryIsBrowsable(intent_filter) && |
| + FilterHandlesWebSchemes(intent_filter); |
| +} |
| + |
| +bool LocalActivityResolver::FilterHasViewAction( |
| + const mojom::IntentFilterPtr& intent_filter) { |
| + for (const mojo::String& action : intent_filter->actions) { |
| + if (action == "android.intent.action.VIEW") { |
|
Yusuke Sato
2016/06/22 19:45:52
nit: can you define a constant?
namespace {
co
zentaro
2016/06/22 20:16:14
Done.
|
| + return true; |
| + } |
| + } |
| + |
| + return false; |
| +} |
| + |
| +bool LocalActivityResolver::FilterCategoryIsBrowsable( |
| + const mojom::IntentFilterPtr& intent_filter) { |
| + for (const mojo::String& category : intent_filter->categories) { |
| + if (category == "android.intent.category.BROWSABLE") { |
|
Yusuke Sato
2016/06/22 19:45:52
same
zentaro
2016/06/22 20:16:14
Done.
|
| + return true; |
| + } |
| + } |
| + |
| + return false; |
| +} |
| + |
| +bool LocalActivityResolver::FilterHandlesWebSchemes( |
| + const mojom::IntentFilterPtr& intent_filter) { |
| + for (const mojo::String& scheme : intent_filter->data_schemes) { |
| + if (scheme == "http" || scheme == "https") { |
| + return true; |
| + } |
| + } |
| + |
| + return false; |
| +} |
| + |
| } // namespace arc |