#include "base/pickle.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "content/common/clipboard_format.h"
#include "content/public/common/drop_data.h"
#include "content/renderer/clipboard_utils.h"
#include "content/renderer/drop_data_builder.h"
switch (format) {
case FormatPlainText:
- return client_->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(),
- clipboard_type) ||
- client_->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(),
- clipboard_type);
- case FormatHTML:
- return client_->IsFormatAvailable(ui::Clipboard::GetHtmlFormatType(),
+ return client_->IsFormatAvailable(CLIPBOARD_FORMAT_PLAINTEXT,
clipboard_type);
+ case FormatHTML:
+ return client_->IsFormatAvailable(CLIPBOARD_FORMAT_HTML, clipboard_type);
case FormatSmartPaste:
- return client_->IsFormatAvailable(
- ui::Clipboard::GetWebKitSmartPasteFormatType(), clipboard_type);
+ return client_->IsFormatAvailable(CLIPBOARD_FORMAT_SMART_PASTE,
+ clipboard_type);
case FormatBookmark:
-#if defined(OS_WIN) || defined(OS_MACOSX)
- return client_->IsFormatAvailable(ui::Clipboard::GetUrlWFormatType(),
+ return client_->IsFormatAvailable(CLIPBOARD_FORMAT_BOOKMARK,
clipboard_type);
-#endif
default:
NOTREACHED();
}
if (!ConvertBufferType(buffer, &clipboard_type))
return WebString();
- if (client_->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(),
- clipboard_type)) {
- base::string16 text;
- client_->ReadText(clipboard_type, &text);
- if (!text.empty())
- return text;
- }
-
- if (client_->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(),
- clipboard_type)) {
- std::string text;
- client_->ReadAsciiText(clipboard_type, &text);
- if (!text.empty())
- return base::ASCIIToUTF16(text);
- }
-
- return WebString();
+ base::string16 text;
+ client_->ReadText(clipboard_type, &text);
+ return text;
}
WebString WebClipboardImpl::readHTML(Buffer buffer, WebURL* source_url,
if (!image.isNull()) {
const SkBitmap& bitmap = image.getSkBitmap();
+ // WriteBitmapFromPixels expects 32-bit data.
+ DCHECK_EQ(bitmap.colorType(), kN32_SkColorType);
+
SkAutoLockPixels locked(bitmap);
- scw.WriteBitmapFromPixels(bitmap.getPixels(), image.size());
+ void *pixels = bitmap.getPixels();
+ // TODO(piman): this should not be NULL, but it is. crbug.com/369621
+ if (!pixels)
+ return;
+ scw.WriteBitmapFromPixels(pixels, image.size());
}
if (!url.isEmpty()) {
case BufferStandard:
break;
case BufferSelection:
-#if defined(USE_X11)
-#if defined(OS_CHROMEOS)
- // Chrome OS only supports the standard clipboard,
- // but not the X selection clipboad.
- return false;
-#else
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
*result = ui::CLIPBOARD_TYPE_SELECTION;
break;
-#endif
+#else
+ // Chrome OS and non-X11 unix builds do not support
+ // the X selection clipboad.
+ // TODO: remove the need for this case, see http://crbug.com/361753
+ return false;
#endif
default:
NOTREACHED();