summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2020-10-29 10:01:00 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-10-04 10:20:07 +0200
commit1eac89ea5801c663690ad55c258b603261114216 (patch)
tree2a626a6984f00770c6a26095d994e1825448be82
parent628e4f86facb88f5609091f0f17c8cd9461a6890 (diff)
downloadqtwebengine-chromium-1eac89ea5801c663690ad55c258b603261114216.tar.gz
Add minimal webrtcdesktopcapture api for hangout services extension
The hangout services extension is required for meet.google.com. The extension is only able to capture the primary screen without audio with this fix. Change-Id: Ic5563ebe4e0b8f1e8bfa83ca0830f180281a1f8c Fixes: QTBUG-85731 Task-number: QTBUG-51185 Task-number: QTBUG-61676 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--chromium/chrome/browser/extensions/api/BUILD.gn8
-rw-r--r--chromium/chrome/browser/resources/hangout_services/manifest.json10
-rw-r--r--chromium/chrome/browser/resources/hangout_services/thunk.js16
-rw-r--r--chromium/chrome/common/extensions/api/BUILD.gn5
-rw-r--r--chromium/chrome/common/extensions/api/api_sources.gni9
-rw-r--r--chromium/chrome/renderer/resources/extensions/webrtc_desktop_capture_private_custom_bindings.js4
-rw-r--r--chromium/extensions/browser/api/BUILD.gn6
-rw-r--r--chromium/extensions/browser/api/messaging/message_service.cc6
-rw-r--r--chromium/extensions/common/api/_webengine_api_features.json10
-rw-r--r--chromium/extensions/common/api/schema.gni5
-rw-r--r--chromium/qtwebengine/browser/extensions/api/BUILD.gn33
-rw-r--r--chromium/qtwebengine/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.cc196
-rw-r--r--chromium/qtwebengine/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.h120
-rw-r--r--chromium/qtwebengine/browser/qt_webengine_resources.grd3
-rw-r--r--chromium/qtwebengine/common/extensions/api/BUILD.gn41
-rw-r--r--chromium/qtwebengine/common/extensions/api/schema.gni9
-rw-r--r--chromium/qtwebengine/common/extensions/api/webrtc_desktop_capture_private.idl28
17 files changed, 487 insertions, 22 deletions
diff --git a/chromium/chrome/browser/extensions/api/BUILD.gn b/chromium/chrome/browser/extensions/api/BUILD.gn
index bbb51858520..f6d56c397cc 100644
--- a/chromium/chrome/browser/extensions/api/BUILD.gn
+++ b/chromium/chrome/browser/extensions/api/BUILD.gn
@@ -45,4 +45,12 @@ function_registration("api_registration") {
"//third_party/metrics_proto",
"//ui/accessibility:ax_enums_mojo",
]
+
+ if (use_qt) {
+ deps = [ ]
+ deps = [
+ "//extensions/common/api",
+ "//third_party/blink/public/mojom:mojom_platform",
+ ]
+ }
}
diff --git a/chromium/chrome/browser/resources/hangout_services/manifest.json b/chromium/chrome/browser/resources/hangout_services/manifest.json
index 556c6046a36..cf44bbbd649 100644
--- a/chromium/chrome/browser/resources/hangout_services/manifest.json
+++ b/chromium/chrome/browser/resources/hangout_services/manifest.json
@@ -18,12 +18,12 @@
},
"incognito": "split",
"permissions": [
- "desktopCapture",
+ //"desktopCapture",
"enterprise.hardwarePlatform",
- "processes",
+ //"processes",
"system.cpu",
- "webrtcAudioPrivate",
- "webrtcDesktopCapturePrivate",
- "webrtcLoggingPrivate"
+ //"webrtcAudioPrivate",
+ //"webrtcLoggingPrivate",
+ "webrtcDesktopCapturePrivate"
]
}
diff --git a/chromium/chrome/browser/resources/hangout_services/thunk.js b/chromium/chrome/browser/resources/hangout_services/thunk.js
index 40b5f380a08..9f75710b873 100644
--- a/chromium/chrome/browser/resources/hangout_services/thunk.js
+++ b/chromium/chrome/browser/resources/hangout_services/thunk.js
@@ -63,8 +63,9 @@ chrome.runtime.onMessageExternal.addListener(function(
requestInfo, origin, metaData, doSendResponse);
return true;
} else if (method == 'logging.start') {
- chrome.webrtcLoggingPrivate.start(requestInfo, origin, doSendResponse);
- return true;
+ //chrome.webrtcLoggingPrivate.start(requestInfo, origin, doSendResponse);
+ // Disable webrtc logging for QtWebEngine.
+ return false;
} else if (method == 'logging.uploadOnRenderClose') {
chrome.webrtcLoggingPrivate.setUploadOnRenderClose(
requestInfo, origin, true);
@@ -221,6 +222,7 @@ function onChooseDesktopMediaPort(port) {
port.onMessage.addListener(function(message) {
const method = message['method'];
if (method == 'chooseDesktopMedia') {
+ /*
const sources = message['sources'];
let cancelId = null;
const tab = port.sender.tab;
@@ -248,6 +250,14 @@ function onChooseDesktopMediaPort(port) {
chrome.webrtcDesktopCapturePrivate.cancelChooseDesktopMedia(cancelId);
}
});
+ */
+
+ // QtWebEngine
+ const requestInfo = {};
+ requestInfo['guestProcessId'] = port.sender.guestProcessId || 0;
+ requestInfo['guestRenderFrameId'] =
+ port.sender.guestRenderFrameRoutingId || 0;
+ chrome.webrtcDesktopCapturePrivate.chooseDesktopMedia(requestInfo, sendResponse);
}
});
}
@@ -294,10 +304,12 @@ function onProcessCpu(port) {
});
}
+ /*
chrome.processes.onUpdated.addListener(processListener);
port.onDisconnect.addListener(function() {
chrome.processes.onUpdated.removeListener(processListener);
});
+ */
}
function appendLastErrorMessage(errors) {
diff --git a/chromium/chrome/common/extensions/api/BUILD.gn b/chromium/chrome/common/extensions/api/BUILD.gn
index 55a98d7ce5f..502d5a06cb5 100644
--- a/chromium/chrome/common/extensions/api/BUILD.gn
+++ b/chromium/chrome/common/extensions/api/BUILD.gn
@@ -41,11 +41,14 @@ group("extensions_features") {
# Private Targets
generated_json_strings("generated_api_json_strings") {
+ sources = chrome_extensions_api_schema_sources +
+ chrome_extensions_api_uncompiled_sources
+
configs = [ "//build/config:precompiled_headers" ]
bundle_name = "Chrome"
schema_include_rules = chrome_extensions_api_schema_include_rules
- sources = [
+ sources += [
"app.json",
"commands.json",
"declarative_content.json",
diff --git a/chromium/chrome/common/extensions/api/api_sources.gni b/chromium/chrome/common/extensions/api/api_sources.gni
index 27fc40b18d3..91571a08d38 100644
--- a/chromium/chrome/common/extensions/api/api_sources.gni
+++ b/chromium/chrome/common/extensions/api/api_sources.gni
@@ -145,6 +145,15 @@ if (is_chromeos_ash) {
]
}
+if (use_qt) {
+ schema_sources_ = [ ]
+ schema_sources_ = [
+ "enterprise_hardware_platform.idl",
+ ]
+
+ uncompiled_sources_ = [ ]
+}
+
chrome_extensions_api_schema_sources = get_path_info(schema_sources_, "abspath")
chrome_extensions_manifest_only_schema_sources =
diff --git a/chromium/chrome/renderer/resources/extensions/webrtc_desktop_capture_private_custom_bindings.js b/chromium/chrome/renderer/resources/extensions/webrtc_desktop_capture_private_custom_bindings.js
index aff374d3f60..6b5aa047245 100644
--- a/chromium/chrome/renderer/resources/extensions/webrtc_desktop_capture_private_custom_bindings.js
+++ b/chromium/chrome/renderer/resources/extensions/webrtc_desktop_capture_private_custom_bindings.js
@@ -20,12 +20,12 @@ apiBridge.registerCustomHook(function(bindingsAPI) {
}
apiFunctions.setHandleRequest('chooseDesktopMedia',
- function(sources, request, callback) {
+ function(/* sources, */ request, callback) {
var id = idGenerator.GetNextId();
pendingRequests[id] = callback;
bindingUtil.sendRequest(
'webrtcDesktopCapturePrivate.chooseDesktopMedia',
- [id, sources, request, $Function.bind(onRequestResult, null, id)],
+ [id, /* sources, */ request, $Function.bind(onRequestResult, null, id)],
undefined);
return id;
});
diff --git a/chromium/extensions/browser/api/BUILD.gn b/chromium/extensions/browser/api/BUILD.gn
index 3d0a4e08374..9d27321c859 100644
--- a/chromium/extensions/browser/api/BUILD.gn
+++ b/chromium/extensions/browser/api/BUILD.gn
@@ -192,12 +192,6 @@ group("api_implementations") {
"//extensions/browser/api/bluetooth_low_energy",
"//extensions/browser/api/bluetooth_socket",
"//extensions/browser/api/feedback_private",
- "//extensions/browser/api/system_cpu",
- "//extensions/browser/api/system_display",
- "//extensions/browser/api/system_info",
- "//extensions/browser/api/system_memory",
- "//extensions/browser/api/system_network",
- "//extensions/browser/api/system_storage",
]
}
}
diff --git a/chromium/extensions/browser/api/messaging/message_service.cc b/chromium/extensions/browser/api/messaging/message_service.cc
index ee18931b184..977e8123834 100644
--- a/chromium/extensions/browser/api/messaging/message_service.cc
+++ b/chromium/extensions/browser/api/messaging/message_service.cc
@@ -321,12 +321,16 @@ void MessageService::OpenChannelToExtension(
source_frame_id =
ExtensionApiFrameIdMap::GetFrameId(source_render_frame_host);
} else {
+#if !defined(TOOLKIT_QT)
// Check to see if it was a WebView making the request.
// Sending messages from WebViews to extensions breaks webview isolation,
// so only allow component extensions to receive messages from WebViews.
bool is_web_view = !!WebViewGuest::FromWebContents(source_contents);
if (is_web_view &&
Manifest::IsComponentLocation(target_extension->location())) {
+#else
+ if (Manifest::IsComponentLocation(target_extension->location())) {
+#endif
include_guest_process_info = true;
}
}
@@ -590,8 +594,10 @@ void MessageService::OpenChannelImpl(BrowserContext* browser_context,
DCHECK(port_context.frame);
guest_render_frame_routing_id = port_context.frame->routing_id;
+#if !defined(TOOLKIT_QT)
DCHECK(WebViewGuest::FromWebContents(
WebContents::FromRenderFrameHost(source.GetRenderFrameHost())));
+#endif
}
// Send the connect event to the receiver. Give it the opener's port ID (the
diff --git a/chromium/extensions/common/api/_webengine_api_features.json b/chromium/extensions/common/api/_webengine_api_features.json
index 663ded442a7..c0ab2a6576b 100644
--- a/chromium/extensions/common/api/_webengine_api_features.json
+++ b/chromium/extensions/common/api/_webengine_api_features.json
@@ -23,5 +23,13 @@
"matches": [
"chrome://print/*"
]
- }]
+ }],
+ "enterprise.hardwarePlatform": {
+ "dependencies": ["permission:enterprise.hardwarePlatform"],
+ "contexts": ["blessed_extension"]
+ },
+ "webrtcDesktopCapturePrivate": {
+ "dependencies": ["permission:webrtcDesktopCapturePrivate"],
+ "contexts": ["blessed_extension"]
+ }
}
diff --git a/chromium/extensions/common/api/schema.gni b/chromium/extensions/common/api/schema.gni
index 68123e41fbe..f1cf8c794c3 100644
--- a/chromium/extensions/common/api/schema.gni
+++ b/chromium/extensions/common/api/schema.gni
@@ -86,11 +86,6 @@ if (use_qt) {
"bluetooth_private.idl",
"bluetooth_socket.idl",
"feedback_private.idl",
- "system_cpu.idl",
- "system_display.idl",
- "system_memory.idl",
- "system_network.idl",
- "system_storage.idl",
]
}
diff --git a/chromium/qtwebengine/browser/extensions/api/BUILD.gn b/chromium/qtwebengine/browser/extensions/api/BUILD.gn
new file mode 100644
index 00000000000..13baddb25af
--- /dev/null
+++ b/chromium/qtwebengine/browser/extensions/api/BUILD.gn
@@ -0,0 +1,33 @@
+import("//extensions/buildflags/buildflags.gni")
+import("//qtwebengine/common/extensions/api/schema.gni")
+import("//tools/json_schema_compiler/json_schema_api.gni")
+
+assert(enable_extensions,
+ "Cannot depend on extensions because enable_extensions=false.")
+
+source_set("webrtc_desktop_capture_private") {
+ sources = [
+ "webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.cc",
+ "webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.h",
+ ]
+
+ deps = [
+ "//content/public/browser",
+ ]
+}
+
+function_registration("api_registration") {
+ sources = webengine_extensions_api_schema_files
+
+ impl_dir = "//qtwebengine/browser/extensions/api"
+ bundle_name = "QtWebEngine"
+ root_namespace = webengine_extensions_api_root_namespace
+
+ deps = [
+ ":webrtc_desktop_capture_private",
+ "//extensions/common/api",
+
+ # Required due to generated mojom headers
+ "//skia"
+ ]
+}
diff --git a/chromium/qtwebengine/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.cc b/chromium/qtwebengine/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.cc
new file mode 100644
index 00000000000..9499437130b
--- /dev/null
+++ b/chromium/qtwebengine/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.cc
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// based on //chrome/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.cc
+// Copyright 2015 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 "qtwebengine/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.h"
+
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/desktop_media_id.h"
+#include "content/public/browser/desktop_streams_registry.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/media_stream_request.h"
+#include "content/public/common/origin_util.h"
+#include "extensions/browser/extension_host.h"
+#include "extensions/browser/process_manager.h"
+#include "qtwebengine/common/extensions/api/webrtc_desktop_capture_private.h"
+#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
+
+using extensions::api::webrtc_desktop_capture_private::Options;
+using extensions::api::webrtc_desktop_capture_private::ChooseDesktopMedia::Results::Create;
+
+namespace extensions {
+
+namespace {
+
+const char kTargetNotFoundError[] = "The specified target is not found.";
+
+} // namespace
+
+WebrtcDesktopCapturePrivateChooseDesktopMediaFunction::
+ WebrtcDesktopCapturePrivateChooseDesktopMediaFunction() {
+}
+
+WebrtcDesktopCapturePrivateChooseDesktopMediaFunction::
+ ~WebrtcDesktopCapturePrivateChooseDesktopMediaFunction() {
+}
+
+ExtensionFunction::ResponseAction
+WebrtcDesktopCapturePrivateChooseDesktopMediaFunction::Run() {
+ using Params =
+ extensions::api::webrtc_desktop_capture_private::ChooseDesktopMedia
+ ::Params;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetSize() > 0);
+
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &request_id_));
+ DesktopCaptureRequestsRegistry::GetInstance()->AddRequest(source_process_id(),
+ request_id_, this);
+
+ args_->Remove(0, NULL);
+
+ std::unique_ptr<Params> params = Params::Create(*args_);
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
+ params->request.guest_process_id,
+ params->request.guest_render_frame_id);
+
+ if (!rfh) {
+ return RespondNow(Error(kTargetNotFoundError));
+ }
+
+ GURL origin = rfh->GetLastCommittedURL().GetOrigin();
+ content::WebContents* web_contents =
+ content::WebContents::FromRenderFrameHost(rfh);
+ if (!web_contents) {
+ return RespondNow(Error(kTargetNotFoundError));
+ }
+
+ content::RenderFrameHost* const main_frame = web_contents->GetMainFrame();
+ content::MediaStreamRequest request(main_frame->GetProcess()->GetID() /* render_process_id */,
+ main_frame->GetRoutingID() /* render_frame_id */,
+ request_id_ /* page_request_id */,
+ origin /* security_origin */,
+ true /* user_gesture */,
+ blink::MediaStreamRequestType::MEDIA_DEVICE_ACCESS /* request_type */,
+ "" /* requested_audio_device_id */,
+ "" /* requested_video_device_id */,
+ blink::mojom::MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE /* audio_type */,
+ blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE /* video_type */,
+ true /* disable_local_echo */,
+ false /* request_pan_tilt_zoom_permission */);
+
+ extensions::ExtensionHost *host = extensions::ProcessManager::Get(browser_context())->GetBackgroundHostForExtension(extension_id());
+ host->RequestMediaAccessPermission(web_contents, request,
+ base::BindOnce(&WebrtcDesktopCapturePrivateChooseDesktopMediaFunction::ProcessAccessRequestResponse,
+ weak_factory_.GetWeakPtr(), main_frame, origin));
+
+ return RespondLater();
+}
+
+void WebrtcDesktopCapturePrivateChooseDesktopMediaFunction::ProcessAccessRequestResponse(
+ content::RenderFrameHost* const main_frame,
+ const GURL &origin,
+ const blink::MediaStreamDevices& devices,
+ blink::mojom::MediaStreamRequestResult stream_request_result,
+ std::unique_ptr<content::MediaStreamUI> stream_ui)
+{
+ if (stream_request_result != blink::mojom::MediaStreamRequestResult::OK) {
+ Respond(ArgumentList(Create(std::string(), Options())));
+ return;
+ }
+
+ DCHECK(!devices.empty());
+
+ content::DesktopMediaID source = content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, 0);
+ blink::MediaStreamDevices::const_iterator it = devices.begin();
+ for (; it != devices.end(); ++it) {
+ content::DesktopMediaID id = content::DesktopMediaID::Parse(it->id);
+ if (id.type == content::DesktopMediaID::TYPE_SCREEN) {
+ source = id;
+ break;
+ }
+ }
+
+ std::string result = content::DesktopStreamsRegistry::GetInstance()->RegisterStream(
+ main_frame->GetProcess()->GetID(), main_frame->GetRoutingID(),
+ url::Origin::Create(origin), source, extension()->name(),
+ content::kRegistryStreamTypeDesktop);
+
+ Options options;
+ options.can_request_audio_track = source.audio_share;
+ Respond(ArgumentList(Create(result, options)));
+}
+
+DesktopCaptureRequestsRegistry::RequestId::RequestId(int process_id,
+ int request_id)
+ : process_id(process_id), request_id(request_id) {}
+
+bool DesktopCaptureRequestsRegistry::RequestId::operator<(
+ const RequestId& other) const {
+ return std::tie(process_id, request_id) <
+ std::tie(other.process_id, other.request_id);
+}
+
+DesktopCaptureRequestsRegistry::DesktopCaptureRequestsRegistry() {}
+DesktopCaptureRequestsRegistry::~DesktopCaptureRequestsRegistry() {}
+
+// static
+DesktopCaptureRequestsRegistry* DesktopCaptureRequestsRegistry::GetInstance() {
+ return base::Singleton<DesktopCaptureRequestsRegistry>::get();
+}
+
+void DesktopCaptureRequestsRegistry::AddRequest(
+ int process_id,
+ int request_id,
+ WebrtcDesktopCapturePrivateChooseDesktopMediaFunction* handler) {
+ requests_.insert(
+ RequestsMap::value_type(RequestId(process_id, request_id), handler));
+}
+
+void DesktopCaptureRequestsRegistry::RemoveRequest(int process_id,
+ int request_id) {
+ requests_.erase(RequestId(process_id, request_id));
+}
+
+} // namespace extensions
diff --git a/chromium/qtwebengine/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.h b/chromium/qtwebengine/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.h
new file mode 100644
index 00000000000..f057d211939
--- /dev/null
+++ b/chromium/qtwebengine/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// based on //chrome/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.h
+// Copyright 2015 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 WEBENGINE_BROWSER_EXTENSIONS_API_WEBRTC_DESKTOP_CAPTURE_PRIVATE_WEBRTC_DESKTOP_CAPTURE_PRIVATE_API_H_
+#define WEBENGINE_BROWSER_EXTENSIONS_API_WEBRTC_DESKTOP_CAPTURE_PRIVATE_WEBRTC_DESKTOP_CAPTURE_PRIVATE_API_H_
+
+#include <map>
+
+#include "base/macros.h"
+#include "base/memory/singleton.h"
+#include "base/memory/weak_ptr.h"
+#include "content/public/browser/media_stream_request.h"
+#include "extensions/browser/extension_function.h"
+#include "third_party/blink/public/common/mediastream/media_stream_request.h"
+
+namespace content {
+class RenderFrameHost;
+}
+
+namespace extensions {
+
+class WebrtcDesktopCapturePrivateChooseDesktopMediaFunction : public ExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("webrtcDesktopCapturePrivate.chooseDesktopMedia",
+ WEBRTCDESKTOPCAPTUREPRIVATE_CHOOSEDESKTOPMEDIA)
+ WebrtcDesktopCapturePrivateChooseDesktopMediaFunction();
+
+ private:
+ ~WebrtcDesktopCapturePrivateChooseDesktopMediaFunction() override;
+ void ProcessAccessRequestResponse(
+ content::RenderFrameHost* const main_frame,
+ const GURL &origin,
+ const blink::MediaStreamDevices& devices,
+ blink::mojom::MediaStreamRequestResult stream_request_result,
+ std::unique_ptr<content::MediaStreamUI> stream_ui);
+
+ // ExtensionFunction overrides.
+ ResponseAction Run() override;
+
+ int request_id_;
+ base::WeakPtrFactory<WebrtcDesktopCapturePrivateChooseDesktopMediaFunction> weak_factory_{this};
+};
+
+class DesktopCaptureRequestsRegistry {
+ public:
+ DesktopCaptureRequestsRegistry();
+ ~DesktopCaptureRequestsRegistry();
+
+ static DesktopCaptureRequestsRegistry* GetInstance();
+
+ void AddRequest(int process_id,
+ int request_id,
+ WebrtcDesktopCapturePrivateChooseDesktopMediaFunction* handler);
+ void RemoveRequest(int process_id, int request_id);
+
+ private:
+ friend struct base::DefaultSingletonTraits<DesktopCaptureRequestsRegistry>;
+
+ struct RequestId {
+ RequestId(int process_id, int request_id);
+
+ // Need to use RequestId as a key in std::map<>.
+ bool operator<(const RequestId& other) const;
+
+ int process_id;
+ int request_id;
+ };
+
+ using RequestsMap =
+ std::map<RequestId, WebrtcDesktopCapturePrivateChooseDesktopMediaFunction*>;
+
+ RequestsMap requests_;
+
+ DISALLOW_COPY_AND_ASSIGN(DesktopCaptureRequestsRegistry);
+};
+
+} // namespace extensions
+
+#endif // WEBENGINE_BROWSER_EXTENSIONS_API_WEBRTC_DESKTOP_CAPTURE_PRIVATE_WEBRTC_DESKTOP_CAPTURE_PRIVATE_API_H_
diff --git a/chromium/qtwebengine/browser/qt_webengine_resources.grd b/chromium/qtwebengine/browser/qt_webengine_resources.grd
index 2369ec2c114..928a0969724 100644
--- a/chromium/qtwebengine/browser/qt_webengine_resources.grd
+++ b/chromium/qtwebengine/browser/qt_webengine_resources.grd
@@ -25,6 +25,9 @@
<include name="IDR_SANDBOX_INTERNALS_HTML" file="../../chrome/browser/resources/sandbox_internals/sandbox_internals.html" preprocess="true" type="BINDATA" />
<include name="IDR_SANDBOX_INTERNALS_JS" file="../../chrome/browser/resources/sandbox_internals/sandbox_internals_win.js" type="BINDATA" />
</if>
+ <if expr="enable_hangout_services_extension">
+ <include name="IDR_HANGOUT_SERVICES_MANIFEST" file="../../chrome/browser/resources/hangout_services/manifest.json" type="BINDATA" />
+ </if>
</includes>
</release>
</grit>
diff --git a/chromium/qtwebengine/common/extensions/api/BUILD.gn b/chromium/qtwebengine/common/extensions/api/BUILD.gn
new file mode 100644
index 00000000000..92bcdcd5ae8
--- /dev/null
+++ b/chromium/qtwebengine/common/extensions/api/BUILD.gn
@@ -0,0 +1,41 @@
+import("//extensions/buildflags/buildflags.gni")
+import("//tools/json_schema_compiler/json_features.gni")
+import("//tools/json_schema_compiler/json_schema_api.gni")
+import("//qtwebengine/common/extensions/api/schema.gni")
+
+assert(enable_extensions)
+
+################################################################################
+# Public Targets
+
+group("api") {
+ public_deps = [
+ ":generated_api_json_strings",
+ ":generated_api_types",
+ ]
+}
+
+################################################################################
+# Private Targets
+
+generated_json_strings("generated_api_json_strings") {
+ sources = webengine_extensions_api_schema_files
+
+ bundle_name = "QtWebEngine"
+ root_namespace = webengine_extensions_api_root_namespace
+
+ deps = [ "//extensions/common/api" ]
+
+ visibility = [ ":api" ]
+}
+
+generated_types("generated_api_types") {
+ sources = webengine_extensions_api_schema_files
+
+ root_namespace = webengine_extensions_api_root_namespace
+
+ deps = [ "//extensions/common/api" ]
+
+ visibility = [ ":api" ]
+}
+
diff --git a/chromium/qtwebengine/common/extensions/api/schema.gni b/chromium/qtwebengine/common/extensions/api/schema.gni
new file mode 100644
index 00000000000..95a335c591a
--- /dev/null
+++ b/chromium/qtwebengine/common/extensions/api/schema.gni
@@ -0,0 +1,9 @@
+webengine_extensions_api_schema_files_ = [
+ "webrtc_desktop_capture_private.idl",
+]
+
+webengine_extensions_api_schema_files =
+ get_path_info(webengine_extensions_api_schema_files_, "abspath")
+
+webengine_extensions_api_root_namespace = "extensions::api::%(namespace)s"
+
diff --git a/chromium/qtwebengine/common/extensions/api/webrtc_desktop_capture_private.idl b/chromium/qtwebengine/common/extensions/api/webrtc_desktop_capture_private.idl
new file mode 100644
index 00000000000..644bb2125ed
--- /dev/null
+++ b/chromium/qtwebengine/common/extensions/api/webrtc_desktop_capture_private.idl
@@ -0,0 +1,28 @@
+// based on //chrome/common/extensions/api/webrtc_desktop_capture_private.idl
+// Copyright 2015 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.
+
+// Use the <code>chrome.webrtcDesktopCapturePrivate</code> API to capture
+// desktop media requested from a WebView.
+namespace webrtcDesktopCapturePrivate {
+ dictionary RequestInfo {
+ // The guest process id for the requester.
+ long guestProcessId;
+
+ // The webview render frame id for the requester.
+ long guestRenderFrameId;
+ };
+
+ dictionary Options {
+ boolean canRequestAudioTrack;
+ };
+
+ callback chooseDesktopMediaCallback = void (DOMString streamId, Options options);
+
+ interface Functions {
+ // Selects primary screen for share explicitly.
+ static long chooseDesktopMedia(RequestInfo request,
+ chooseDesktopMediaCallback callback);
+ };
+};