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

Unified Diff: content/browser/renderer_host/clipboard_message_filter.cc

Issue 206133002: Remove FormatType usage from ClipboardHostMsg_IsFormatAvailable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Win/Mac typo Created 6 years, 9 months 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: content/browser/renderer_host/clipboard_message_filter.cc
diff --git a/content/browser/renderer_host/clipboard_message_filter.cc b/content/browser/renderer_host/clipboard_message_filter.cc
index e06852addb038a9a650d4e341c35225fa6d0edb3..4e6aa652f3faec96a32a1c7d297ed52fae5ce366 100644
--- a/content/browser/renderer_host/clipboard_message_filter.cc
+++ b/content/browser/renderer_host/clipboard_message_filter.cc
@@ -9,6 +9,7 @@
#include "base/location.h"
#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "content/common/clipboard_messages.h"
#include "content/public/browser/browser_context.h"
#include "ipc/ipc_message_macros.h"
@@ -98,7 +99,6 @@ bool ClipboardMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadAvailableTypes,
OnReadAvailableTypes)
IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadText, OnReadText)
- IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadAsciiText, OnReadAsciiText)
IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadHTML, OnReadHTML)
IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadRTF, OnReadRTF)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ClipboardHostMsg_ReadImage, OnReadImage)
@@ -181,11 +181,30 @@ void ClipboardMessageFilter::OnReadAvailableTypes(
GetClipboard()->ReadAvailableTypes(type, types, contains_filenames);
}
-void ClipboardMessageFilter::OnIsFormatAvailable(
- const ui::Clipboard::FormatType& format,
- ui::ClipboardType type,
- bool* result) {
- *result = GetClipboard()->IsFormatAvailable(format, type);
+void ClipboardMessageFilter::OnIsFormatAvailable(ClipboardFormat format,
+ ui::ClipboardType type,
+ bool* result) {
+ switch (format) {
+ case kClipboardFormatPlaintext:
+ *result = GetClipboard()->IsFormatAvailable(
+ ui::Clipboard::GetPlainTextWFormatType(), type) ||
+ GetClipboard()->IsFormatAvailable(
+ ui::Clipboard::GetPlainTextFormatType(), type);
+ break;
+ case kClipboardFormatHTML:
+ *result = GetClipboard()->IsFormatAvailable(
+ ui::Clipboard::GetHtmlFormatType(), type);
+ case kClipboardFormatSmartPaste:
+ *result = GetClipboard()->IsFormatAvailable(
+ ui::Clipboard::GetWebKitSmartPasteFormatType(), type);
+ case kClipboardFormatBookmark:
+#if defined(OS_WIN) || defined(OS_MACOSX)
+ *result = GetClipboard()->IsFormatAvailable(
+ ui::Clipboard::GetUrlWFormatType(), type);
+#else
+ *result = false;
+#endif
+ }
}
void ClipboardMessageFilter::OnClear(ui::ClipboardType type) {
@@ -194,12 +213,17 @@ void ClipboardMessageFilter::OnClear(ui::ClipboardType type) {
void ClipboardMessageFilter::OnReadText(ui::ClipboardType type,
base::string16* result) {
- GetClipboard()->ReadText(type, result);
-}
-
-void ClipboardMessageFilter::OnReadAsciiText(ui::ClipboardType type,
- std::string* result) {
- GetClipboard()->ReadAsciiText(type, result);
+ if (GetClipboard()->IsFormatAvailable(
+ ui::Clipboard::GetPlainTextWFormatType(), type)) {
+ GetClipboard()->ReadText(type, result);
+ } else if (GetClipboard()->IsFormatAvailable(
+ ui::Clipboard::GetPlainTextFormatType(), type)) {
+ std::string ascii;
+ GetClipboard()->ReadAsciiText(type, &ascii);
+ *result = base::ASCIIToUTF16(ascii);
+ } else {
+ result->clear();
+ }
}
void ClipboardMessageFilter::OnReadHTML(ui::ClipboardType type,

Powered by Google App Engine
This is Rietveld 408576698