Commit 33710b29 authored by Michael Hansen's avatar Michael Hansen Committed by Chromium LUCI CQ

[Nearby] Reland: Add GetShareType to Attachment.

The original change was reverted due to the NearbyPreviewTest.All test
failing. Fixed by adding a missing script include.

Revert is here:
  https://chromium-review.googlesource.com/c/chromium/src/+/2592991

Original change is here:
  https://chromium-review.googlesource.com/c/chromium/src/+/2582523

Original description:
> Moves the logic for determining the ShareType into the *Attachment
> classes. This cleans up some static casts and also allows this logic
> to be reused when generating the preview for the receive dialog page,
> coming in a subsequent CL.
>
> To avoid a dependency cycle I've moved the ShareType mojo struct
> definition into its own build target, which required importing new
> mojo gen files in a number of places.

Fixed: 1144942
Change-Id: I012f682d52505420a2ae7063f95d7c4227d5bb03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593808Reviewed-by: default avatarJames Vecore <vecore@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Commit-Queue: Michael Hansen <hansenmichael@google.com>
Cr-Commit-Position: refs/heads/master@{#837199}
parent 100d31d5
......@@ -18,6 +18,7 @@ source_set("share_target") {
deps = [
"//base",
"//chrome/browser/ui/webui/nearby_share:share_type",
"//chromeos/services/nearby/public/mojom",
"//chromeos/services/nearby/public/mojom:nearby_share_target_types",
"//net",
......
......@@ -8,6 +8,8 @@
#include <stdint.h>
#include <string>
#include "chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom.h"
struct ShareTarget;
// A single attachment to be sent by / received from a ShareTarget, can be
......@@ -31,6 +33,7 @@ class Attachment {
virtual void MoveToShareTarget(ShareTarget& share_target) = 0;
virtual const std::string& GetDescription() const = 0;
virtual nearby_share::mojom::ShareType GetShareType() const = 0;
private:
int64_t id_;
......
......@@ -71,3 +71,29 @@ void FileAttachment::MoveToShareTarget(ShareTarget& share_target) {
const std::string& FileAttachment::GetDescription() const {
return file_name_;
}
nearby_share::mojom::ShareType FileAttachment::GetShareType() const {
switch (type()) {
case FileAttachment::Type::kImage:
return nearby_share::mojom::ShareType::kImageFile;
case FileAttachment::Type::kVideo:
return nearby_share::mojom::ShareType::kVideoFile;
case FileAttachment::Type::kAudio:
return nearby_share::mojom::ShareType::kAudioFile;
default:
break;
}
// Try matching on mime type if the attachment type is unrecognized.
if (mime_type() == "application/pdf") {
return nearby_share::mojom::ShareType::kPdfFile;
} else if (mime_type() == "application/vnd.google-apps.document") {
return nearby_share::mojom::ShareType::kGoogleDocsFile;
} else if (mime_type() == "application/vnd.google-apps.spreadsheet") {
return nearby_share::mojom::ShareType::kGoogleSheetsFile;
} else if (mime_type() == "application/vnd.google-apps.presentation") {
return nearby_share::mojom::ShareType::kGoogleSlidesFile;
} else {
return nearby_share::mojom::ShareType::kUnknownFile;
}
}
......@@ -38,6 +38,7 @@ class FileAttachment : public Attachment {
// Attachment:
void MoveToShareTarget(ShareTarget& share_target) override;
const std::string& GetDescription() const override;
nearby_share::mojom::ShareType GetShareType() const override;
void set_file_path(base::Optional<base::FilePath> path) {
file_path_ = std::move(path);
......
......@@ -57,50 +57,6 @@ base::Optional<nearby_share::mojom::TransferStatus> GetTransferStatus(
}
}
nearby_share::mojom::ShareType GetTextShareType(
const TextAttachment* attachment) {
switch (attachment->type()) {
case TextAttachment::Type::kUrl:
return nearby_share::mojom::ShareType::kUrl;
case TextAttachment::Type::kAddress:
return nearby_share::mojom::ShareType::kAddress;
case TextAttachment::Type::kPhoneNumber:
return nearby_share::mojom::ShareType::kPhone;
default:
return nearby_share::mojom::ShareType::kText;
}
}
nearby_share::mojom::ShareType GetFileShareType(
const FileAttachment* attachment) {
switch (attachment->type()) {
case FileAttachment::Type::kImage:
return nearby_share::mojom::ShareType::kImageFile;
case FileAttachment::Type::kVideo:
return nearby_share::mojom::ShareType::kVideoFile;
case FileAttachment::Type::kAudio:
return nearby_share::mojom::ShareType::kAudioFile;
default:
break;
}
// Try matching on mime type if the attachment type is unrecognized.
if (attachment->mime_type() == "application/pdf") {
return nearby_share::mojom::ShareType::kPdfFile;
} else if (attachment->mime_type() ==
"application/vnd.google-apps.document") {
return nearby_share::mojom::ShareType::kGoogleDocsFile;
} else if (attachment->mime_type() ==
"application/vnd.google-apps.spreadsheet") {
return nearby_share::mojom::ShareType::kGoogleSheetsFile;
} else if (attachment->mime_type() ==
"application/vnd.google-apps.presentation") {
return nearby_share::mojom::ShareType::kGoogleSlidesFile;
} else {
return nearby_share::mojom::ShareType::kUnknownFile;
}
}
std::string GetDeviceIdForLogs(const ShareTarget& share_target) {
return (share_target.device_id
? base::HexEncode(share_target.device_id.value().data(),
......@@ -330,23 +286,13 @@ void NearbyPerSessionDiscoveryManager::GetSendPreview(
auto& attachment = attachments_[0];
send_preview->description = attachment->GetDescription();
// TODO(crbug.com/1144942) Add virtual GetShareType to Attachment to eliminate
// these casts.
switch (attachment->family()) {
case Attachment::Family::kText:
send_preview->share_type =
GetTextShareType(static_cast<TextAttachment*>(attachment.get()));
break;
case Attachment::Family::kFile:
send_preview->file_count = attachments_.size();
// For multiple files we don't capture the types.
send_preview->share_type =
attachments_.size() > 1
? nearby_share::mojom::ShareType::kMultipleFiles
: GetFileShareType(
static_cast<FileAttachment*>(attachment.get()));
break;
}
if (attachment->family() == Attachment::Family::kFile)
send_preview->file_count = attachments_.size();
if (send_preview->file_count > 1)
send_preview->share_type = nearby_share::mojom::ShareType::kMultipleFiles;
else
send_preview->share_type = attachment->GetShareType();
std::move(callback).Run(std::move(send_preview));
}
......
......@@ -32,13 +32,27 @@ MATCHER_P(MatchesTarget, target, "") {
const char kTextAttachmentBody[] = "Test text payload";
std::vector<std::unique_ptr<Attachment>> CreateAttachments() {
std::vector<std::unique_ptr<Attachment>> CreateTextAttachments() {
std::vector<std::unique_ptr<Attachment>> attachments;
attachments.push_back(std::make_unique<TextAttachment>(
TextAttachment::Type::kText, kTextAttachmentBody));
return attachments;
}
std::vector<std::unique_ptr<Attachment>> CreateFileAttachments(
size_t count,
std::string mime_type,
sharing::mojom::FileMetadata::Type type) {
std::vector<std::unique_ptr<Attachment>> attachments;
for (size_t i = 0; i < count; i++) {
std::string file_name("File-" + base::NumberToString(i));
attachments.push_back(
std::make_unique<FileAttachment>(i, i, file_name, mime_type, type));
}
return attachments;
}
void ExpectTextAttachment(
const std::string& text_body,
const std::vector<std::unique_ptr<Attachment>>& attachments) {
......@@ -96,6 +110,8 @@ class NearbyPerSessionDiscoveryManagerTest : public testing::Test {
NearbyPerSessionDiscoveryManager::SelectShareTargetCallback>;
using MockStartDiscoveryCallback = base::MockCallback<
NearbyPerSessionDiscoveryManager::StartDiscoveryCallback>;
using MockGetSendPreviewCallback = base::MockCallback<
nearby_share::mojom::DiscoveryManager::GetSendPreviewCallback>;
NearbyPerSessionDiscoveryManagerTest() = default;
~NearbyPerSessionDiscoveryManagerTest() override = default;
......@@ -108,7 +124,7 @@ class NearbyPerSessionDiscoveryManagerTest : public testing::Test {
content::BrowserTaskEnvironment task_environment_;
MockNearbySharingService sharing_service_;
NearbyPerSessionDiscoveryManager manager_{&sharing_service_,
CreateAttachments()};
CreateTextAttachments()};
};
} // namespace
......@@ -120,7 +136,7 @@ TEST_F(NearbyPerSessionDiscoveryManagerTest, CreateDestroyWithoutRegistering) {
.Times(0);
{
NearbyPerSessionDiscoveryManager manager(&sharing_service(),
CreateAttachments());
CreateTextAttachments());
// Creating and destroying an instance should not register itself with the
// NearbySharingService.
}
......@@ -494,3 +510,94 @@ TEST_F(NearbyPerSessionDiscoveryManagerTest, TransferUpdateWithoutListener) {
EXPECT_CALL(sharing_service(), UnregisterSendSurface(&manager(), &manager()))
.WillOnce(testing::Return(NearbySharingService::StatusCodes::kOk));
}
TEST_F(NearbyPerSessionDiscoveryManagerTest, PreviewText) {
NearbyPerSessionDiscoveryManager manager(&sharing_service(),
CreateTextAttachments());
MockGetSendPreviewCallback callback;
nearby_share::mojom::SendPreview send_preview;
EXPECT_CALL(callback, Run(_))
.WillOnce(testing::SaveArgPointee<0>(&send_preview));
manager.GetSendPreview(callback.Get());
EXPECT_EQ(send_preview.description, kTextAttachmentBody);
EXPECT_EQ(send_preview.file_count, 0);
EXPECT_EQ(send_preview.share_type, nearby_share::mojom::ShareType::kText);
}
TEST_F(NearbyPerSessionDiscoveryManagerTest, PreviewSingleVideo) {
NearbyPerSessionDiscoveryManager manager(
&sharing_service(),
CreateFileAttachments(/*count=*/1, /*mime_type=*/"",
/*type=*/FileAttachment::Type::kVideo));
MockGetSendPreviewCallback callback;
nearby_share::mojom::SendPreview send_preview;
EXPECT_CALL(callback, Run(_))
.WillOnce(testing::SaveArgPointee<0>(&send_preview));
manager.GetSendPreview(callback.Get());
EXPECT_EQ(send_preview.description, "File-0");
EXPECT_EQ(send_preview.file_count, 1);
EXPECT_EQ(send_preview.share_type,
nearby_share::mojom::ShareType::kVideoFile);
}
TEST_F(NearbyPerSessionDiscoveryManagerTest, PreviewSinglePDF) {
NearbyPerSessionDiscoveryManager manager(
&sharing_service(),
CreateFileAttachments(/*count=*/1, /*mime_type=*/"application/pdf",
/*type=*/FileAttachment::Type::kUnknown));
MockGetSendPreviewCallback callback;
nearby_share::mojom::SendPreview send_preview;
EXPECT_CALL(callback, Run(_))
.WillOnce(testing::SaveArgPointee<0>(&send_preview));
manager.GetSendPreview(callback.Get());
EXPECT_EQ(send_preview.description, "File-0");
EXPECT_EQ(send_preview.file_count, 1);
EXPECT_EQ(send_preview.share_type, nearby_share::mojom::ShareType::kPdfFile);
}
TEST_F(NearbyPerSessionDiscoveryManagerTest, PreviewSingleUnknownFile) {
NearbyPerSessionDiscoveryManager manager(
&sharing_service(),
CreateFileAttachments(/*count=*/1, /*mime_type=*/"",
/*type=*/FileAttachment::Type::kUnknown));
MockGetSendPreviewCallback callback;
nearby_share::mojom::SendPreview send_preview;
EXPECT_CALL(callback, Run(_))
.WillOnce(testing::SaveArgPointee<0>(&send_preview));
manager.GetSendPreview(callback.Get());
EXPECT_EQ(send_preview.description, "File-0");
EXPECT_EQ(send_preview.file_count, 1);
EXPECT_EQ(send_preview.share_type,
nearby_share::mojom::ShareType::kUnknownFile);
}
TEST_F(NearbyPerSessionDiscoveryManagerTest, PreviewMultipleFiles) {
NearbyPerSessionDiscoveryManager manager(
&sharing_service(),
CreateFileAttachments(/*count=*/2, /*mime_type=*/"",
/*type=*/FileAttachment::Type::kUnknown));
MockGetSendPreviewCallback callback;
nearby_share::mojom::SendPreview send_preview;
EXPECT_CALL(callback, Run(_))
.WillOnce(testing::SaveArgPointee<0>(&send_preview));
manager.GetSendPreview(callback.Get());
EXPECT_EQ(send_preview.description, "File-0");
EXPECT_EQ(send_preview.file_count, 2);
EXPECT_EQ(send_preview.share_type,
nearby_share::mojom::ShareType::kMultipleFiles);
}
TEST_F(NearbyPerSessionDiscoveryManagerTest, PreviewNoAttachments) {
NearbyPerSessionDiscoveryManager manager(
&sharing_service(),
CreateFileAttachments(/*count=*/0, /*mime_type=*/"",
/*type=*/FileAttachment::Type::kUnknown));
MockGetSendPreviewCallback callback;
nearby_share::mojom::SendPreview send_preview;
EXPECT_CALL(callback, Run(_))
.WillOnce(testing::SaveArgPointee<0>(&send_preview));
manager.GetSendPreview(callback.Get());
EXPECT_EQ(send_preview.description, "");
EXPECT_EQ(send_preview.file_count, 0);
EXPECT_EQ(send_preview.share_type, nearby_share::mojom::ShareType::kText);
}
......@@ -126,6 +126,19 @@ const std::string& TextAttachment::GetDescription() const {
return text_title_;
}
nearby_share::mojom::ShareType TextAttachment::GetShareType() const {
switch (type()) {
case TextAttachment::Type::kUrl:
return nearby_share::mojom::ShareType::kUrl;
case TextAttachment::Type::kAddress:
return nearby_share::mojom::ShareType::kAddress;
case TextAttachment::Type::kPhoneNumber:
return nearby_share::mojom::ShareType::kPhone;
default:
return nearby_share::mojom::ShareType::kText;
}
}
void TextAttachment::set_text_body(std::string text_body) {
text_body_ = std::move(text_body);
text_title_ = GetTextTitle(text_body_, type_);
......
......@@ -31,6 +31,7 @@ class TextAttachment : public Attachment {
// Attachment:
void MoveToShareTarget(ShareTarget& share_target) override;
const std::string& GetDescription() const override;
nearby_share::mojom::ShareType GetShareType() const override;
void set_text_body(std::string text_body);
......
......@@ -55,6 +55,7 @@ generate_grd("build_grd") {
]
resource_path_rewrites = [
"chrome/browser/ui/webui/nearby_share/nearby_share.mojom-lite.js|mojo/nearby_share.mojom-lite.js",
"chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom-lite.js|mojo/nearby_share_share_type.mojom-lite.js",
"chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom-lite.js|mojo/nearby_share_settings.mojom-lite.js",
"chromeos/services/nearby/public/mojom/nearby_share_target_types.mojom-lite.js|mojo/nearby_share_target_types.mojom-lite.js",
]
......@@ -89,6 +90,7 @@ generate_grd("build_mojo_grdp") {
manifest_files = [ "$target_gen_dir/$preprocess_mojo_manifest" ]
resource_path_rewrites = [
"chrome/browser/ui/webui/nearby_share/nearby_share.mojom-lite.js|mojo/nearby_share.mojom-lite.js",
"chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom-lite.js|mojo/nearby_share_share_type.mojom-lite.js",
"chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom-lite.js|mojo/nearby_share_settings.mojom-lite.js",
"chromeos/services/nearby/public/mojom/nearby_share_target_types.mojom-lite.js|mojo/nearby_share_target_types.mojom-lite.js",
]
......@@ -106,6 +108,7 @@ preprocess_if_expr("preprocess_mojo") {
out_manifest = "$target_gen_dir/$preprocess_mojo_manifest"
in_files = [
"chrome/browser/ui/webui/nearby_share/nearby_share.mojom-lite.js",
"chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom-lite.js",
"chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom-lite.js",
"chromeos/services/nearby/public/mojom/nearby_share_target_types.mojom-lite.js",
]
......@@ -140,8 +143,10 @@ js_library("app") {
}
js_library("discovery_manager") {
deps =
[ "//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile" ]
deps = [
"//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
"//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
]
}
js_library("nearby_confirmation_page") {
......@@ -149,6 +154,7 @@ js_library("nearby_confirmation_page") {
"./shared:nearby_preview.m",
"./shared:nearby_progress.m",
"//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
"//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_button:cr_button.m",
"//ui/webui/resources/cr_elements/cr_checkbox:cr_checkbox.m",
......@@ -159,9 +165,10 @@ js_library("nearby_confirmation_page") {
js_library("nearby_discovery_page") {
deps = [
":discovery_manager",
"./shared:nearby_preview.m",
"./shared:nearby_device.m",
"./shared:nearby_preview.m",
"//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
"//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
"//third_party/polymer/v3_0/components-chromium/iron-list",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_button:cr_button.m",
......
......@@ -10,6 +10,7 @@
import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
import 'chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js';
import './mojo/nearby_share_target_types.mojom-lite.js';
import './mojo/nearby_share_share_type.mojom-lite.js';
import './mojo/nearby_share.mojom-lite.js';
/** @type {?nearbyShare.mojom.DiscoveryManagerInterface} */
......
......@@ -13,6 +13,7 @@ import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.m.js';
import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
import 'chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js';
import './mojo/nearby_share_target_types.mojom-lite.js';
import './mojo/nearby_share_share_type.mojom-lite.js';
import './mojo/nearby_share.mojom-lite.js';
import './shared/nearby_page_template.m.js';
import './shared/nearby_preview.m.js';
......
......@@ -14,6 +14,7 @@ import 'chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-l
import 'chrome://resources/polymer/v3_0/iron-list/iron-list.js';
import './shared/nearby_device.m.js';
import './mojo/nearby_share_target_types.mojom-lite.js';
import './mojo/nearby_share_share_type.mojom-lite.js';
import './mojo/nearby_share.mojom-lite.js';
import './shared/nearby_page_template.m.js';
import './shared/nearby_preview.m.js';
......
......@@ -89,8 +89,8 @@ js_type_check("closure_compile") {
deps = [
":nearby_contact_manager",
":nearby_contact_visibility",
":nearby_device_icon",
":nearby_device",
":nearby_device_icon",
":nearby_onboarding_page",
":nearby_page_template",
":nearby_preview",
......@@ -130,6 +130,7 @@ js_library("nearby_contact_visibility") {
js_library("nearby_device_icon") {
deps = [
"//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
"//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
"//chromeos/services/nearby/public/mojom:nearby_share_target_types_js_library_for_compile",
"//third_party/polymer/v1_0/components-chromium/iron-icon:iron-icon-extracted",
]
......@@ -148,6 +149,7 @@ js_library("nearby_page_template") {
js_library("nearby_preview") {
deps = [
"//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
"//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
"//chromeos/services/nearby/public/mojom:nearby_share_target_types_js_library_for_compile",
"//third_party/polymer/v1_0/components-chromium/iron-icon:iron-icon-extracted",
"//ui/webui/resources/js:assert",
......@@ -207,8 +209,8 @@ js_type_check("closure_compile_module") {
deps = [
":nearby_contact_manager.m",
":nearby_contact_visibility.m",
":nearby_device_icon.m",
":nearby_device.m",
":nearby_device_icon.m",
":nearby_onboarding_page.m",
":nearby_page_template.m",
":nearby_preview.m",
......@@ -233,6 +235,7 @@ group("polymer3_elements") {
":nearby_shared_share_type_icons_module",
":nearby_visibility_page_module",
"//chrome/browser/ui/webui/nearby_share:mojom_js",
"//chrome/browser/ui/webui/nearby_share:share_type_js",
"//chrome/browser/ui/webui/nearby_share/public/mojom:mojom_js",
"//chromeos/services/nearby/public/mojom:nearby_share_target_types_js",
]
......@@ -267,6 +270,7 @@ js_library("nearby_device_icon.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/nearby_share/shared/nearby_device_icon.m.js" ]
deps = [
"//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
"//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
"//chromeos/services/nearby/public/mojom:nearby_share_target_types_js_library_for_compile",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
......@@ -303,6 +307,7 @@ js_library("nearby_preview.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/nearby_share/shared/nearby_preview.m.js" ]
deps = [
"//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
"//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
"//chromeos/services/nearby/public/mojom:nearby_share_target_types_js_library_for_compile",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
......
......@@ -8,6 +8,7 @@
<script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script>
<script src="chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js"></script>
<script src="/mojo/nearby_share_target_types.mojom-lite.js"></script>
<script src="/mojo/nearby_share_share_type.mojom-lite.js"></script>
<script src="/mojo/nearby_share.mojom-lite.js"></script>
<dom-module id="nearby-device-icon">
......
......@@ -11,6 +11,7 @@
<script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script>
<script src="chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js"></script>
<script src="/mojo/nearby_share_target_types.mojom-lite.js"></script>
<script src="/mojo/nearby_share_share_type.mojom-lite.js"></script>
<script src="/mojo/nearby_share.mojom-lite.js"></script>
<dom-module id="nearby-preview">
......
......@@ -61,6 +61,7 @@ if (optimize_webui) {
"chrome://resources/mojo/skia/public/mojom/image_info.mojom-lite.js",
"chrome://resources/mojo/url/mojom/url.mojom-lite.js",
"mojo/nearby_share.mojom-lite.js",
"mojo/nearby_share_share_type.mojom-lite.js",
"mojo/nearby_share_target_types.mojom-lite.js",
"mojo/nearby_share_settings.mojom-lite.js",
]
......@@ -115,6 +116,7 @@ if (optimize_webui) {
"app-management/image.mojom-lite.js",
"app-management/types.mojom-lite.js",
"mojo/nearby_share.mojom-lite.js",
"mojo/nearby_share_share_type.mojom-lite.js",
"mojo/nearby_share_target_types.mojom-lite.js",
"mojo/nearby_share_settings.mojom-lite.js",
]
......
......@@ -4,5 +4,6 @@
<script src="chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js">
</script>
<script src="/mojo/nearby_share_target_types.mojom-lite.js"></script>
<script src="/mojo/nearby_share_share_type.mojom-lite.js"></script>
<script src="/mojo/nearby_share.mojom-lite.js"></script>
<script src="nearby_share_receive_manager.js"></script>
......@@ -8,6 +8,7 @@
// #import 'chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js';
// #import {addSingletonGetter} from 'chrome://resources/js/cr.m.js';
// #import '/mojo/nearby_share_target_types.mojom-lite.js';
// #import '/mojo/nearby_share_share_type.mojom-lite.js';
// #import '/mojo/nearby_share.mojom-lite.js';
// #import '/mojo/nearby_share_settings.mojom-lite.js';
// clang-format on
......
......@@ -6,10 +6,15 @@ import("//mojo/public/tools/bindings/mojom.gni")
assert(is_chromeos, "Nearby Share is CrOS only")
mojom("share_type") {
sources = [ "nearby_share_share_type.mojom" ]
}
mojom("mojom") {
sources = [ "nearby_share.mojom" ]
public_deps = [
":share_type",
"//chromeos/services/nearby/public/mojom:nearby_share_target_types",
"//mojo/public/mojom/base",
]
......
......@@ -4,6 +4,7 @@
module nearby_share.mojom;
import "chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom";
import "chromeos/services/nearby/public/mojom/nearby_share_target_types.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
......@@ -101,40 +102,6 @@ interface TransferUpdateListener {
OnTransferUpdate(TransferStatus status, string? token);
};
// This enum combines both text and file share attachment types into a single
// enum that more directly maps to what is shown to user for preview.
enum ShareType {
// A generic non-file text share.
kText,
// A text share representing a url, opened in browser.
kUrl,
// A text share representing a phone number, opened in dialer.
kPhone,
// A text share representing an address, opened in browser.
kAddress,
// Multiple files are being shared, we don't capture the specific types.
kMultipleFiles,
// Single file attachment with a mime type of 'image/*'.
kImageFile,
// Single file attachment with a mime type of 'video/*'.
kVideoFile,
// Single file attachment with a mime type of 'audio/*'.
kAudioFile,
// Single file attachment with a mime type of 'application/pdf'.
kPdfFile,
// Single file attachment with a mime type of
// 'application/vnd.google-apps.document'.
kGoogleDocsFile,
// Single file attachment with a mime type of
// 'application/vnd.google-apps.spreadsheet'.
kGoogleSheetsFile,
// Single file attachment with a mime type of
// 'application/vnd.google-apps.presentation'.
kGoogleSlidesFile,
// Single file attachment with un-matched mime type.
kUnknownFile,
};
// Contains the minimum amount of information needed to show the user a preview
// of their share when they are confirming a send to a share target.
struct SendPreview {
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module nearby_share.mojom;
// This enum combines both text and file share attachment types into a single
// enum that more directly maps to what is shown to user for preview.
enum ShareType {
// A generic non-file text share.
kText,
// A text share representing a url, opened in browser.
kUrl,
// A text share representing a phone number, opened in dialer.
kPhone,
// A text share representing an address, opened in browser.
kAddress,
// Multiple files are being shared, we don't capture the specific types.
kMultipleFiles,
// Single file attachment with a mime type of 'image/*'.
kImageFile,
// Single file attachment with a mime type of 'video/*'.
kVideoFile,
// Single file attachment with a mime type of 'audio/*'.
kAudioFile,
// Single file attachment with a mime type of 'application/pdf'.
kPdfFile,
// Single file attachment with a mime type of
// 'application/vnd.google-apps.document'.
kGoogleDocsFile,
// Single file attachment with a mime type of
// 'application/vnd.google-apps.spreadsheet'.
kGoogleSheetsFile,
// Single file attachment with a mime type of
// 'application/vnd.google-apps.presentation'.
kGoogleSlidesFile,
// Single file attachment with un-matched mime type.
kUnknownFile,
};
......@@ -8,6 +8,7 @@
// #import 'chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js';
// #import 'chrome://nearby/shared/nearby_device_icon.m.js';
// #import 'chrome://nearby/mojo/nearby_share_target_types.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share_share_type.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share.mojom-lite.js';
// #import {assertEquals} from '../../chai_assert.js';
// clang-format on
......
......@@ -7,6 +7,7 @@
// #import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
// #import 'chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share_target_types.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share_share_type.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share.mojom-lite.js';
// #import 'chrome://nearby/shared/nearby_device.m.js';
// #import {assertEquals} from '../../chai_assert.js';
......
......@@ -7,6 +7,7 @@
// #import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
// #import 'chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share_target_types.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share_share_type.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share.mojom-lite.js';
// #import 'chrome://nearby/shared/nearby_preview.m.js';
// #import {assertEquals} from '../../chai_assert.js';
......
......@@ -7,6 +7,7 @@
// #import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
// #import 'chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share_target_types.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share_share_type.mojom-lite.js';
// #import 'chrome://nearby/mojo/nearby_share.mojom-lite.js';
// #import 'chrome://nearby/shared/nearby_progress.m.js';
// #import {assertEquals} from '../../chai_assert.js';
......
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