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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/arc/intent_helper/local_activity_resolver.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8069624a95e4f34083e9da05ddfc1699436cf385 100644
--- a/components/arc/intent_helper/local_activity_resolver.cc
+++ b/components/arc/intent_helper/local_activity_resolver.cc
@@ -6,11 +6,81 @@
#include "url/gurl.h"
+namespace {
+
+constexpr char kIntentActionView[] = "android.intent.action.VIEW";
+constexpr char kIntentCategoryBrowsable[] = "android.intent.category.BROWSABLE";
+
+} // namespace
+
namespace arc {
+LocalActivityResolver::LocalActivityResolver() = default;
+
+LocalActivityResolver::~LocalActivityResolver() = default;
+
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 == kIntentActionView) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool LocalActivityResolver::FilterCategoryIsBrowsable(
+ const mojom::IntentFilterPtr& intent_filter) {
+ for (const mojo::String& category : intent_filter->categories) {
+ if (category == kIntentCategoryBrowsable) {
+ 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") {
dcheng 2016/06/24 22:32:35 Use kHttpScheme and kHttpsScheme at least. I don't
zentaro 2016/06/27 16:15:38 Done.
+ return true;
+ }
+ }
+
+ return false;
+}
+
} // namespace arc
« 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