| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
| 13 #include "ppapi/c/private/ppb_flash_clipboard.h" | 13 #include "ppapi/c/private/ppb_flash_clipboard.h" |
| 14 #include "ppapi/shared_impl/var.h" | 14 #include "ppapi/shared_impl/var.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebClipboard
.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebClipboard
.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatfo
rmSupport.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatfo
rmSupport.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 20 #include "webkit/plugins/ppapi/common.h" | 20 #include "webkit/plugins/ppapi/common.h" |
| 21 #include "webkit/plugins/ppapi/host_globals.h" | 21 #include "webkit/plugins/ppapi/host_globals.h" |
| 22 #include "webkit/plugins/ppapi/plugin_module.h" | |
| 23 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 24 | 23 |
| 25 using ppapi::StringVar; | 24 using ppapi::StringVar; |
| 26 | 25 |
| 27 namespace webkit { | 26 namespace webkit { |
| 28 namespace ppapi { | 27 namespace ppapi { |
| 29 | 28 |
| 30 namespace { | 29 namespace { |
| 31 | 30 |
| 32 const size_t kMaxClipboardWriteSize = 1000000; | 31 const size_t kMaxClipboardWriteSize = 1000000; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 PP_Instance instance, | 90 PP_Instance instance, |
| 92 PP_Flash_Clipboard_Type clipboard_type) { | 91 PP_Flash_Clipboard_Type clipboard_type) { |
| 93 WebKit::WebClipboard* web_clipboard = | 92 WebKit::WebClipboard* web_clipboard = |
| 94 WebKit::webKitPlatformSupport()->clipboard(); | 93 WebKit::webKitPlatformSupport()->clipboard(); |
| 95 if (!web_clipboard) { | 94 if (!web_clipboard) { |
| 96 NOTREACHED(); | 95 NOTREACHED(); |
| 97 return PP_MakeNull(); | 96 return PP_MakeNull(); |
| 98 } | 97 } |
| 99 WebKit::WebCString s = | 98 WebKit::WebCString s = |
| 100 web_clipboard->readPlainText(ConvertClipboardType(clipboard_type)).utf8(); | 99 web_clipboard->readPlainText(ConvertClipboardType(clipboard_type)).utf8(); |
| 101 return StringVar::StringToPPVar(instance_->module()->pp_module(), s); | 100 return StringVar::StringToPPVar(s); |
| 102 } | 101 } |
| 103 | 102 |
| 104 int32_t PPB_Flash_Clipboard_Impl::WritePlainText( | 103 int32_t PPB_Flash_Clipboard_Impl::WritePlainText( |
| 105 PP_Instance instance, | 104 PP_Instance instance, |
| 106 PP_Flash_Clipboard_Type clipboard_type, | 105 PP_Flash_Clipboard_Type clipboard_type, |
| 107 const PP_Var& text) { | 106 const PP_Var& text) { |
| 108 StringVar* text_string = StringVar::FromPPVar(text); | 107 StringVar* text_string = StringVar::FromPPVar(text); |
| 109 if (!text_string) | 108 if (!text_string) |
| 110 return PP_ERROR_BADARGUMENT; | 109 return PP_ERROR_BADARGUMENT; |
| 111 | 110 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 124 return PP_ERROR_FAILED; | 123 return PP_ERROR_FAILED; |
| 125 } | 124 } |
| 126 | 125 |
| 127 web_clipboard->writePlainText( | 126 web_clipboard->writePlainText( |
| 128 WebKit::WebCString(text_string->value()).utf16()); | 127 WebKit::WebCString(text_string->value()).utf16()); |
| 129 return PP_OK; | 128 return PP_OK; |
| 130 } | 129 } |
| 131 | 130 |
| 132 } // namespace ppapi | 131 } // namespace ppapi |
| 133 } // namespace webkit | 132 } // namespace webkit |
| OLD | NEW |