pepper_flash_clipboard_message_filter.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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 CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_CLIPBOARD_MESSAGE_FILTER_H_
6#define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_CLIPBOARD_MESSAGE_FILTER_H_
7
8#include <string>
9#include <vector>
10
11#include "base/basictypes.h"
12#include "base/compiler_specific.h"
13#include "ppapi/host/resource_message_filter.h"
14#include "ppapi/shared_impl/flash_clipboard_format_registry.h"
15
16namespace ppapi {
17namespace host {
18struct HostMessageContext;
19}
20}
21
22namespace ui {
23class ScopedClipboardWriter;
24}
25
26namespace chrome {
27
28// Resource message filter for accessing the clipboard in Pepper. Pepper
29// supports reading/writing custom formats from the clipboard. Currently, all
30// custom formats that are read/written from the clipboard through pepper are
31// stored in a single real clipboard format (in the same way the "web custom"
32// clipboard formats are). This is done so that we don't have to have use real
33// clipboard types for each custom clipboard format which may be a limited
34// resource on a particular platform.
35class PepperFlashClipboardMessageFilter
36    : public ppapi::host::ResourceMessageFilter {
37 public:
38  PepperFlashClipboardMessageFilter();
39
40 protected:
41  // ppapi::host::ResourceMessageFilter overrides.
42  virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
43      const IPC::Message& msg) OVERRIDE;
44  virtual int32_t OnResourceMessageReceived(
45      const IPC::Message& msg,
46      ppapi::host::HostMessageContext* context) OVERRIDE;
47
48 private:
49  virtual ~PepperFlashClipboardMessageFilter();
50
51  int32_t OnMsgRegisterCustomFormat(
52      ppapi::host::HostMessageContext* host_context,
53      const std::string& format_name);
54  int32_t OnMsgIsFormatAvailable(ppapi::host::HostMessageContext* host_context,
55                                 uint32_t clipboard_type,
56                                 uint32_t format);
57  int32_t OnMsgReadData(ppapi::host::HostMessageContext* host_context,
58                        uint32_t clipoard_type,
59                        uint32_t format);
60  int32_t OnMsgWriteData(ppapi::host::HostMessageContext* host_context,
61                         uint32_t clipboard_type,
62                         const std::vector<uint32_t>& formats,
63                         const std::vector<std::string>& data);
64
65  int32_t WriteClipboardDataItem(uint32_t format,
66                                 const std::string& data,
67                                 ui::ScopedClipboardWriter* scw);
68
69  ppapi::FlashClipboardFormatRegistry custom_formats_;
70
71  DISALLOW_COPY_AND_ASSIGN(PepperFlashClipboardMessageFilter);
72};
73
74}  // namespace chrome
75
76#endif  // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_CLIPBOARD_MESSAGE_FILTER_H_
77