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

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, 7 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 <string>
10
11 #include "base/tuple.h"
12 #include "chrome/browser/content_settings/content_settings_pattern.h"
13 #include "chrome/common/content_settings_types.h"
14
15 class GURL;
16 class Value;
17
18 namespace content_settings {
19
20 class OriginIdentifierValueMap {
21 public:
22 typedef std::string ResourceIdentifier;
23
24 typedef Tuple5 <ContentSettingsPattern,
25 ContentSettingsPattern,
26 ContentSettingsType,
27 ResourceIdentifier,
28 Value*> Entry;
Bernhard Bauer 2011/05/26 23:14:42 If you typedef the Entry as Tuple, you might just
markusheintz_ 2011/05/31 11:46:41 Changed to a struct.
29
30 typedef std::list<Entry> EntryList;
31
32 typedef EntryList::const_iterator const_iterator;
33
34 typedef EntryList::iterator iterator;
35
36 EntryList::iterator begin() {
37 return entries_.begin();
38 }
39
40 EntryList::iterator end() {
41 return entries_.end();
42 }
43
44 EntryList::const_iterator begin() const {
45 return entries_.begin();
46 }
47
48 EntryList::const_iterator end() const {
49 return entries_.end();
50 }
51
52 size_t size() const {
53 return entries_.size();
54 }
55
56 OriginIdentifierValueMap();
57 ~OriginIdentifierValueMap();
58
59 // Returns a weak pointer to the value for the given |item_pattern|,
60 // |top_level_frame_pattern|, |content_type|, |resource_identifier| tuple. If
61 // no value is stored for the passed parameter Null is returned.
Bernhard Bauer 2011/05/26 23:14:42 Nit: |NULL|?
markusheintz_ 2011/05/31 11:46:41 Done.
62 Value* GetValue(
63 const GURL& item_url,
64 const GURL& top_level_frame_url,
65 ContentSettingsType content_type,
66 const ResourceIdentifier& resource_identifier) const;
67
68 // Sets the |value| for the given |item_pattern|, |top_level_frame_pattern|,
69 // |content_type|, |resource_identifier| tuple. The method takes the ownership
70 // of the passed |value|.
71 void SetValue(
72 const ContentSettingsPattern& item_pattern,
73 const ContentSettingsPattern& top_level_frame_pattern,
74 ContentSettingsType content_type,
75 const ResourceIdentifier& resource_identifier,
76 Value* value);
77
78 // Deletes the map entry for the given |item_pattern|,
79 // |top_level_frame_pattern|, |content_type|, |resource_identifier| tuple.
80 void DeleteValue(
81 const ContentSettingsPattern& item_pattern,
82 const ContentSettingsPattern& top_level_frame_pattern,
83 ContentSettingsType content_type,
84 const ResourceIdentifier& resource_identifier);
85
86 // Deletes the map entry at the passed position. The method returns the
87 // position of the next entry in the map.
88 EntryList::iterator DeleteValue(EntryList::iterator entry);
89
90 // Clears all map entries.
91 void Clear();
92
93 private:
94 // Compares the content settings patterns of two list entries and returns the
95 // entry that contains the patterns with higher precedences.
96 EntryList::const_iterator GetEntryWithHighestPrecedence(
97 EntryList::const_iterator first,
98 EntryList::const_iterator second) const;
99
100 // Finds the list entry for the given |item_pattern|,
101 // |top_level_frame_pattern|, |content_type|, |resource_identifier| tuple and
102 // returns the iterator of the list entry. If no entry is found for the passed
103 // parameters then the end of list iterator is returned.
104 EntryList::iterator FindEntry(
105 const ContentSettingsPattern& item_pattern,
106 const ContentSettingsPattern& top_level_frame_pattern,
107 ContentSettingsType content_type,
108 const ResourceIdentifier& resource_identifier);
109
110 EntryList entries_;
111
112 DISALLOW_COPY_AND_ASSIGN(OriginIdentifierValueMap);
113 };
114
115 } // namespace content_settings
116
117 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_ORIGIN_IDENTIFIER_VA LUE_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698