Commit 20d87fa7 authored by Tim Sergeant's avatar Tim Sergeant Committed by Chromium LUCI CQ

[IntentHandling] Convert Actions and Mime Type in ARC IntentFilters

This adds support for actions ("send" and "send_multiple") and mime
types to filters in the CreateArcIntentFilter function. This isn't
currently used, but will be used by the Shadow APKs feature, which needs
to send arbitrary IntentFilters through to ARC (see
crrev.com/c/2548592).

BUG=853604,1099134

Change-Id: Ibf798ac37ca457e112c83a5568d1c064cd8b68f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2610409
Commit-Queue: Tim Sergeant <tsergeant@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarMaggie Cai <mxcai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840505}
parent efc32dd3
...@@ -229,6 +229,18 @@ base::flat_map<std::string, std::string> CreateIntentExtras( ...@@ -229,6 +229,18 @@ base::flat_map<std::string, std::string> CreateIntentExtras(
return extras; return extras;
} }
const char* GetArcIntentAction(const std::string& action) {
if (action == apps_util::kIntentActionView) {
return arc::kIntentActionView;
} else if (action == apps_util::kIntentActionSend) {
return arc::kIntentActionSend;
} else if (action == apps_util::kIntentActionSendMultiple) {
return arc::kIntentActionSendMultiple;
} else {
return arc::kIntentActionView;
}
}
arc::mojom::IntentInfoPtr CreateArcIntent(apps::mojom::IntentPtr intent) { arc::mojom::IntentInfoPtr CreateArcIntent(apps::mojom::IntentPtr intent) {
arc::mojom::IntentInfoPtr arc_intent; arc::mojom::IntentInfoPtr arc_intent;
if (!intent->url.has_value() && !intent->share_text.has_value()) { if (!intent->url.has_value() && !intent->share_text.has_value()) {
...@@ -236,15 +248,7 @@ arc::mojom::IntentInfoPtr CreateArcIntent(apps::mojom::IntentPtr intent) { ...@@ -236,15 +248,7 @@ arc::mojom::IntentInfoPtr CreateArcIntent(apps::mojom::IntentPtr intent) {
} }
arc_intent = arc::mojom::IntentInfo::New(); arc_intent = arc::mojom::IntentInfo::New();
if (intent->action.has_value()) { if (intent->action.has_value()) {
if (intent->action.value() == apps_util::kIntentActionView) { arc_intent->action = GetArcIntentAction(intent->action.value());
arc_intent->action = arc::kIntentActionView;
} else if (intent->action.value() == apps_util::kIntentActionSend) {
arc_intent->action = arc::kIntentActionSend;
} else if (intent->action.value() == apps_util::kIntentActionSendMultiple) {
arc_intent->action = arc::kIntentActionSendMultiple;
} else {
arc_intent->action = arc::kIntentActionView;
}
} else { } else {
arc_intent->action = arc::kIntentActionView; arc_intent->action = arc::kIntentActionView;
} }
...@@ -362,7 +366,6 @@ arc::IntentFilter CreateArcIntentFilter( ...@@ -362,7 +366,6 @@ arc::IntentFilter CreateArcIntentFilter(
std::vector<arc::IntentFilter::AuthorityEntry> authorities; std::vector<arc::IntentFilter::AuthorityEntry> authorities;
std::vector<arc::IntentFilter::PatternMatcher> paths; std::vector<arc::IntentFilter::PatternMatcher> paths;
std::vector<std::string> mime_types; std::vector<std::string> mime_types;
// TODO(crbug.com/853604): Add conversion for actions and mime types.
for (auto& condition : intent_filter->conditions) { for (auto& condition : intent_filter->conditions) {
switch (condition->condition_type) { switch (condition->condition_type) {
case apps::mojom::ConditionType::kScheme: case apps::mojom::ConditionType::kScheme:
...@@ -398,13 +401,19 @@ arc::IntentFilter CreateArcIntentFilter( ...@@ -398,13 +401,19 @@ arc::IntentFilter CreateArcIntentFilter(
condition_value->value, match_type)); condition_value->value, match_type));
} }
break; break;
// TODO(crbug.com/1092784): Handle action and mime type.
case apps::mojom::ConditionType::kAction: case apps::mojom::ConditionType::kAction:
for (auto& condition_value : condition->condition_values) {
actions.push_back(GetArcIntentAction(condition_value->value));
}
break;
case apps::mojom::ConditionType::kMimeType: case apps::mojom::ConditionType::kMimeType:
NOTIMPLEMENTED(); for (auto& condition_value : condition->condition_values) {
mime_types.push_back(condition_value->value);
}
break;
} }
} }
// TODO(crbug.com/853604): Add support for other action and category types. // TODO(crbug.com/853604): Add support for other category types.
return arc::IntentFilter(package_name, std::move(actions), return arc::IntentFilter(package_name, std::move(actions),
std::move(authorities), std::move(paths), std::move(authorities), std::move(paths),
std::move(schemes), std::move(mime_types)); std::move(schemes), std::move(mime_types));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment