Index: ppapi/shared_impl/flash_clipboard_format_registry.h |
diff --git a/ppapi/shared_impl/flash_clipboard_format_registry.h b/ppapi/shared_impl/flash_clipboard_format_registry.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..17d70e2d3c869dbef9092f5a4b64b1162f5108df |
--- /dev/null |
+++ b/ppapi/shared_impl/flash_clipboard_format_registry.h |
@@ -0,0 +1,67 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_ |
+#define PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "ppapi/c/private/ppb_flash_clipboard.h" |
+#include "ppapi/shared_impl/ppapi_shared_export.h" |
+ |
+namespace ppapi { |
+ |
+// This class manages custom clipboard formats that can be registered by a user |
+// of PPB_Flash_Clipboard. It is used by both the plugin and host side |
+// of the proxy. The host side is the definitive source of which formats |
+// have been registered but format registration is tracked on the plugin |
+// side to better handle error cases. |
+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
|
+ public: |
+ FlashClipboardFormatRegistry(); |
+ ~FlashClipboardFormatRegistry(); |
+ |
+ // Registers a custom format with the given string. The ID of the format is |
+ // returned if registered successfully, otherwise |
+ // PP_FLASH_CLIPBOARD_FORMAT_INVALID is returned. If a format with a |
+ // particular name is already registered, the ID associated with that name |
+ // will be returned. The format name is checked for validity. |
+ uint32_t RegisterFormat(const std::string& format_name); |
+ |
+ // This sets the name of a particular format in the registry. This is only |
+ // used on the plugin side in order to track format IDs that are returned |
+ // by the host. |
+ void SetRegisteredFormat(const std::string& format_name, uint32_t format); |
+ |
+ // Checks whether the given custom format ID has been registered. |
+ bool IsFormatRegistered(uint32_t format); |
+ |
+ // Returns the name of a particular format. |
+ std::string GetFormatName(uint32_t format); |
+ |
+ // Gets the ID of a particular format name that has already been registered. |
+ // PP_FLASH_CLIPBOARD_FORMAT_INVALID is returned if the format has not been |
+ // registered. |
+ uint32_t GetFormatID(const std::string& format_name); |
+ |
+ // Returns whether the given clipboard type is valid. |
+ static bool IsValidClipboardType(PP_Flash_Clipboard_Type type); |
+ |
+ // Returns whether the given clipboard format is a valid predefined format |
+ // (i.e. one defined in the PP_Flash_Clipboard_Format enum). |
+ static bool IsValidPredefinedFormat(uint32_t format); |
+ |
+ private: |
+ // A vector of the custom format names where the index of the vector is the |
+ // ID of the custom format. This means that the first indices in this |
+ // structure will be reserved for predefined formats. |
+ 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.
|
+ |
+}; |
+ |
+} // ppapi |
+ |
+#endif // PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_ |
+ |