- add sources.
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / clipboard_message_filter.h
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_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "content/public/browser/browser_message_filter.h"
13 #include "ui/base/clipboard/clipboard.h"
14
15 class GURL;
16
17 namespace content {
18
19 class ClipboardMessageFilter : public BrowserMessageFilter {
20  public:
21   ClipboardMessageFilter();
22
23   virtual void OverrideThreadForMessage(
24       const IPC::Message& message,
25       BrowserThread::ID* thread) OVERRIDE;
26   virtual bool OnMessageReceived(const IPC::Message& message,
27                                  bool* message_was_ok) OVERRIDE;
28  private:
29   virtual ~ClipboardMessageFilter();
30
31   void OnWriteObjectsAsync(const ui::Clipboard::ObjectMap& objects);
32   void OnWriteObjectsSync(ui::Clipboard::ObjectMap objects,
33                           base::SharedMemoryHandle bitmap_handle);
34
35   void OnGetSequenceNumber(const ui::ClipboardType type,
36                            uint64* sequence_number);
37   void OnIsFormatAvailable(const ui::Clipboard::FormatType& format,
38                            ui::ClipboardType type,
39                            bool* result);
40   void OnClear(ui::ClipboardType type);
41   void OnReadAvailableTypes(ui::ClipboardType type,
42                             std::vector<string16>* types,
43                             bool* contains_filenames);
44   void OnReadText(ui::ClipboardType type, string16* result);
45   void OnReadAsciiText(ui::ClipboardType type, std::string* result);
46   void OnReadHTML(ui::ClipboardType type,
47                   string16* markup,
48                   GURL* url,
49                   uint32* fragment_start,
50                   uint32* fragment_end);
51   void OnReadRTF(ui::ClipboardType type, std::string* result);
52   void OnReadImage(ui::ClipboardType type, IPC::Message* reply_msg);
53   void OnReadImageReply(const SkBitmap& bitmap, IPC::Message* reply_msg);
54   void OnReadCustomData(ui::ClipboardType clipboard_type,
55                         const string16& type,
56                         string16* result);
57   void OnReadData(const ui::Clipboard::FormatType& format,
58                   std::string* data);
59
60 #if defined(OS_MACOSX)
61   void OnFindPboardWriteString(const string16& text);
62 #endif
63
64   // We have our own clipboard because we want to access the clipboard on the
65   // IO thread instead of forwarding (possibly synchronous) messages to the UI
66   // thread. This instance of the clipboard should be accessed only on the IO
67   // thread.
68   static ui::Clipboard* GetClipboard();
69
70   DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter);
71 };
72
73 }  // namespace content
74
75 #endif  // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_