Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: ppapi/cpp/private/flash_clipboard.h

Issue 9212066: Modified the flash cipboard interface to add html clipboard support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_CPP_PRIVATE_FLASH_CLIPBOARD_H_ 5 #ifndef PPAPI_CPP_PRIVATE_FLASH_CLIPBOARD_H_
6 #define PPAPI_CPP_PRIVATE_FLASH_CLIPBOARD_H_ 6 #define PPAPI_CPP_PRIVATE_FLASH_CLIPBOARD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ppapi/c/private/ppb_flash_clipboard.h" 10 #include "ppapi/c/private/ppb_flash_clipboard.h"
11 11
12 namespace pp { 12 namespace pp {
13 13
14 class Instance; 14 class Instance;
15 15
16 namespace flash { 16 namespace flash {
17 17
18 class ClipboardData {
viettrungluu 2012/02/06 21:29:29 This seems like overkill to me. I'd just use an st
raymes 2012/02/07 00:02:25 Done.
19 public:
20 static const uint32_t kMaxFormats = 3;
21
22 void SetPlainText(const std::string& text);
23 void SetHTML(const std::string& html);
24 void Clear();
25 PP_Flash_Clipboard_Data_Item const*
26 GetDataItems(uint32_t* data_item_count_out) const;
27
28 private:
29 uint32_t GetFormatIndex(PP_Flash_Clipboard_Format format);
30 void SetTextVar(const std::string& text, PP_Flash_Clipboard_Format format);
31
32 PP_Flash_Clipboard_Data_Item data_items_[kMaxFormats];
33 uint32_t data_item_count_;
34 };
35
18 class Clipboard { 36 class Clipboard {
19 public: 37 public:
20 // Returns true if the required interface is available. 38 // Returns true if the required interface is available.
21 static bool IsAvailable(); 39 static bool IsAvailable();
22 40
23 // Returns true if the given format is available from the given clipboard. 41 // Returns true if the given format is available from the given clipboard.
24 static bool IsFormatAvailable(Instance* instance, 42 static bool IsFormatAvailable(Instance* instance,
25 PP_Flash_Clipboard_Type clipboard_type, 43 PP_Flash_Clipboard_Type clipboard_type,
26 PP_Flash_Clipboard_Format format); 44 PP_Flash_Clipboard_Format format);
27 45
28 // Returns true on success, in which case |text_out| will be filled with plain 46 // Returns true on success, in which case |text_out| will be filled with plain
29 // text read from the given clipboard. 47 // text read from the given clipboard.
30 static bool ReadPlainText(Instance* instance, 48 static bool ReadPlainText(Instance* instance,
31 PP_Flash_Clipboard_Type clipboard_type, 49 PP_Flash_Clipboard_Type clipboard_type,
32 std::string* text_out); 50 std::string* text_out);
33 51
34 // Returns true on success (it may fail if |text| is too big). 52 // Returns true on success, in which case |html_out| will be filled with html
viettrungluu 2012/02/06 21:29:29 I'd just implement a ReadData() that parallels the
raymes 2012/02/07 00:02:25 Done.
35 static bool WritePlainText(Instance* instance, 53 // text read from the given clipboard.
viettrungluu 2012/02/06 21:29:29 You should keep this (and also ReadPlainText()) te
raymes 2012/02/07 00:02:25 Done.
36 PP_Flash_Clipboard_Type clipboard_type, 54 static bool ReadHTML(Instance* instance,
37 const std::string& text); 55 PP_Flash_Clipboard_Type clipboard_type,
56 std::string* html_out);
57
58
59 // Returns true on success in which case all of |data| will be written to
60 // the clipboard. Otherwise nothing will be written.
61 static bool WriteData(Instance* instance,
62 PP_Flash_Clipboard_Type clipboard_type,
63 const ClipboardData& data);
64
65 private:
66 // Helper method for writing strings to the clipboard.
67 static bool ReadTextVar(Instance*,
68 PP_Flash_Clipboard_Type clipboard_type,
69 PP_Flash_Clipboard_Format clipboard_format,
70 std::string* text_out);
38 }; 71 };
39 72
40 } // namespace flash 73 } // namespace flash
41 } // namespace pp 74 } // namespace pp
42 75
43 #endif // PPAPI_CPP_PRIVATE_FLASH_CLIPBOARD_H_ 76 #endif // PPAPI_CPP_PRIVATE_FLASH_CLIPBOARD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698