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/proxy/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 | |
40 : public ppapi::host::ResourceHost { | |
yzshen1
2012/10/29 17:58:04
no need to be on a new line.
raymes
2012/10/29 18:44:58
Done.
| |
41 public: | |
42 PepperFlashClipboardHost(RendererPpapiHost* host, | |
43 PP_Instance instance, | |
44 PP_Resource resource); | |
45 virtual ~PepperFlashClipboardHost(); | |
46 | |
47 virtual int32_t OnResourceMessageReceived( | |
48 const IPC::Message& msg, | |
49 ppapi::host::HostMessageContext* context) OVERRIDE; | |
50 | |
51 int32_t OnMsgRegisterCustomFormat( | |
52 ppapi::host::HostMessageContext* host_context, | |
53 const std::string& format_name); | |
54 | |
55 int32_t OnMsgIsFormatAvailable( | |
56 ppapi::host::HostMessageContext* host_context, | |
57 uint32_t clipboard_type, | |
58 uint32_t format); | |
59 | |
60 int32_t OnMsgReadData( | |
61 ppapi::host::HostMessageContext* host_context, | |
62 uint32_t clipoard_type, | |
63 uint32_t format); | |
64 | |
65 int32_t OnMsgWriteData( | |
66 ppapi::host::HostMessageContext* host_context, | |
67 uint32_t clipboard_type, | |
68 const std::vector<uint32_t>& formats, | |
69 const std::vector<std::string>& data); | |
70 | |
71 private: | |
72 int32_t WriteClipboardDataItem( | |
73 uint32_t format, | |
74 const std::string& data, | |
75 webkit_glue::ScopedClipboardWriterGlue* scw); | |
76 | |
77 scoped_ptr<webkit_glue::ClipboardClient> clipboard_client_; | |
78 ppapi::proxy::FlashClipboardFormatRegistry custom_formats_; | |
79 | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(PepperFlashClipboardHost); | |
82 }; | |
83 | |
84 } // namespace content | |
85 | |
86 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FLASH_CLIPBOARD_HOST_H_ | |
OLD | NEW |