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

Side by Side Diff: components/arc/intent_helper/local_activity_resolver.cc

Issue 2078683002: Add handler and mojo interface to accept android intent filters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add code accidentally removed. 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 unified diff | Download patch
« no previous file with comments | « components/arc/intent_helper/local_activity_resolver.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/arc/intent_helper/local_activity_resolver.h" 5 #include "components/arc/intent_helper/local_activity_resolver.h"
6 6
7 #include "url/gurl.h" 7 #include "url/gurl.h"
8 8
9 namespace {
10
11 constexpr char kIntentActionView[] = "android.intent.action.VIEW";
12 constexpr char kIntentCategoryBrowsable[] = "android.intent.category.BROWSABLE";
13 constexpr char kSchemeHttp[] = "http";
14 constexpr char kSchemeHttps[] = "https";
15
16 } // namespace
17
9 namespace arc { 18 namespace arc {
10 19
20 LocalActivityResolver::LocalActivityResolver() = default;
21
22 LocalActivityResolver::~LocalActivityResolver() = default;
23
11 bool LocalActivityResolver::ShouldChromeHandleUrl(const GURL& url) { 24 bool LocalActivityResolver::ShouldChromeHandleUrl(const GURL& url) {
12 // Stub implementation for now. 25 if (!url.SchemeIsHTTPOrHTTPS()) {
26 // Chrome will handle everything that is not http and https.
27 return true;
28 }
29
30 for (const mojom::IntentFilterPtr& filter : intent_filters_) {
31 if (IsRelevantIntentFilter(filter)) {
32 // For now err on the side of caution and let Android
33 // handle cases where there are possible matching intent
34 // filters.
35 return false;
36 }
37 }
38
39 // Didn't find any matches for Android so let Chrome handle it.
13 return true; 40 return true;
14 } 41 }
15 42
43 void LocalActivityResolver::UpdateIntentFilters(
44 mojo::Array<mojom::IntentFilterPtr> intent_filters) {
45 intent_filters_ = std::move(intent_filters);
46 }
47
48 bool LocalActivityResolver::IsRelevantIntentFilter(
49 const mojom::IntentFilterPtr& intent_filter) {
50 return FilterHasViewAction(intent_filter) &&
51 FilterCategoryIsBrowsable(intent_filter) &&
52 FilterHandlesWebSchemes(intent_filter);
53 }
54
55 bool LocalActivityResolver::FilterHasViewAction(
56 const mojom::IntentFilterPtr& intent_filter) {
57 for (const mojo::String& action : intent_filter->actions) {
58 if (action == kIntentActionView) {
59 return true;
60 }
61 }
62
63 return false;
64 }
65
66 bool LocalActivityResolver::FilterCategoryIsBrowsable(
67 const mojom::IntentFilterPtr& intent_filter) {
68 for (const mojo::String& category : intent_filter->categories) {
69 if (category == kIntentCategoryBrowsable) {
70 return true;
71 }
72 }
73
74 return false;
75 }
76
77 bool LocalActivityResolver::FilterHandlesWebSchemes(
78 const mojom::IntentFilterPtr& intent_filter) {
79 for (const mojo::String& scheme : intent_filter->data_schemes) {
80 if (scheme == kSchemeHttp || scheme == kSchemeHttps) {
81 return true;
82 }
83 }
84
85 return false;
86 }
87
16 } // namespace arc 88 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/intent_helper/local_activity_resolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698