Commit a349be15 authored by Marc Treib's avatar Marc Treib Committed by Chromium LUCI CQ

Revert "[Nearby] Add GetShareType to Attachment."

This reverts commit b8cd7ece.

Reason for revert: Seems to have broken NearbyPreviewTest.All on linux-chromeos-dbg, see crbug.com/1156833

Original change's description:
> [Nearby] Add GetShareType to Attachment.
>
> 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: I7fe151470c9067a918363152d2e0520a08dc0298
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2582523
> Commit-Queue: Michael Hansen <hansenmichael@google.com>
> Reviewed-by: Alex Gough <ajgo@chromium.org>
> Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
> Reviewed-by: James Vecore <vecore@google.com>
> Cr-Commit-Position: refs/heads/master@{#836953}

TBR=khorimoto@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com,ajgo@chromium.org,vecore@google.com,hansenmichael@google.com

Change-Id: I1c7f146adaf4bf76a032a1fe7a469fcd6a05ee65
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592991Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837024}
parent ae2fd008
......@@ -18,7 +18,6 @@ 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,8 +8,6 @@
#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
......@@ -33,7 +31,6 @@ 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,29 +71,3 @@ 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,7 +38,6 @@ 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,6 +57,50 @@ 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(),
......@@ -286,13 +330,23 @@ void NearbyPerSessionDiscoveryManager::GetSendPreview(
auto& attachment = attachments_[0];
send_preview->description = attachment->GetDescription();
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();
// 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;
}
std::move(callback).Run(std::move(send_preview));
}
......
......@@ -32,27 +32,13 @@ MATCHER_P(MatchesTarget, target, "") {
const char kTextAttachmentBody[] = "Test text payload";
std::vector<std::unique_ptr<Attachment>> CreateTextAttachments() {
std::vector<std::unique_ptr<Attachment>> CreateAttachments() {
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) {
......@@ -110,8 +96,6 @@ 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;
......@@ -124,7 +108,7 @@ class NearbyPerSessionDiscoveryManagerTest : public testing::Test {
content::BrowserTaskEnvironment task_environment_;
MockNearbySharingService sharing_service_;
NearbyPerSessionDiscoveryManager manager_{&sharing_service_,
CreateTextAttachments()};
CreateAttachments()};
};
} // namespace
......@@ -136,7 +120,7 @@ TEST_F(NearbyPerSessionDiscoveryManagerTest, CreateDestroyWithoutRegistering) {
.Times(0);
{
NearbyPerSessionDiscoveryManager manager(&sharing_service(),
CreateTextAttachments());
CreateAttachments());
// Creating and destroying an instance should not register itself with the
// NearbySharingService.
}
......@@ -510,94 +494,3 @@ 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,19 +126,6 @@ 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,7 +31,6 @@ 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,7 +55,6 @@ 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",
]
......@@ -90,7 +89,6 @@ 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",
]
......@@ -108,7 +106,6 @@ 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",
]
......@@ -143,10 +140,8 @@ js_library("app") {
}
js_library("discovery_manager") {
deps = [
"//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
"//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
]
deps =
[ "//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile" ]
}
js_library("nearby_confirmation_page") {
......@@ -154,7 +149,6 @@ 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",
......@@ -165,10 +159,9 @@ js_library("nearby_confirmation_page") {
js_library("nearby_discovery_page") {
deps = [
":discovery_manager",
"./shared:nearby_device.m",
"./shared:nearby_preview.m",
"./shared:nearby_device.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,7 +10,6 @@
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,7 +13,6 @@ 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,7 +14,6 @@ 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",
":nearby_device_icon",
":nearby_device",
":nearby_onboarding_page",
":nearby_page_template",
":nearby_preview",
......@@ -130,7 +130,6 @@ 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",
]
......@@ -149,7 +148,6 @@ 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",
......@@ -209,8 +207,8 @@ js_type_check("closure_compile_module") {
deps = [
":nearby_contact_manager.m",
":nearby_contact_visibility.m",
":nearby_device.m",
":nearby_device_icon.m",
":nearby_device.m",
":nearby_onboarding_page.m",
":nearby_page_template.m",
":nearby_preview.m",
......@@ -235,7 +233,6 @@ 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",
]
......@@ -270,7 +267,6 @@ 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",
]
......@@ -307,7 +303,6 @@ 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,7 +8,6 @@
<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">
......
......@@ -61,7 +61,6 @@ 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",
]
......@@ -116,7 +115,6 @@ 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,6 +4,5 @@
<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,7 +8,6 @@
// #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,15 +6,10 @@ 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,7 +4,6 @@
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";
......@@ -102,6 +101,40 @@ 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,7 +8,6 @@
// #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,7 +7,6 @@
// #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,7 +7,6 @@
// #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,7 +7,6 @@
// #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