OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_FLASH_CLIPBOARD_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_FLASH_CLIPBOARD_HOST_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "ipc/ipc_message.h" |
| 13 #include "ppapi/host/host_message_context.h" |
| 14 #include "ppapi/host/resource_host.h" |
| 15 #include "ppapi/shared_impl/flash_clipboard_format_registry.h" |
| 16 |
| 17 namespace webkit_glue { |
| 18 class ClipboardClient; |
| 19 class ScopedClipboardWriterGlue; |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 |
| 24 class RendererPpapiHost; |
| 25 |
| 26 // The host resource for accessing the clipboard in Pepper. Pepper supports |
| 27 // reading/writing custom formats from the clipboard. Currently, all custom |
| 28 // formats that are read/written from the clipboard through pepper are stored |
| 29 // in a single real clipboard format (in the same way the "web custom" clipboard |
| 30 // formats are). This is done so that we don't have to have use real clipboard |
| 31 // types for each custom clipboard format which may be a limited resource on |
| 32 // a particular platform. |
| 33 |
| 34 // TODO(raymes): This host can be moved to the browser process and we would |
| 35 // avoid crossing an additional process boundary to access the clipboard from |
| 36 // pepper. Moving the host code to the browser is straightforward but it also |
| 37 // means we have to deal with handling the clipboard accesses on the clipboard |
| 38 // thread. |
| 39 class PepperFlashClipboardHost : public ppapi::host::ResourceHost { |
| 40 public: |
| 41 PepperFlashClipboardHost(RendererPpapiHost* host, |
| 42 PP_Instance instance, |
| 43 PP_Resource resource); |
| 44 virtual ~PepperFlashClipboardHost(); |
| 45 |
| 46 virtual int32_t OnResourceMessageReceived( |
| 47 const IPC::Message& msg, |
| 48 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 49 |
| 50 private: |
| 51 int32_t OnMsgRegisterCustomFormat( |
| 52 ppapi::host::HostMessageContext* host_context, |
| 53 const std::string& format_name); |
| 54 int32_t OnMsgIsFormatAvailable( |
| 55 ppapi::host::HostMessageContext* host_context, |
| 56 uint32_t clipboard_type, |
| 57 uint32_t format); |
| 58 int32_t OnMsgReadData( |
| 59 ppapi::host::HostMessageContext* host_context, |
| 60 uint32_t clipoard_type, |
| 61 uint32_t format); |
| 62 int32_t OnMsgWriteData( |
| 63 ppapi::host::HostMessageContext* host_context, |
| 64 uint32_t clipboard_type, |
| 65 const std::vector<uint32_t>& formats, |
| 66 const std::vector<std::string>& data); |
| 67 |
| 68 int32_t WriteClipboardDataItem( |
| 69 uint32_t format, |
| 70 const std::string& data, |
| 71 webkit_glue::ScopedClipboardWriterGlue* scw); |
| 72 |
| 73 scoped_ptr<webkit_glue::ClipboardClient> clipboard_client_; |
| 74 ppapi::FlashClipboardFormatRegistry custom_formats_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(PepperFlashClipboardHost); |
| 77 }; |
| 78 |
| 79 } // namespace content |
| 80 |
| 81 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FLASH_CLIPBOARD_HOST_H_ |
OLD | NEW |