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

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: Minor style fix. Created 4 years, 6 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
14 } // namespace
15
9 namespace arc { 16 namespace arc {
10 17
18 LocalActivityResolver::LocalActivityResolver() = default;
19
20 LocalActivityResolver::~LocalActivityResolver() = default;
21
11 bool LocalActivityResolver::ShouldChromeHandleUrl(const GURL& url) { 22 bool LocalActivityResolver::ShouldChromeHandleUrl(const GURL& url) {
12 // Stub implementation for now. 23 if (!url.SchemeIsHTTPOrHTTPS()) {
24 // Chrome will handle everything that is not http and https.
25 return true;
26 }
27
28 for (const mojom::IntentFilterPtr& filter : intent_filters_) {
29 if (IsRelevantIntentFilter(filter)) {
30 // For now err on the side of caution and let Android
31 // handle cases where there are possible matching intent
32 // filters.
33 return false;
34 }
35 }
36
37 // Didn't find any matches for Android so let Chrome handle it.
13 return true; 38 return true;
14 } 39 }
15 40
41 void LocalActivityResolver::UpdateIntentFilters(
42 mojo::Array<mojom::IntentFilterPtr> intent_filters) {
43 intent_filters_ = std::move(intent_filters);
44 }
45
46 bool LocalActivityResolver::IsRelevantIntentFilter(
47 const mojom::IntentFilterPtr& intent_filter) {
48 return FilterHasViewAction(intent_filter) &&
49 FilterCategoryIsBrowsable(intent_filter) &&
50 FilterHandlesWebSchemes(intent_filter);
51 }
52
53 bool LocalActivityResolver::FilterHasViewAction(
54 const mojom::IntentFilterPtr& intent_filter) {
55 for (const mojo::String& action : intent_filter->actions) {
56 if (action == kIntentActionView) {
57 return true;
58 }
59 }
60
61 return false;
62 }
63
64 bool LocalActivityResolver::FilterCategoryIsBrowsable(
65 const mojom::IntentFilterPtr& intent_filter) {
66 for (const mojo::String& category : intent_filter->categories) {
67 if (category == kIntentCategoryBrowsable) {
68 return true;
69 }
70 }
71
72 return false;
73 }
74
75 bool LocalActivityResolver::FilterHandlesWebSchemes(
76 const mojom::IntentFilterPtr& intent_filter) {
77 for (const mojo::String& scheme : intent_filter->data_schemes) {
78 if (scheme == "http" || scheme == "https") {
dcheng 2016/06/24 22:32:35 Use kHttpScheme and kHttpsScheme at least. I don't
zentaro 2016/06/27 16:15:38 Done.
79 return true;
80 }
81 }
82
83 return false;
84 }
85
16 } // namespace arc 86 } // 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