diff options
author | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-02 22:10:05 +0000 |
---|---|---|
committer | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-02 22:10:05 +0000 |
commit | 4dfb8f00b69ec3dde0660c4790a469df5596a3ab (patch) | |
tree | defc06b4fc11ced9c365bf502c5475bee4b3620a /webkit | |
parent | 28cc10a26ffaaf8ff7f4f2e05ab6d03926951167 (diff) | |
download | chromium_src-4dfb8f00b69ec3dde0660c4790a469df5596a3ab.zip chromium_src-4dfb8f00b69ec3dde0660c4790a469df5596a3ab.tar.gz chromium_src-4dfb8f00b69ec3dde0660c4790a469df5596a3ab.tar.bz2 |
Added RTF support to pepper API.
BUG=120435
TEST=out/Release/browser_tests --gtest_filter=*PPAPITest.*Clipboard*
Review URL: http://codereview.chromium.org/9921018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130223 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/clipboard_client.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc | 27 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_clipboard_impl.cc | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_clipboard_impl.h | 2 |
4 files changed, 34 insertions, 3 deletions
diff --git a/webkit/glue/clipboard_client.h b/webkit/glue/clipboard_client.h index a0ddec2..6c9856c 100644 --- a/webkit/glue/clipboard_client.h +++ b/webkit/glue/clipboard_client.h @@ -59,6 +59,9 @@ class ClipboardClient { GURL* url, uint32* fragment_start, uint32* fragment_end) = 0; + // Reads RTF from the clipboard, if available. + virtual void ReadRTF(ui::Clipboard::Buffer buffer, std::string* result) = 0; + // Reads and image from the clipboard, if available. virtual void ReadImage(ui::Clipboard::Buffer buffer, std::string* data) = 0; diff --git a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc index 7706144..fdebb2dd 100644 --- a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc @@ -12,7 +12,9 @@ #include "base/utf_string_conversions.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_flash_clipboard.h" +#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/var.h" +#include "ppapi/shared_impl/var_tracker.h" #include "webkit/glue/clipboard_client.h" #include "webkit/glue/scoped_clipboard_writer_glue.h" #include "webkit/plugins/ppapi/common.h" @@ -92,11 +94,13 @@ PP_Bool PPB_Flash_Clipboard_Impl::IsFormatAvailable( case PP_FLASH_CLIPBOARD_FORMAT_HTML: return BoolToPPBool(client_->IsFormatAvailable( ui::Clipboard::GetHtmlFormatType(), buffer_type)); + case PP_FLASH_CLIPBOARD_FORMAT_RTF: + return BoolToPPBool(client_->IsFormatAvailable( + ui::Clipboard::GetRtfFormatType(), buffer_type)); case PP_FLASH_CLIPBOARD_FORMAT_INVALID: break; } - NOTREACHED(); return PP_FALSE; } @@ -150,11 +154,16 @@ PP_Var PPB_Flash_Clipboard_Impl::ReadData( &fragment_end); return StringVar::StringToPPVar(UTF16ToUTF8(html_stdstr)); } + case PP_FLASH_CLIPBOARD_FORMAT_RTF: { + std::string result; + client_->ReadRTF(buffer_type, &result); + return ::ppapi::PpapiGlobals::Get()->GetVarTracker()-> + MakeArrayBufferPPVar(result.size(), result.data()); + } case PP_FLASH_CLIPBOARD_FORMAT_INVALID: break; } - NOTREACHED(); return PP_MakeUndefined(); } @@ -185,11 +194,23 @@ int32_t PPB_Flash_Clipboard_Impl::WriteDataItem( scw->WriteHTML(UTF8ToUTF16(text_string->value()), ""); return PP_OK; } + case PP_FLASH_CLIPBOARD_FORMAT_RTF: { + ::ppapi::ArrayBufferVar* rtf_data = + ::ppapi::ArrayBufferVar::FromPPVar(data); + if (!rtf_data) + return PP_ERROR_BADARGUMENT; + + if (rtf_data->ByteLength() > kMaxClipboardWriteSize) + return PP_ERROR_NOSPACE; + + scw->WriteRTF(std::string(static_cast<char*>(rtf_data->Map()), + rtf_data->ByteLength())); + return PP_OK; + } case PP_FLASH_CLIPBOARD_FORMAT_INVALID: break; } - NOTREACHED(); return PP_ERROR_BADARGUMENT; } diff --git a/webkit/tools/test_shell/simple_clipboard_impl.cc b/webkit/tools/test_shell/simple_clipboard_impl.cc index ec5a65c..06d6c8b 100644 --- a/webkit/tools/test_shell/simple_clipboard_impl.cc +++ b/webkit/tools/test_shell/simple_clipboard_impl.cc @@ -80,6 +80,11 @@ void SimpleClipboardClient::ReadHTML(ui::Clipboard::Buffer buffer, *url = GURL(url_str); } +void SimpleClipboardClient::ReadRTF(ui::Clipboard::Buffer buffer, + std::string* result) { + GetClipboard()->ReadRTF(buffer, result); +} + void SimpleClipboardClient::ReadImage(ui::Clipboard::Buffer buffer, std::string* data) { SkBitmap bitmap = GetClipboard()->ReadImage(buffer); diff --git a/webkit/tools/test_shell/simple_clipboard_impl.h b/webkit/tools/test_shell/simple_clipboard_impl.h index 389ec36..52571bf 100644 --- a/webkit/tools/test_shell/simple_clipboard_impl.h +++ b/webkit/tools/test_shell/simple_clipboard_impl.h @@ -28,6 +28,8 @@ class SimpleClipboardClient : public webkit_glue::ClipboardClient { virtual void ReadHTML(ui::Clipboard::Buffer buffer, string16* markup, GURL* url, uint32* fragment_start, uint32* fragment_end) OVERRIDE; + virtual void ReadRTF(ui::Clipboard::Buffer buffer, + std::string* result) OVERRIDE; virtual void ReadImage(ui::Clipboard::Buffer buffer, std::string* data) OVERRIDE; virtual void ReadCustomData(ui::Clipboard::Buffer buffer, |