Chromium Code Reviews| 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 int32_t OnMsgRegisterCustomFormat( | |
|
brettw
2012/10/31 18:05:53
Can these messages be in the private section? I us
raymes
2012/11/01 19:57:54
Done.
| |
| 51 ppapi::host::HostMessageContext* host_context, | |
| 52 const std::string& format_name); | |
| 53 | |
| 54 int32_t OnMsgIsFormatAvailable( | |
| 55 ppapi::host::HostMessageContext* host_context, | |
| 56 uint32_t clipboard_type, | |
| 57 uint32_t format); | |
| 58 | |
| 59 int32_t OnMsgReadData( | |
| 60 ppapi::host::HostMessageContext* host_context, | |
| 61 uint32_t clipoard_type, | |
| 62 uint32_t format); | |
| 63 | |
| 64 int32_t OnMsgWriteData( | |
| 65 ppapi::host::HostMessageContext* host_context, | |
| 66 uint32_t clipboard_type, | |
| 67 const std::vector<uint32_t>& formats, | |
| 68 const std::vector<std::string>& data); | |
| 69 | |
| 70 private: | |
| 71 int32_t WriteClipboardDataItem( | |
| 72 uint32_t format, | |
| 73 const std::string& data, | |
| 74 webkit_glue::ScopedClipboardWriterGlue* scw); | |
| 75 | |
| 76 scoped_ptr<webkit_glue::ClipboardClient> clipboard_client_; | |
| 77 ppapi::FlashClipboardFormatRegistry custom_formats_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(PepperFlashClipboardHost); | |
| 80 }; | |
| 81 | |
| 82 } // namespace content | |
| 83 | |
| 84 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FLASH_CLIPBOARD_HOST_H_ | |
| OLD | NEW |