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

Unified Diff: webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc

Issue 6724010: Pepper/Flapper: Add IsFormatAvailable() to PPB_Flash_Clipboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« no previous file with comments | « webkit/glue/webclipboard_impl.cc ('k') | webkit/tools/test_shell/mock_webclipboard_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc
index 630a897a0db581bb7e275fcce6ee5e9a20e62b12..c0b32733b4d3bb51b84d61b000dc5ff5a8b1323d 100644
--- a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc
@@ -16,6 +16,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/plugins/ppapi/var.h"
@@ -42,6 +43,39 @@ WebKit::WebClipboard::Buffer ConvertClipboardType(
}
}
+WebKit::WebClipboard::Format ConvertClipboardFormat(
+ PP_Flash_Clipboard_Format format) {
+ switch (format) {
+ case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT:
+ return WebKit::WebClipboard::FormatPlainText;
+ case PP_FLASH_CLIPBOARD_FORMAT_HTML:
+ return WebKit::WebClipboard::FormatHTML;
+ case PP_FLASH_CLIPBOARD_FORMAT_INVALID:
+ default:
+ NOTREACHED();
+ return WebKit::WebClipboard::FormatPlainText; // Gotta return something.
+ }
+}
+
+PP_Bool IsFormatAvailable(PP_Instance instance_id,
+ PP_Flash_Clipboard_Type clipboard_type,
+ PP_Flash_Clipboard_Format format) {
+ // If you don't give us an instance, we don't give you anything.
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return PP_FALSE;
+
+ WebKit::WebClipboard* web_clipboard = WebKit::webKitClient()->clipboard();
+ if (!web_clipboard) {
+ NOTREACHED();
+ return PP_FALSE;
+ }
+
+ return BoolToPPBool(
+ web_clipboard->isFormatAvailable(ConvertClipboardFormat(format),
+ ConvertClipboardType(clipboard_type)));
+}
+
PP_Var ReadPlainText(PP_Instance instance_id,
PP_Flash_Clipboard_Type clipboard_type) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
@@ -86,6 +120,7 @@ int32_t WritePlainText(PP_Instance instance_id,
}
const PPB_Flash_Clipboard ppb_flash_clipboard = {
+ &IsFormatAvailable,
&ReadPlainText,
&WritePlainText,
};
« no previous file with comments | « webkit/glue/webclipboard_impl.cc ('k') | webkit/tools/test_shell/mock_webclipboard_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698