0
Files
src/content/renderer/webclipboard_impl.h
dcheng 112adc89f9 Reland rewrite clipboard write IPC handling to be easier to understand.
The original implementation sent clipboard data to be written over IPC
as a map of clipboard formats to 'parameters' for that format. The
parameters were just vectors of byte vectors. Needless to say, this
logic was complicated, fragile, and prone to bugs. In the browser
process, this resulted in the IPC validation logic being scattered
between ClipboardMessageFilter and Clipboard::DispatchObject.

The rewrite adds an IPC message for each flavor of data that the
renderer is allowed to write to the clipboard. On the browser side,
the logic is simply delegated to ScopedClipboardWriter. Since the
clipboard object map is no longer under the control of an untrusted
process, this allows the removal of a lot of validation logic.
Unfortunately, bitmap handling is still a bit complicated because it's
sent over shared memory, but all the validation logic has been moved
into ClipboardMessageFilter.

BUG=319285
TBR=avi@chromium.org,jamesr@chromium.org,wfh@chromium.org

Review URL: https://codereview.chromium.org/740763003

Cr-Commit-Position: refs/heads/master@{#304988}
2014-11-20 07:17:08 +00:00

57 lines
1.8 KiB
C++

// Copyright (c) 2013 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 CONTENT_RENDERER_WEBCLIPBOARD_IMPL_H_
#define CONTENT_RENDERER_WEBCLIPBOARD_IMPL_H_
#include "base/compiler_specific.h"
#include "third_party/WebKit/public/platform/WebClipboard.h"
#include "ui/base/clipboard/clipboard.h"
#include <string>
namespace content {
class RendererClipboardDelegate;
class WebClipboardImpl : public blink::WebClipboard {
public:
explicit WebClipboardImpl(RendererClipboardDelegate* delegate);
virtual ~WebClipboardImpl();
// WebClipboard methods:
virtual uint64 sequenceNumber(Buffer buffer);
virtual bool isFormatAvailable(Format format, Buffer buffer);
virtual blink::WebVector<blink::WebString> readAvailableTypes(
Buffer buffer, bool* contains_filenames);
virtual blink::WebString readPlainText(Buffer buffer);
virtual blink::WebString readHTML(
Buffer buffer,
blink::WebURL* source_url,
unsigned* fragment_start,
unsigned* fragment_end);
virtual blink::WebData readImage(Buffer buffer);
virtual blink::WebString readCustomData(
Buffer buffer, const blink::WebString& type);
virtual void writePlainText(const blink::WebString& plain_text);
virtual void writeHTML(
const blink::WebString& html_text,
const blink::WebURL& source_url,
const blink::WebString& plain_text,
bool write_smart_paste);
virtual void writeImage(
const blink::WebImage& image,
const blink::WebURL& source_url,
const blink::WebString& title);
virtual void writeDataObject(const blink::WebDragData& data);
private:
bool ConvertBufferType(Buffer, ui::ClipboardType*);
RendererClipboardDelegate* const delegate_;
};
} // namespace content
#endif // CONTENT_RENDERER_WEBCLIPBOARD_IMPL_H_