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