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

Unified Diff: ppapi/proxy/flash_clipboard_format_registry.h

Issue 11225021: Move flash clipboard to the new proxy and add custom format support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/flash_clipboard_format_registry.h
diff --git a/ppapi/proxy/flash_clipboard_format_registry.h b/ppapi/proxy/flash_clipboard_format_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..ccde1cfd2e6c12245013705ef53b396b71c27ca4
--- /dev/null
+++ b/ppapi/proxy/flash_clipboard_format_registry.h
@@ -0,0 +1,70 @@
+// 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_PROXY_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_
+#define PPAPI_PROXY_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_
+
+#include <string>
+#include <vector>
+
+#include "ppapi/proxy/ppapi_proxy_export.h"
+
+#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.
+
+namespace ppapi {
+namespace proxy {
yzshen1 2012/10/29 16:55:46 Shall we put this in shared_impl?
raymes 2012/10/29 18:44:58 Done.
+
+// 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_PROXY_EXPORT FlashClipboardFormatRegistry {
+ public:
+ FlashClipboardFormatRegistry();
+ 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.
+
+ // 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.
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
+ std::vector<std::string> custom_formats_;
+
+};
+
+} // proxy
+} // ppapi
+
+#endif // PPAPI_PROXY_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_
+

Powered by Google App Engine
This is Rietveld 408576698