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 PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_ | |
6 #define PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "ppapi/c/private/ppb_flash_clipboard.h" | |
12 #include "ppapi/shared_impl/ppapi_shared_export.h" | |
13 | |
14 namespace ppapi { | |
15 | |
16 // This class manages custom clipboard formats that can be registered by a user | |
17 // of PPB_Flash_Clipboard. It is used by both the plugin and host side | |
18 // of the proxy. The host side is the definitive source of which formats | |
19 // have been registered but format registration is tracked on the plugin | |
20 // side to better handle error cases. | |
21 class PPAPI_SHARED_EXPORT FlashClipboardFormatRegistry { | |
dcheng
2012/10/29 20:26:29
With the custom web data changes, do you still nee
raymes
2012/10/29 23:30:00
As discussed, this is still needed because of the
| |
22 public: | |
23 FlashClipboardFormatRegistry(); | |
24 ~FlashClipboardFormatRegistry(); | |
25 | |
26 // Registers a custom format with the given string. The ID of the format is | |
27 // returned if registered successfully, otherwise | |
28 // PP_FLASH_CLIPBOARD_FORMAT_INVALID is returned. If a format with a | |
29 // particular name is already registered, the ID associated with that name | |
30 // will be returned. The format name is checked for validity. | |
31 uint32_t RegisterFormat(const std::string& format_name); | |
32 | |
33 // This sets the name of a particular format in the registry. This is only | |
34 // used on the plugin side in order to track format IDs that are returned | |
35 // by the host. | |
36 void SetRegisteredFormat(const std::string& format_name, uint32_t format); | |
37 | |
38 // Checks whether the given custom format ID has been registered. | |
39 bool IsFormatRegistered(uint32_t format); | |
40 | |
41 // Returns the name of a particular format. | |
42 std::string GetFormatName(uint32_t format); | |
43 | |
44 // Gets the ID of a particular format name that has already been registered. | |
45 // PP_FLASH_CLIPBOARD_FORMAT_INVALID is returned if the format has not been | |
46 // registered. | |
47 uint32_t GetFormatID(const std::string& format_name); | |
48 | |
49 // Returns whether the given clipboard type is valid. | |
50 static bool IsValidClipboardType(PP_Flash_Clipboard_Type type); | |
51 | |
52 // Returns whether the given clipboard format is a valid predefined format | |
53 // (i.e. one defined in the PP_Flash_Clipboard_Format enum). | |
54 static bool IsValidPredefinedFormat(uint32_t format); | |
55 | |
56 private: | |
57 // A vector of the custom format names where the index of the vector is the | |
58 // ID of the custom format. This means that the first indices in this | |
59 // structure will be reserved for predefined formats. | |
60 std::vector<std::string> custom_formats_; | |
dcheng
2012/10/29 20:26:29
Should this class be copyable/assignable?
raymes
2012/10/29 23:30:00
Done.
| |
61 | |
62 }; | |
63 | |
64 } // ppapi | |
65 | |
66 #endif // PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_ | |
67 | |
OLD | NEW |