chromium/third_party/blink/renderer/modules/clipboard/clipboard_promise.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/clipboard/clipboard_promise.h"

#include <memory>
#include <utility>

#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/single_thread_task_runner.h"
#include "mojo/public/cpp/base/big_buffer.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-blink.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_clipboard_unsanitized_formats.h"
#include "third_party/blink/renderer/core/clipboard/clipboard_mime_types.h"
#include "third_party/blink/renderer/core/clipboard/system_clipboard.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/editing/commands/clipboard_commands.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/modules/clipboard/clipboard.h"
#include "third_party/blink/renderer/modules/clipboard/clipboard_item.h"
#include "third_party/blink/renderer/modules/clipboard/clipboard_reader.h"
#include "third_party/blink/renderer/modules/clipboard/clipboard_writer.h"
#include "third_party/blink/renderer/modules/permissions/permission_utils.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/worker_pool.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "ui/base/clipboard/clipboard_constants.h"

// There are 2 clipboard permissions defined in the spec:
// * clipboard-read
// * clipboard-write
// See https://w3c.github.io/clipboard-apis/#clipboard-permissions
//
// These permissions map to these ContentSettings:
// * CLIPBOARD_READ_WRITE, for sanitized read, and unsanitized read/write.
// * CLIPBOARD_SANITIZED_WRITE, for sanitized write only.

namespace blink {

PermissionService;

// This class deals with all the Blob promises and executes the write
// operation after all the promises have been resolved.
class ClipboardPromise::BlobPromiseResolverFunction final
    : public ScriptFunction::Callable {};

// static
ScriptPromise<IDLSequence<ClipboardItem>> ClipboardPromise::CreateForRead(
    ExecutionContext* context,
    ScriptState* script_state,
    ClipboardUnsanitizedFormats* formats,
    ExceptionState& exception_state) {}

// static
ScriptPromise<IDLString> ClipboardPromise::CreateForReadText(
    ExecutionContext* context,
    ScriptState* script_state,
    ExceptionState& exception_state) {}

// static
ScriptPromise<IDLUndefined> ClipboardPromise::CreateForWrite(
    ExecutionContext* context,
    ScriptState* script_state,
    const HeapVector<Member<ClipboardItem>>& items,
    ExceptionState& exception_state) {}

// static
ScriptPromise<IDLUndefined> ClipboardPromise::CreateForWriteText(
    ExecutionContext* context,
    ScriptState* script_state,
    const String& data,
    ExceptionState& exception_state) {}

ClipboardPromise::ClipboardPromise(ExecutionContext* context,
                                   ScriptPromiseResolverBase* resolver,
                                   ExceptionState& exception_state)
    :{}

ClipboardPromise::~ClipboardPromise() = default;

void ClipboardPromise::CompleteWriteRepresentation() {}

void ClipboardPromise::WriteNextRepresentation() {}

void ClipboardPromise::RejectFromReadOrDecodeFailure() {}

void ClipboardPromise::HandleRead(ClipboardUnsanitizedFormats* formats) {}

void ClipboardPromise::HandleReadText() {}

void ClipboardPromise::HandleWrite(
    const HeapVector<Member<ClipboardItem>>& clipboard_items) {}

void ClipboardPromise::HandleWriteText(const String& data) {}

void ClipboardPromise::HandleReadWithPermission(
    mojom::blink::PermissionStatus status) {}

void ClipboardPromise::ResolveRead() {}

void ClipboardPromise::OnReadAvailableFormatNames(
    const Vector<String>& format_names) {}

void ClipboardPromise::ReadNextRepresentation() {}

void ClipboardPromise::OnRead(Blob* blob) {}

void ClipboardPromise::HandleReadTextWithPermission(
    mojom::blink::PermissionStatus status) {}

void ClipboardPromise::HandlePromiseBlobsWrite(
    HeapVector<Member<Blob>>* blob_list) {}

void ClipboardPromise::WriteBlobs(HeapVector<Member<Blob>>* blob_list) {}

void ClipboardPromise::HandleWriteWithPermission(
    mojom::blink::PermissionStatus status) {}

void ClipboardPromise::HandleWriteTextWithPermission(
    mojom::blink::PermissionStatus status) {}

void ClipboardPromise::RejectBlobPromise(const String& exception_text) {}

PermissionService* ClipboardPromise::GetPermissionService() {}

void ClipboardPromise::ValidatePreconditions(
    mojom::blink::PermissionName permission,
    bool will_be_sanitized,
    base::OnceCallback<void(mojom::blink::PermissionStatus)> callback) {}

LocalFrame* ClipboardPromise::GetLocalFrame() const {}

ScriptState* ClipboardPromise::GetScriptState() const {}

scoped_refptr<base::SingleThreadTaskRunner>
ClipboardPromise::GetClipboardTaskRunner() {}

// ExecutionContextLifecycleObserver implementation.
void ClipboardPromise::ContextDestroyed() {}

void ClipboardPromise::Trace(Visitor* visitor) const {}

}  // namespace blink