Add ability to change display settings to chrome.systemInfo.display
[chromium-blink-merge.git] / ppapi / shared_impl / dictionary_var.h
blobcdc63bdee8d3cd1267ba52117706073a02df1f1f
1 // Copyright (c) 2013 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_DICTIONARY_VAR_H_
6 #define PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "ppapi/c/pp_var.h"
14 #include "ppapi/shared_impl/ppapi_shared_export.h"
15 #include "ppapi/shared_impl/scoped_pp_var.h"
16 #include "ppapi/shared_impl/var.h"
18 namespace ppapi {
20 class PPAPI_SHARED_EXPORT DictionaryVar : public Var {
21 public:
22 typedef std::map<std::string, ScopedPPVar> KeyValueMap;
24 DictionaryVar();
26 // Helper function that converts a PP_Var to a DictionaryVar. This will
27 // return NULL if the PP_Var is not of type PP_VARTYPE_DICTIONARY or the
28 // dictionary cannot be found from the var tracker.
29 static DictionaryVar* FromPPVar(const PP_Var& var);
31 // Var overrides.
32 virtual DictionaryVar* AsDictionaryVar() OVERRIDE;
33 virtual PP_VarType GetType() const OVERRIDE;
35 // The returned PP_Var has had a ref added on behalf of the caller.
36 PP_Var Get(const PP_Var& key) const;
37 PP_Bool Set(const PP_Var& key, const PP_Var& value);
38 void Delete(const PP_Var& key);
39 PP_Bool HasKey(const PP_Var& key) const;
40 // The returned PP_Var has had a ref added on behalf of the caller.
41 PP_Var GetKeys() const;
43 // Returns false and keeps the dictionary unchanged if |key| is not a valid
44 // UTF-8 string.
45 bool SetWithStringKey(const std::string& utf8_key, const PP_Var& value);
46 void DeleteWithStringKey(const std::string& utf8_key);
48 const KeyValueMap& key_value_map() const {
49 return key_value_map_;
52 protected:
53 virtual ~DictionaryVar();
55 private:
56 KeyValueMap key_value_map_;
58 DISALLOW_COPY_AND_ASSIGN(DictionaryVar);
61 } // namespace ppapi
63 #endif // PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_