Chromium Code Reviews| 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..ba37daf6bef79279c2ae9545f340cd72ab0511c2 |
| --- /dev/null |
| +++ b/ppapi/shared_impl/flash_clipboard_format_registry.h |
| @@ -0,0 +1,69 @@ |
| +// 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 "base/basictypes.h" |
| +#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 { |
| + 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/30 00:52:33
My general feedback is this vector makes the class
raymes
2012/10/30 01:57:16
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(FlashClipboardFormatRegistry); |
| +}; |
| + |
| +} // ppapi |
| + |
| +#endif // PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_ |
| + |