[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / ppapi / shared_impl / flash_clipboard_format_registry.h
blob9e9ae3000c9c34e927b8bbdc8c89c7a9dccb0c63
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.
5 #ifndef PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_
6 #define PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "ppapi/c/private/ppb_flash_clipboard.h"
13 #include "ppapi/shared_impl/ppapi_shared_export.h"
15 namespace ppapi {
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();
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);
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);
39 // Checks whether the given custom format ID has been registered.
40 bool IsFormatRegistered(uint32_t format) const;
42 // Returns the name of a particular format.
43 std::string GetFormatName(uint32_t format) const;
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) const;
50 // Returns whether the given clipboard format is a valid predefined format
51 // (i.e. one defined in the PP_Flash_Clipboard_Format enum).
52 static bool IsValidPredefinedFormat(uint32_t format);
54 private:
55 // A map of custom format ID to format name.
56 typedef std::map<uint32_t, std::string> FormatMap;
57 FormatMap custom_formats_;
59 DISALLOW_COPY_AND_ASSIGN(FlashClipboardFormatRegistry);
62 } // ppapi
64 #endif // PPAPI_SHARED_IMPL_FLASH_CLIPBOARD_FORMAT_REGISTRY_H_