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

Side by Side Diff: chrome/browser/content_settings/content_settings_origin_identifier_value_map.h

Issue 7049007: Origin Identifier Value Map. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_ORIGIN_IDENTIFIER_VALUE _MAP_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_ORIGIN_IDENTIFIER_VALUE _MAP_H_
7
8 #include <list>
9 #include <map>
10 #include <string>
11
12 #include "base/tuple.h"
13 #include "base/memory/linked_ptr.h"
14 #include "chrome/browser/content_settings/content_settings_pattern.h"
15 #include "chrome/common/content_settings_types.h"
16
17 class GURL;
18 class Value;
19
20 namespace content_settings {
21
22 class OriginIdentifierValueMap {
23 public:
24 typedef std::string ResourceIdentifier;
25
26 struct Entry {
27 Entry(ContentSettingsPattern item_pattern,
28 ContentSettingsPattern top_level_frame_pattern,
29 ContentSettingsType content_type,
30 ResourceIdentifier identifier,
31 Value* value)
32 : item_pattern(item_pattern),
33 top_level_frame_pattern(top_level_frame_pattern),
34 content_type(content_type),
35 identifier(identifier),
36 value(value) {
37 }
38
39 ContentSettingsPattern item_pattern;
40 ContentSettingsPattern top_level_frame_pattern;
41 ContentSettingsType content_type;
42 ResourceIdentifier identifier;
43 linked_ptr<Value> value;
44 };
45
46 typedef std::list<Entry> EntryList;
47
48 typedef EntryList::const_iterator const_iterator;
49
50 typedef EntryList::iterator iterator;
51
52 EntryList::iterator begin() {
53 return entries_.begin();
54 }
55
56 EntryList::iterator end() {
57 return entries_.end();
58 }
59
60 EntryList::const_iterator begin() const {
61 return entries_.begin();
62 }
63
64 EntryList::const_iterator end() const {
65 return entries_.end();
66 }
67
68 size_t size() const {
69 return entries_.size();
70 }
71
72 OriginIdentifierValueMap();
73 ~OriginIdentifierValueMap();
74
75 // Returns a weak pointer to the value for the given |item_pattern|,
76 // |top_level_frame_pattern|, |content_type|, |resource_identifier| tuple. If
77 // no value is stored for the passed parameter |NULL| is returned.
78 Value* GetValue(
79 const GURL& item_url,
80 const GURL& top_level_frame_url,
81 ContentSettingsType content_type,
82 const ResourceIdentifier& resource_identifier) const;
83
84 // Sets the |value| for the given |item_pattern|, |top_level_frame_pattern|,
85 // |content_type|, |resource_identifier| tuple. The method takes the ownership
86 // of the passed |value|.
87 void SetValue(
88 const ContentSettingsPattern& item_pattern,
89 const ContentSettingsPattern& top_level_frame_pattern,
90 ContentSettingsType content_type,
91 const ResourceIdentifier& resource_identifier,
92 Value* value);
93
94 // Deletes the map entry for the given |item_pattern|,
95 // |top_level_frame_pattern|, |content_type|, |resource_identifier| tuple.
96 void DeleteValue(
97 const ContentSettingsPattern& item_pattern,
98 const ContentSettingsPattern& top_level_frame_pattern,
99 ContentSettingsType content_type,
100 const ResourceIdentifier& resource_identifier);
101
102 // Deletes the map entry at the passed position. The method returns the
103 // position of the next entry in the map.
104 EntryList::iterator DeleteValue(EntryList::iterator entry);
Bernhard Bauer 2011/06/14 11:50:57 This method overloads |DeleteValue| and seems to b
markusheintz_ 2011/06/14 12:24:33 Will remove.
105
106 // Clears all map entries.
107 void Clear();
Bernhard Bauer 2011/06/14 11:50:57 This should be unnecessary now.
markusheintz_ 2011/06/14 12:24:33 I think that's still necessary. I use it in the Po
Bernhard Bauer 2011/06/14 12:34:27 Oh, right. You could rename it to lowercase to mak
108
109 private:
110 // Finds the list entry for the given |item_pattern|,
111 // |top_level_frame_pattern|, |content_type|, |resource_identifier| tuple and
112 // returns the iterator of the list entry. If no entry is found for the passed
113 // parameters then the end of list iterator is returned.
114 EntryList::iterator FindEntry(
115 const ContentSettingsPattern& item_pattern,
116 const ContentSettingsPattern& top_level_frame_pattern,
117 ContentSettingsType content_type,
118 const ResourceIdentifier& resource_identifier);
119
120 EntryList entries_;
121
122 DISALLOW_COPY_AND_ASSIGN(OriginIdentifierValueMap);
123 };
124
125 // Compares two origin value map entries and tests if the item, top-level-frame
126 // pattern pair of the first entry has a higher precedences then the pattern
127 // pair of the second entry.
128 bool operator>(const OriginIdentifierValueMap::Entry& first,
129 const OriginIdentifierValueMap::Entry& second);
130
131 } // namespace content_settings
132
133 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_ORIGIN_IDENTIFIER_VA LUE_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698