Commit 015fd7a9 authored by Maggie Cai's avatar Maggie Cai Committed by Chromium LUCI CQ

[Sharesheet] Support sharing extra data with files to ARC.

Currently when we share files to ARC, it does not accept any extra data.
However, with the web share support, it is possible to share files with
title and text. This CL adds the support to share extra strings to ARC.

BUG=1127670

Change-Id: I2eeaf4199ad1c2df94be77df0574f046c26f1f95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2589200Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837028}
parent d04319f4
...@@ -213,6 +213,19 @@ base::Optional<arc::UserInteractionType> GetUserInterationType( ...@@ -213,6 +213,19 @@ base::Optional<arc::UserInteractionType> GetUserInterationType(
return user_interaction_type; return user_interaction_type;
} }
base::flat_map<std::string, std::string> CreateIntentExtras(
const apps::mojom::IntentPtr& intent) {
auto extras = base::flat_map<std::string, std::string>();
if (intent->share_text.has_value()) {
extras.insert(std::make_pair(kIntentExtraText, intent->share_text.value()));
}
if (intent->share_title.has_value()) {
extras.insert(
std::make_pair(kIntentExtraSubject, intent->share_title.value()));
}
return extras;
}
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 +249,7 @@ arc::mojom::IntentInfoPtr CreateArcIntent(apps::mojom::IntentPtr intent) { ...@@ -236,15 +249,7 @@ arc::mojom::IntentInfoPtr CreateArcIntent(apps::mojom::IntentPtr intent) {
arc_intent->data = intent->url->spec(); arc_intent->data = intent->url->spec();
} }
if (intent->share_text.has_value() || intent->share_title.has_value()) { if (intent->share_text.has_value() || intent->share_title.has_value()) {
arc_intent->extras = base::flat_map<std::string, std::string>(); arc_intent->extras = CreateIntentExtras(intent);
}
if (intent->share_text.has_value()) {
arc_intent->extras.value().insert(
std::make_pair(kIntentExtraText, intent->share_text.value()));
}
if (intent->share_title.has_value()) {
arc_intent->extras.value().insert(
std::make_pair(kIntentExtraSubject, intent->share_title.value()));
} }
return arc_intent; return arc_intent;
} }
...@@ -537,6 +542,9 @@ arc::mojom::OpenUrlsRequestPtr ConstructOpenUrlsRequest( ...@@ -537,6 +542,9 @@ arc::mojom::OpenUrlsRequestPtr ConstructOpenUrlsRequest(
url_with_type->mime_type = intent->mime_type.value(); url_with_type->mime_type = intent->mime_type.value();
request->urls.push_back(std::move(url_with_type)); request->urls.push_back(std::move(url_with_type));
} }
if (intent->share_text.has_value() || intent->share_title.has_value()) {
request->extras = CreateIntentExtras(intent);
}
return request; return request;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// Next MinVersion: 17 // Next MinVersion: 18
module arc.mojom; module arc.mojom;
...@@ -126,6 +126,11 @@ struct OpenUrlsRequest { ...@@ -126,6 +126,11 @@ struct OpenUrlsRequest {
// One or more URLs to open with the intent. // One or more URLs to open with the intent.
array<ContentUrlWithMimeType> urls; array<ContentUrlWithMimeType> urls;
// Optional string extras. These are the key-value pairs stored in android
// intents to carry additional data. See:
// https://developer.android.com/reference/android/content/Intent#putExtra(java.lang.String,%20java.lang.String)
[MinVersion=17] map<string, string>? extras;
}; };
// Supported action types for SelectFilesRequest. // Supported action types for SelectFilesRequest.
......
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