Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: webkit/glue/webclipboard_impl.cc

Issue 8591030: Move clipboard-related webkit_glue embedder functions into a ClipboardClient interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/glue/webclipboard_impl.cc
diff --git a/webkit/glue/webclipboard_impl.cc b/webkit/glue/webclipboard_impl.cc
index 0cbecaf08c57a1b1b028d289bf148a6a6fcffe2c..60176be73f94045c896af3b30ff62294e084393d 100644
--- a/webkit/glue/webclipboard_impl.cc
+++ b/webkit/glue/webclipboard_impl.cc
@@ -60,6 +60,10 @@ std::string WebClipboardImpl::URLToImageMarkup(const WebURL& url,
return markup;
}
+WebClipboardImpl::WebClipboardImpl(ClipboardClient* client)
+ : client_(client) {
+}
+
WebClipboardImpl::~WebClipboardImpl() {
}
@@ -72,7 +76,7 @@ uint64 WebClipboardImpl::sequenceNumber(Buffer buffer) {
if (!ConvertBufferType(buffer, &buffer_type))
return 0;
- return ClipboardGetSequenceNumber(buffer_type);
+ return client_->GetSequenceNumber(buffer_type);
}
bool WebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) {
@@ -84,9 +88,9 @@ bool WebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) {
switch (format) {
case FormatPlainText:
- return ClipboardIsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(),
+ return client_->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(),
buffer_type) ||
- ClipboardIsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(),
+ client_->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(),
buffer_type);
case FormatHTML:
format_type = ui::Clipboard::GetHtmlFormatType();
@@ -104,7 +108,7 @@ bool WebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) {
return false;
}
- return ClipboardIsFormatAvailable(format_type, buffer_type);
+ return client_->IsFormatAvailable(format_type, buffer_type);
}
WebVector<WebString> WebClipboardImpl::readAvailableTypes(
@@ -112,7 +116,7 @@ WebVector<WebString> WebClipboardImpl::readAvailableTypes(
ui::Clipboard::Buffer buffer_type;
std::vector<string16> types;
if (ConvertBufferType(buffer, &buffer_type)) {
- ClipboardReadAvailableTypes(buffer_type, &types, contains_filenames);
+ client_->ReadAvailableTypes(buffer_type, &types, contains_filenames);
}
return types;
}
@@ -122,18 +126,18 @@ WebString WebClipboardImpl::readPlainText(Buffer buffer) {
if (!ConvertBufferType(buffer, &buffer_type))
return WebString();
- if (ClipboardIsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(),
+ if (client_->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(),
buffer_type)) {
string16 text;
- ClipboardReadText(buffer_type, &text);
+ client_->ReadText(buffer_type, &text);
if (!text.empty())
return text;
}
- if (ClipboardIsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(),
+ if (client_->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(),
buffer_type)) {
std::string text;
- ClipboardReadAsciiText(buffer_type, &text);
+ client_->ReadAsciiText(buffer_type, &text);
if (!text.empty())
return ASCIIToUTF16(text);
}
@@ -150,7 +154,7 @@ WebString WebClipboardImpl::readHTML(Buffer buffer, WebURL* source_url,
string16 html_stdstr;
GURL gurl;
- ClipboardReadHTML(buffer_type, &html_stdstr, &gurl,
+ client_->ReadHTML(buffer_type, &html_stdstr, &gurl,
static_cast<uint32*>(fragment_start),
static_cast<uint32*>(fragment_end));
*source_url = gurl;
@@ -163,14 +167,14 @@ WebData WebClipboardImpl::readImage(Buffer buffer) {
return WebData();
std::string png_data;
- ClipboardReadImage(buffer_type, &png_data);
+ client_->ReadImage(buffer_type, &png_data);
return WebData(png_data);
}
void WebClipboardImpl::writeHTML(
const WebString& html_text, const WebURL& source_url,
const WebString& plain_text, bool write_smart_paste) {
- ScopedClipboardWriterGlue scw(ClipboardGetClipboard());
+ ScopedClipboardWriterGlue scw(client_);
scw.WriteHTML(html_text, source_url.spec());
scw.WriteText(plain_text);
@@ -179,12 +183,12 @@ void WebClipboardImpl::writeHTML(
}
void WebClipboardImpl::writePlainText(const WebString& plain_text) {
- ScopedClipboardWriterGlue scw(ClipboardGetClipboard());
+ ScopedClipboardWriterGlue scw(client_);
scw.WriteText(plain_text);
}
void WebClipboardImpl::writeURL(const WebURL& url, const WebString& title) {
- ScopedClipboardWriterGlue scw(ClipboardGetClipboard());
+ ScopedClipboardWriterGlue scw(client_);
scw.WriteBookmark(title, url.spec());
scw.WriteHTML(UTF8ToUTF16(URLToMarkup(url, title)), "");
@@ -193,7 +197,7 @@ void WebClipboardImpl::writeURL(const WebURL& url, const WebString& title) {
void WebClipboardImpl::writeImage(
const WebImage& image, const WebURL& url, const WebString& title) {
- ScopedClipboardWriterGlue scw(ClipboardGetClipboard());
+ ScopedClipboardWriterGlue scw(client_);
if (!image.isNull()) {
#if WEBKIT_USING_SKIA

Powered by Google App Engine
This is Rietveld 408576698