| OLD | NEW |
| 1 // Copyright (c) 2011 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_CONTENT_SETTINGS_CONTENT_SETTINGS_ORIGIN_IDENTIFIER_VALUE
_MAP_H_ | 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_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_ORIGIN_IDENTIFIER_VALUE
_MAP_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/tuple.h" | 12 #include "base/tuple.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "chrome/browser/content_settings/content_settings_pattern.h" | 14 #include "chrome/browser/content_settings/content_settings_pattern.h" |
| 15 #include "chrome/common/content_settings_types.h" | 15 #include "chrome/common/content_settings_types.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 |
| 19 namespace base { |
| 18 class Value; | 20 class Value; |
| 21 } |
| 19 | 22 |
| 20 namespace content_settings { | 23 namespace content_settings { |
| 21 | 24 |
| 22 class OriginIdentifierValueMap { | 25 class OriginIdentifierValueMap { |
| 23 public: | 26 public: |
| 24 typedef std::string ResourceIdentifier; | 27 typedef std::string ResourceIdentifier; |
| 25 | 28 |
| 26 struct Entry { | 29 struct Entry { |
| 27 Entry(const ContentSettingsPattern& primary_pattern, | 30 Entry(const ContentSettingsPattern& primary_pattern, |
| 28 const ContentSettingsPattern& secondary_pattern, | 31 const ContentSettingsPattern& secondary_pattern, |
| 29 ContentSettingsType content_type, | 32 ContentSettingsType content_type, |
| 30 ResourceIdentifier identifier, | 33 ResourceIdentifier identifier, |
| 31 Value* value); | 34 base::Value* value); |
| 32 ~Entry(); | 35 ~Entry(); |
| 33 | 36 |
| 34 ContentSettingsPattern primary_pattern; | 37 ContentSettingsPattern primary_pattern; |
| 35 ContentSettingsPattern secondary_pattern; | 38 ContentSettingsPattern secondary_pattern; |
| 36 ContentSettingsType content_type; | 39 ContentSettingsType content_type; |
| 37 ResourceIdentifier identifier; | 40 ResourceIdentifier identifier; |
| 38 linked_ptr<Value> value; | 41 linked_ptr<base::Value> value; |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 typedef std::list<Entry> EntryList; | 44 typedef std::list<Entry> EntryList; |
| 42 | 45 |
| 43 typedef EntryList::const_iterator const_iterator; | 46 typedef EntryList::const_iterator const_iterator; |
| 44 | 47 |
| 45 typedef EntryList::iterator iterator; | 48 typedef EntryList::iterator iterator; |
| 46 | 49 |
| 47 EntryList::iterator begin() { | 50 EntryList::iterator begin() { |
| 48 return entries_.begin(); | 51 return entries_.begin(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 size_t size() const { | 66 size_t size() const { |
| 64 return entries_.size(); | 67 return entries_.size(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 OriginIdentifierValueMap(); | 70 OriginIdentifierValueMap(); |
| 68 ~OriginIdentifierValueMap(); | 71 ~OriginIdentifierValueMap(); |
| 69 | 72 |
| 70 // Returns a weak pointer to the value for the given |primary_pattern|, | 73 // Returns a weak pointer to the value for the given |primary_pattern|, |
| 71 // |secondary_pattern|, |content_type|, |resource_identifier| tuple. If | 74 // |secondary_pattern|, |content_type|, |resource_identifier| tuple. If |
| 72 // no value is stored for the passed parameter |NULL| is returned. | 75 // no value is stored for the passed parameter |NULL| is returned. |
| 73 Value* GetValue( | 76 base::Value* GetValue( |
| 74 const GURL& primary_url, | 77 const GURL& primary_url, |
| 75 const GURL& secondary_url, | 78 const GURL& secondary_url, |
| 76 ContentSettingsType content_type, | 79 ContentSettingsType content_type, |
| 77 const ResourceIdentifier& resource_identifier) const; | 80 const ResourceIdentifier& resource_identifier) const; |
| 78 | 81 |
| 79 // Sets the |value| for the given |primary_pattern|, |secondary_pattern|, | 82 // Sets the |value| for the given |primary_pattern|, |secondary_pattern|, |
| 80 // |content_type|, |resource_identifier| tuple. The method takes the ownership | 83 // |content_type|, |resource_identifier| tuple. The method takes the ownership |
| 81 // of the passed |value|. | 84 // of the passed |value|. |
| 82 void SetValue( | 85 void SetValue( |
| 83 const ContentSettingsPattern& primary_pattern, | 86 const ContentSettingsPattern& primary_pattern, |
| 84 const ContentSettingsPattern& secondary_pattern, | 87 const ContentSettingsPattern& secondary_pattern, |
| 85 ContentSettingsType content_type, | 88 ContentSettingsType content_type, |
| 86 const ResourceIdentifier& resource_identifier, | 89 const ResourceIdentifier& resource_identifier, |
| 87 Value* value); | 90 base::Value* value); |
| 88 | 91 |
| 89 // Deletes the map entry for the given |primary_pattern|, | 92 // Deletes the map entry for the given |primary_pattern|, |
| 90 // |secondary_pattern|, |content_type|, |resource_identifier| tuple. | 93 // |secondary_pattern|, |content_type|, |resource_identifier| tuple. |
| 91 void DeleteValue( | 94 void DeleteValue( |
| 92 const ContentSettingsPattern& primary_pattern, | 95 const ContentSettingsPattern& primary_pattern, |
| 93 const ContentSettingsPattern& secondary_pattern, | 96 const ContentSettingsPattern& secondary_pattern, |
| 94 ContentSettingsType content_type, | 97 ContentSettingsType content_type, |
| 95 const ResourceIdentifier& resource_identifier); | 98 const ResourceIdentifier& resource_identifier); |
| 96 | 99 |
| 97 // Deletes the map entry at the passed position. The method returns the | 100 // Deletes the map entry at the passed position. The method returns the |
| (...skipping 21 matching lines...) Expand all Loading... |
| 119 | 122 |
| 120 // Compares two origin value map entries and tests if the item, top-level-frame | 123 // Compares two origin value map entries and tests if the item, top-level-frame |
| 121 // pattern pair of the first entry has a higher precedences then the pattern | 124 // pattern pair of the first entry has a higher precedences then the pattern |
| 122 // pair of the second entry. | 125 // pair of the second entry. |
| 123 bool operator>(const OriginIdentifierValueMap::Entry& first, | 126 bool operator>(const OriginIdentifierValueMap::Entry& first, |
| 124 const OriginIdentifierValueMap::Entry& second); | 127 const OriginIdentifierValueMap::Entry& second); |
| 125 | 128 |
| 126 } // namespace content_settings | 129 } // namespace content_settings |
| 127 | 130 |
| 128 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_ORIGIN_IDENTIFIER_VA
LUE_MAP_H_ | 131 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_ORIGIN_IDENTIFIER_VA
LUE_MAP_H_ |
| OLD | NEW |