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

Side by Side Diff: chrome/browser/prefs/pref_value_map.h

Issue 5915004: Introduce incognito preference settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed whitespaces in mac files Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_
6 #define CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_ 6 #define CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 14
15 class Value; 15 class Value;
16 16
17 // A generic string to value map used by the PrefStore implementations. 17 // A generic string to value map used by the PrefStore implementations.
18 class PrefValueMap { 18 class PrefValueMap {
19 public: 19 public:
20 typedef std::map<std::string, Value*>::iterator iterator;
21 typedef std::map<std::string, Value*>::const_iterator const_iterator;
22
20 PrefValueMap(); 23 PrefValueMap();
21 virtual ~PrefValueMap(); 24 virtual ~PrefValueMap();
22 25
23 // Gets the value for |key| and stores it in |value|. Ownership remains with 26 // Gets the value for |key| and stores it in |value|. Ownership remains with
24 // the map. Returns true if a value is present. If not, |value| is not 27 // the map. Returns true if a value is present. If not, |value| is not
25 // touched. 28 // touched.
26 bool GetValue(const std::string& key, Value** value) const; 29 bool GetValue(const std::string& key, Value** value) const;
27 30
28 // Sets a new |value| for |key|. Takes ownership of |value|, which must be 31 // Sets a new |value| for |key|. Takes ownership of |value|, which must be
29 // non-NULL. Returns true if the value changed. 32 // non-NULL. Returns true if the value changed.
30 bool SetValue(const std::string& key, Value* value); 33 bool SetValue(const std::string& key, Value* value);
31 34
32 // Removes the value for |key| from the map. Returns true if a value was 35 // Removes the value for |key| from the map. Returns true if a value was
33 // removed. 36 // removed.
34 bool RemoveValue(const std::string& key); 37 bool RemoveValue(const std::string& key);
35 38
36 // Clears the map. 39 // Clears the map.
37 void Clear(); 40 void Clear();
38 41
42 iterator begin();
43 iterator end();
44 const_iterator begin() const;
45 const_iterator end() const;
46
39 // Gets a boolean value for |key| and stores it in |value|. Returns true if 47 // Gets a boolean value for |key| and stores it in |value|. Returns true if
40 // the value was found and of the proper type. 48 // the value was found and of the proper type.
41 bool GetBoolean(const std::string& key, bool* value) const; 49 bool GetBoolean(const std::string& key, bool* value) const;
42 50
43 // Gets a string value for |key| and stores it in |value|. Returns true if 51 // Gets a string value for |key| and stores it in |value|. Returns true if
44 // the value was found and of the proper type. 52 // the value was found and of the proper type.
45 bool GetString(const std::string& key, std::string* value) const; 53 bool GetString(const std::string& key, std::string* value) const;
46 54
47 // Sets the value for |key| to the string |value|. 55 // Sets the value for |key| to the string |value|.
48 void SetString(const std::string& key, const std::string& value); 56 void SetString(const std::string& key, const std::string& value);
49 57
50 // Compares this value map against |other| and stores all key names that have 58 // Compares this value map against |other| and stores all key names that have
51 // different values in |differing_keys|. This includes keys that are present 59 // different values in |differing_keys|. This includes keys that are present
52 // only in one of the maps. 60 // only in one of the maps.
53 void GetDifferingKeys(const PrefValueMap* other, 61 void GetDifferingKeys(const PrefValueMap* other,
54 std::vector<std::string>* differing_keys) const; 62 std::vector<std::string>* differing_keys) const;
55 63
56 private: 64 private:
57 typedef std::map<std::string, Value*> Map; 65 typedef std::map<std::string, Value*> Map;
58 66
59 Map prefs_; 67 Map prefs_;
60 68
61 DISALLOW_COPY_AND_ASSIGN(PrefValueMap); 69 DISALLOW_COPY_AND_ASSIGN(PrefValueMap);
62 }; 70 };
63 71
64 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_ 72 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698