Commit 47f45d5d authored by Hoch Hochkeppel's avatar Hoch Hochkeppel Committed by Commit Bot

WebShare: Stub implementation for Windows

Adding a stub implementation of the mojom ShareService. Currently only
for the Windows build, but intended to be useable as the central file
from which OS-specific implementations can be connected (e.g. a future
share_service_imple_win for the Windows-specific implementation).

To exercise this code, enable the Web Share flag in chrome://flags,
navigate to https://w3c.github.io/web-share/demos/share-files.html, and
attempt to Share content.  With this change, calls to navigator.share
are completed with a cancellation error, rather than crashing the
process.

Bug: 1035527
Change-Id: Id01c2a49646fc9e64401f34fe886b2527866ebda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2378144Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803103}
parent 781c71b0
......@@ -4224,6 +4224,8 @@ static_library("browser") {
"themes/theme_helper_win.cc",
"themes/theme_helper_win.h",
"upgrade_detector/get_installed_version_win.cc",
"webshare/share_service_impl.cc",
"webshare/share_service_impl.h",
"win/app_icon.cc",
"win/app_icon.h",
"win/automation_controller.cc",
......
......@@ -38,6 +38,7 @@
#include "chrome/browser/ui/webui/omnibox/omnibox_ui.h"
#include "chrome/browser/ui/webui/usb_internals/usb_internals.mojom.h"
#include "chrome/browser/ui/webui/usb_internals/usb_internals_ui.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/contextual_search/buildflags.h"
......@@ -101,7 +102,6 @@
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/mojom/digital_goods/digital_goods.mojom.h"
#include "third_party/blink/public/mojom/installedapp/installed_app_provider.mojom.h"
#include "third_party/blink/public/mojom/webshare/webshare.mojom.h"
#else
#include "chrome/browser/accessibility/caption_host_impl.h"
#include "chrome/browser/badging/badge_manager.h"
......@@ -184,6 +184,13 @@
#include "media/capture/video/chromeos/mojom/camera_app.mojom.h"
#endif
#if defined(OS_WIN) || defined(OS_ANDROID)
#if defined(OS_WIN)
#include "chrome/browser/webshare/share_service_impl.h"
#endif
#include "third_party/blink/public/mojom/webshare/webshare.mojom.h"
#endif
#if defined(OS_CHROMEOS) && !defined(OFFICIAL_BUILD)
#include "chromeos/components/telemetry_extension_ui/mojom/diagnostics_service.mojom.h"
#include "chromeos/components/telemetry_extension_ui/mojom/probe_service.mojom.h"
......@@ -474,6 +481,13 @@ void PopulateChromeFrameBinders(
base::BindRepeating(&payments::CreatePaymentCredential));
#endif
#if defined(OS_WIN)
if (base::FeatureList::IsEnabled(features::kWebShare)) {
map->Add<blink::mojom::ShareService>(
base::BindRepeating(&ShareServiceImpl::Create));
}
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
map->Add<extensions::mime_handler::MimeHandlerService>(
base::BindRepeating(&BindMimeHandlerService));
......
// 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.
#include "chrome/browser/webshare/share_service_impl.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
ShareServiceImpl::ShareServiceImpl() = default;
ShareServiceImpl::~ShareServiceImpl() = default;
// static
void ShareServiceImpl::Create(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::ShareService> receiver) {
mojo::MakeSelfOwnedReceiver(std::make_unique<ShareServiceImpl>(),
std::move(receiver));
}
void ShareServiceImpl::Share(const std::string& title,
const std::string& text,
const GURL& share_url,
std::vector<blink::mojom::SharedFilePtr> files,
ShareCallback callback) {
// TODO(crbug.com/1035527): Add implementation for WIN_OS
NOTIMPLEMENTED();
std::move(callback).Run(blink::mojom::ShareError::CANCELED);
}
// 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.
#ifndef CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_
#define CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_
#include <string>
#include <vector>
#include "third_party/blink/public/mojom/webshare/webshare.mojom.h"
class GURL;
namespace content {
class RenderFrameHost;
}
class ShareServiceImpl : public blink::mojom::ShareService {
public:
ShareServiceImpl();
ShareServiceImpl(const ShareServiceImpl&) = delete;
ShareServiceImpl& operator=(const ShareServiceImpl&) = delete;
~ShareServiceImpl() override;
static void Create(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::ShareService> receiver);
// blink::mojom::ShareService:
void Share(const std::string& title,
const std::string& text,
const GURL& share_url,
std::vector<blink::mojom::SharedFilePtr> files,
ShareCallback callback) override;
};
#endif // CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_
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