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