1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
|
/*
* Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "WebPlatformStrategies.h"
#include "BlobRegistryProxy.h"
#include "BlockingResponseMap.h"
#include "HangDetectionDisabler.h"
#include "NetworkConnectionToWebProcessMessages.h"
#include "NetworkProcessConnection.h"
#include "NetworkResourceLoadParameters.h"
#include "SharedBufferReference.h"
#include "WebErrors.h"
#include "WebFrame.h"
#include "WebLoaderStrategy.h"
#include "WebLocalFrameLoaderClient.h"
#include "WebMediaStrategy.h"
#include "WebPage.h"
#include "WebPasteboardOverrides.h"
#include "WebPasteboardProxyMessages.h"
#include "WebProcess.h"
#include "WebProcessProxyMessages.h"
#include <WebCore/AudioDestination.h>
#include <WebCore/Color.h>
#include <WebCore/Document.h>
#include <WebCore/DocumentLoader.h>
#include <WebCore/LoaderStrategy.h>
#include <WebCore/LocalFrame.h>
#include <WebCore/MediaStrategy.h>
#include <WebCore/NetworkStorageSession.h>
#include <WebCore/Page.h>
#include <WebCore/PageGroup.h>
#include <WebCore/PagePasteboardContext.h>
#include <WebCore/PasteboardItemInfo.h>
#include <WebCore/PlatformPasteboard.h>
#include <WebCore/ProgressTracker.h>
#include <WebCore/ResourceError.h>
#include <WebCore/SameSiteInfo.h>
#include <WebCore/StorageNamespace.h>
#include <WebCore/SubframeLoader.h>
#include <wtf/Atomics.h>
#include <wtf/URL.h>
#if PLATFORM(GTK)
#include <WebCore/SelectionData.h>
#endif
namespace WebKit {
using namespace WebCore;
class RemoteAudioDestination;
void WebPlatformStrategies::initialize()
{
static NeverDestroyed<WebPlatformStrategies> platformStrategies;
setPlatformStrategies(&platformStrategies.get());
}
WebPlatformStrategies::WebPlatformStrategies()
{
}
LoaderStrategy* WebPlatformStrategies::createLoaderStrategy()
{
return &WebProcess::singleton().webLoaderStrategy();
}
PasteboardStrategy* WebPlatformStrategies::createPasteboardStrategy()
{
return this;
}
MediaStrategy* WebPlatformStrategies::createMediaStrategy()
{
return new WebMediaStrategy;
}
BlobRegistry* WebPlatformStrategies::createBlobRegistry()
{
return new BlobRegistryProxy;
}
#if ENABLE(DECLARATIVE_WEB_PUSH)
PushStrategy* WebPlatformStrategies::createPushStrategy()
{
return this;
}
#endif
static std::optional<WebPageProxyIdentifier> pageIdentifier(const PasteboardContext* context)
{
auto* pageContext = dynamicDowncast<PagePasteboardContext>(context);
if (!pageContext)
return std::nullopt;
auto pageID = pageContext->pageID();
if (!pageID)
return std::nullopt;
RefPtr webPage = WebProcess::singleton().webPage(*pageID);
if (!webPage)
return std::nullopt;
return webPage->webPageProxyIdentifier();
}
#if PLATFORM(COCOA)
// PasteboardStrategy
void WebPlatformStrategies::getTypes(Vector<String>& types, const String& pasteboardName, const PasteboardContext* context)
{
// First check the overrides.
// The purpose of the overrides is to avoid messaging back to the UI process.
// Therefore, if there are any overridden types, we return just those.
types = WebPasteboardOverrides::sharedPasteboardOverrides().overriddenTypes(pasteboardName);
if (!types.isEmpty())
return;
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardTypes(pasteboardName, pageIdentifier(context)), 0);
if (sendResult.succeeded())
std::tie(types) = sendResult.takeReply();
}
RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::bufferForType(const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
{
// First check the overrides.
Vector<uint8_t> overrideBuffer;
if (WebPasteboardOverrides::sharedPasteboardOverrides().getDataForOverride(pasteboardName, pasteboardType, overrideBuffer))
return SharedBuffer::create(WTFMove(overrideBuffer));
// Fallback to messaging the UI process for native pasteboard content.
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardBufferForType(pasteboardName, pasteboardType, pageIdentifier(context)), 0);
auto [pasteboardBuffer] = sendResult.takeReplyOr(WebCore::PasteboardBuffer { });
return Pasteboard::bufferConvertedToPasteboardType(pasteboardBuffer, pasteboardType);
}
void WebPlatformStrategies::getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
{
Vector<SandboxExtension::Handle> sandboxExtensionsHandleArray;
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardPathnamesForType(pasteboardName, pasteboardType, pageIdentifier(context)), 0);
if (sendResult.succeeded())
std::tie(pathnames, sandboxExtensionsHandleArray) = sendResult.takeReply();
ASSERT(pathnames.size() == sandboxExtensionsHandleArray.size());
SandboxExtension::consumePermanently(sandboxExtensionsHandleArray);
}
String WebPlatformStrategies::stringForType(const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardStringForType(pasteboardName, pasteboardType, pageIdentifier(context)), 0);
auto [value] = sendResult.takeReplyOr(String { });
return value;
}
Vector<String> WebPlatformStrategies::allStringsForType(const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardStringsForType(pasteboardName, pasteboardType, pageIdentifier(context)), 0);
auto [values] = sendResult.takeReplyOr(Vector<String> { });
return values;
}
int64_t WebPlatformStrategies::changeCount(const String& pasteboardName, const PasteboardContext* context)
{
WebProcess::singleton().waitForPendingPasteboardWritesToFinish(pasteboardName);
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardChangeCount(pasteboardName, pageIdentifier(context)), 0);
auto [changeCount] = sendResult.takeReplyOr(0);
return changeCount;
}
Color WebPlatformStrategies::color(const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardColor(pasteboardName, pageIdentifier(context)), 0);
auto [color] = sendResult.takeReplyOr(Color { });
return color;
}
URL WebPlatformStrategies::url(const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardURL(pasteboardName, pageIdentifier(context)), 0);
auto [urlString] = sendResult.takeReplyOr(String { });
return URL({ }, urlString);
}
int64_t WebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::AddPasteboardTypes(pasteboardName, pasteboardTypes, pageIdentifier(context)), 0);
auto [newChangeCount] = sendResult.takeReplyOr(0);
return newChangeCount;
}
int64_t WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardTypes(pasteboardName, pasteboardTypes, pageIdentifier(context)), 0);
auto [newChangeCount] = sendResult.takeReplyOr(0);
return newChangeCount;
}
int64_t WebPlatformStrategies::setBufferForType(SharedBuffer* buffer, const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
{
// FIXME: Null check prevents crashing, but it is not great that we will have empty pasteboard content for this type,
// because we've already set the types.
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardBufferForType(pasteboardName, pasteboardType, buffer ? RefPtr { buffer } : SharedBuffer::create(), pageIdentifier(context)), 0);
auto [newChangeCount] = sendResult.takeReplyOr(0);
return newChangeCount;
}
int64_t WebPlatformStrategies::setURL(const PasteboardURL& pasteboardURL, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardURL(pasteboardURL, pasteboardName, pageIdentifier(context)), 0);
auto [newChangeCount] = sendResult.takeReplyOr(0);
return newChangeCount;
}
int64_t WebPlatformStrategies::setColor(const Color& color, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardColor(pasteboardName, color, pageIdentifier(context)), 0);
auto [newChangeCount] = sendResult.takeReplyOr(0);
return newChangeCount;
}
int64_t WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardStringForType(pasteboardName, pasteboardType, string, pageIdentifier(context)), 0);
auto [newChangeCount] = sendResult.takeReplyOr(0);
return newChangeCount;
}
int WebPlatformStrategies::getNumberOfFiles(const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetNumberOfFiles(pasteboardName, pageIdentifier(context)), 0);
auto [numberOfFiles] = sendResult.takeReplyOr(0);
return numberOfFiles;
}
bool WebPlatformStrategies::containsURLStringSuitableForLoading(const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ContainsURLStringSuitableForLoading(pasteboardName, pageIdentifier(context)), 0);
auto [result] = sendResult.takeReplyOr(false);
return result;
}
String WebPlatformStrategies::urlStringSuitableForLoading(const String& pasteboardName, String& title, const PasteboardContext* context)
{
String url;
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::URLStringSuitableForLoading(pasteboardName, pageIdentifier(context)), 0);
if (sendResult.succeeded())
std::tie(url, title) = sendResult.takeReply();
return url;
}
#if PLATFORM(IOS_FAMILY)
void WebPlatformStrategies::writeToPasteboard(const PasteboardURL& url, const String& pasteboardName, const PasteboardContext* context)
{
WebProcess::singleton().willWriteToPasteboardAsynchronously(pasteboardName);
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteURLToPasteboard(url, pasteboardName, pageIdentifier(context)), 0);
}
void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardWebContent& content, const String& pasteboardName, const PasteboardContext* context)
{
WebProcess::singleton().willWriteToPasteboardAsynchronously(pasteboardName);
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteWebContentToPasteboard(content, pasteboardName, pageIdentifier(context)), 0);
}
void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardImage& image, const String& pasteboardName, const PasteboardContext* context)
{
WebProcess::singleton().willWriteToPasteboardAsynchronously(pasteboardName);
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteImageToPasteboard(image, pasteboardName, pageIdentifier(context)), 0);
}
void WebPlatformStrategies::writeToPasteboard(const String& pasteboardType, const String& text, const String& pasteboardName, const PasteboardContext* context)
{
WebProcess::singleton().willWriteToPasteboardAsynchronously(pasteboardName);
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteStringToPasteboard(pasteboardType, text, pasteboardName, pageIdentifier(context)), 0);
}
void WebPlatformStrategies::updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName, const PasteboardContext* context)
{
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::UpdateSupportedTypeIdentifiers(identifiers, pasteboardName, pageIdentifier(context)), 0);
}
#endif // PLATFORM(IOS_FAMILY)
#endif // PLATFORM(COCOA)
#if PLATFORM(GTK)
// PasteboardStrategy
Vector<String> WebPlatformStrategies::types(const String& pasteboardName)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetTypes(pasteboardName), 0);
auto [result] = sendResult.takeReplyOr(Vector<String> { });
return result;
}
String WebPlatformStrategies::readTextFromClipboard(const String& pasteboardName)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadText(pasteboardName), 0);
auto [result] = sendResult.takeReplyOr(String { });
return result;
}
Vector<String> WebPlatformStrategies::readFilePathsFromClipboard(const String& pasteboardName)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadFilePaths(pasteboardName), 0);
auto [result] = sendResult.takeReplyOr(Vector<String> { });
return result;
}
RefPtr<SharedBuffer> WebPlatformStrategies::readBufferFromClipboard(const String& pasteboardName, const String& pasteboardType)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBuffer(pasteboardName, pasteboardType), 0);
auto [buffer] = sendResult.takeReplyOr(nullptr);
return buffer;
}
void WebPlatformStrategies::writeToClipboard(const String& pasteboardName, SelectionData&& selectionData)
{
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteToClipboard(pasteboardName, WTFMove(selectionData)), 0);
}
void WebPlatformStrategies::clearClipboard(const String& pasteboardName)
{
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::ClearClipboard(pasteboardName), 0);
}
int64_t WebPlatformStrategies::changeCount(const String& pasteboardName)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardChangeCount(pasteboardName), 0);
auto [changeCount] = sendResult.takeReplyOr(0);
return changeCount;
}
#endif // PLATFORM(GTK)
#if USE(LIBWPE)
// PasteboardStrategy
void WebPlatformStrategies::getTypes(Vector<String>& types)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardTypes(), 0);
if (sendResult.succeeded())
std::tie(types) = sendResult.takeReply();
}
void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardWebContent& content)
{
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteWebContentToPasteboard(content), 0);
}
void WebPlatformStrategies::writeToPasteboard(const String& pasteboardType, const String& text)
{
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteStringToPasteboard(pasteboardType, text), 0);
}
#endif // USE(LIBWPE)
Vector<String> WebPlatformStrategies::typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::TypesSafeForDOMToReadAndWrite(pasteboardName, origin, pageIdentifier(context)), 0);
auto [types] = sendResult.takeReplyOr(Vector<String> { });
return types;
}
int64_t WebPlatformStrategies::writeCustomData(const Vector<PasteboardCustomData>& data, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::WriteCustomData(data, pasteboardName, pageIdentifier(context)), 0);
auto [newChangeCount] = sendResult.takeReplyOr(0);
return newChangeCount;
}
bool WebPlatformStrategies::containsStringSafeForDOMToReadForType(const String& type, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ContainsStringSafeForDOMToReadForType(type, pasteboardName, pageIdentifier(context)), 0);
auto [result] = sendResult.takeReplyOr(false);
return result;
}
int WebPlatformStrategies::getPasteboardItemsCount(const String& pasteboardName, const PasteboardContext* context)
{
if (!WebPasteboardOverrides::sharedPasteboardOverrides().overriddenTypes(pasteboardName).isEmpty()) {
// Override pasteboards currently only support single pasteboard items.
return 1;
}
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardItemsCount(pasteboardName, pageIdentifier(context)), 0);
auto [itemsCount] = sendResult.takeReplyOr(0);
return itemsCount;
}
std::optional<Vector<PasteboardItemInfo>> WebPlatformStrategies::allPasteboardItemInfo(const String& pasteboardName, int64_t changeCount, const PasteboardContext* context)
{
if (auto info = WebPasteboardOverrides::sharedPasteboardOverrides().overriddenInfo(pasteboardName))
return { { WTFMove(*info) } };
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::AllPasteboardItemInfo(pasteboardName, changeCount, pageIdentifier(context)), 0);
auto [allInfo] = sendResult.takeReplyOr(std::nullopt);
return allInfo;
}
std::optional<PasteboardItemInfo> WebPlatformStrategies::informationForItemAtIndex(size_t index, const String& pasteboardName, int64_t changeCount, const PasteboardContext* context)
{
if (auto info = WebPasteboardOverrides::sharedPasteboardOverrides().overriddenInfo(pasteboardName))
return info;
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::InformationForItemAtIndex(index, pasteboardName, changeCount, pageIdentifier(context)), 0);
auto [info] = sendResult.takeReplyOr(std::nullopt);
return info;
}
RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(std::optional<size_t> index, const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
{
Vector<uint8_t> overrideBuffer;
if (WebPasteboardOverrides::sharedPasteboardOverrides().getDataForOverride(pasteboardName, pasteboardType, overrideBuffer))
return SharedBuffer::create(WTFMove(overrideBuffer));
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBufferFromPasteboard(index, pasteboardType, pasteboardName, pageIdentifier(context)), 0);
auto [buffer] = sendResult.takeReplyOr(nullptr);
return buffer;
}
URL WebPlatformStrategies::readURLFromPasteboard(size_t index, const String& pasteboardName, String& title, const PasteboardContext* context)
{
String urlString;
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadURLFromPasteboard(index, pasteboardName, pageIdentifier(context)), 0);
if (sendResult.succeeded())
std::tie(urlString, title) = sendResult.takeReply();
return URL({ }, urlString);
}
String WebPlatformStrategies::readStringFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
{
auto sendResult = WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadStringFromPasteboard(index, pasteboardType, pasteboardName, pageIdentifier(context)), 0);
auto [value] = sendResult.takeReplyOr(String { });
return value;
}
#if ENABLE(DECLARATIVE_WEB_PUSH)
void WebPlatformStrategies::windowSubscribeToPushService(const URL& scope, const Vector<uint8_t>& applicationServerKey, SubscribeToPushServiceCallback&& callback)
{
auto completionHandler = [callback = WTFMove(callback)](auto&& valueOrException) mutable {
if (!valueOrException.has_value()) {
callback(valueOrException.error().toException());
return;
}
callback(WTFMove(*valueOrException));
};
WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::NavigatorSubscribeToPushService(scope, applicationServerKey), WTFMove(completionHandler));
}
void WebPlatformStrategies::windowUnsubscribeFromPushService(const URL& scope, std::optional<PushSubscriptionIdentifier> subscriptionIdentifier, UnsubscribeFromPushServiceCallback&& callback)
{
auto completionHandler = [callback = WTFMove(callback)](auto&& valueOrException) mutable {
if (!valueOrException.has_value()) {
callback(valueOrException.error().toException());
return;
}
callback(WTFMove(*valueOrException));
};
WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::NavigatorUnsubscribeFromPushService(scope, *subscriptionIdentifier), WTFMove(completionHandler));
}
void WebPlatformStrategies::windowGetPushSubscription(const URL& scope, GetPushSubscriptionCallback&& callback)
{
auto completionHandler = [callback = WTFMove(callback)](auto&& valueOrException) mutable {
if (!valueOrException.has_value()) {
callback(valueOrException.error().toException());
return;
}
callback(WTFMove(*valueOrException));
};
WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::NavigatorGetPushSubscription(scope), WTFMove(completionHandler));
}
void WebPlatformStrategies::windowGetPushPermissionState(const URL& scope, GetPushPermissionStateCallback&& callback)
{
auto completionHandler = [callback = WTFMove(callback)](auto&& valueOrException) mutable {
if (!valueOrException.has_value())
return callback(valueOrException.error().toException());
callback(static_cast<PushPermissionState>(*valueOrException));
};
WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::NavigatorGetPushPermissionState(scope), WTFMove(completionHandler));
}
#endif // ENABLE(DECLARATIVE_WEB_PUSH)
} // namespace WebKit
|