| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Maps hostnames to custom content settings. Written on the UI thread and read | 5 // Maps hostnames to custom content settings. Written on the UI thread and read |
| 6 // on any thread. One instance per profile. | 6 // on any thread. One instance per profile. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 8 #ifndef CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| 9 #define CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 9 #define CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 std::string pattern_; | 66 std::string pattern_; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // Details for the CONTENT_SETTINGS_CHANGED notification. This is sent when | 69 // Details for the CONTENT_SETTINGS_CHANGED notification. This is sent when |
| 70 // content settings change for at least one host. If settings change for more | 70 // content settings change for at least one host. If settings change for more |
| 71 // than one pattern in one user interaction, this will usually send a single | 71 // than one pattern in one user interaction, this will usually send a single |
| 72 // notification with update_all() returning true instead of one notification | 72 // notification with update_all() returning true instead of one notification |
| 73 // for each pattern. | 73 // for each pattern. |
| 74 class ContentSettingsDetails { | 74 class ContentSettingsDetails { |
| 75 public: | 75 public: |
| 76 explicit ContentSettingsDetails(const Pattern& pattern) | 76 // Update the setting that matches this pattern/content type. |
| 77 : pattern_(pattern), update_all_(false) {} | 77 ContentSettingsDetails(const Pattern& pattern, ContentSettingsType type) |
| 78 : pattern_(pattern), type_(type) {} |
| 78 | 79 |
| 79 explicit ContentSettingsDetails(bool update_all) | 80 // No pattern is specified. Update all settings for this content type. |
| 80 : pattern_(), update_all_(update_all) {} | 81 explicit ContentSettingsDetails(ContentSettingsType type) : type_(type) {} |
| 82 |
| 83 // No content type or pattern is specified. Update all settings. |
| 84 ContentSettingsDetails() : type_(CONTENT_SETTINGS_TYPE_DEFAULT) {} |
| 81 | 85 |
| 82 // The pattern whose settings have changed. | 86 // The pattern whose settings have changed. |
| 83 const Pattern& pattern() const { return pattern_; } | 87 const Pattern& pattern() const { return pattern_; } |
| 84 | 88 |
| 85 // True if many settings changed at once. | 89 // True if all settings should be updated for the given type. |
| 86 bool update_all() const { return update_all_; } | 90 bool update_all() const { return pattern_.AsString().empty(); } |
| 91 |
| 92 // The type of the pattern whose settings have changed. |
| 93 ContentSettingsType type() const { return type_; } |
| 94 |
| 95 // True if all types should be updated. If update_all() is false, this will |
| 96 // be false as well (although the reverse does not hold true). |
| 97 bool update_all_types() const { |
| 98 return CONTENT_SETTINGS_TYPE_DEFAULT == type_; |
| 99 } |
| 87 | 100 |
| 88 private: | 101 private: |
| 89 Pattern pattern_; | 102 Pattern pattern_; |
| 90 bool update_all_; | 103 ContentSettingsType type_; |
| 91 }; | 104 }; |
| 92 | 105 |
| 93 | 106 |
| 94 typedef std::pair<Pattern, ContentSetting> PatternSettingPair; | 107 typedef std::pair<Pattern, ContentSetting> PatternSettingPair; |
| 95 typedef std::vector<PatternSettingPair> SettingsForOneType; | 108 typedef std::vector<PatternSettingPair> SettingsForOneType; |
| 96 | 109 |
| 97 explicit HostContentSettingsMap(Profile* profile); | 110 explicit HostContentSettingsMap(Profile* profile); |
| 98 ~HostContentSettingsMap(); | 111 ~HostContentSettingsMap(); |
| 99 | 112 |
| 100 static void RegisterUserPrefs(PrefService* prefs); | 113 static void RegisterUserPrefs(PrefService* prefs); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 }; | 263 }; |
| 251 | 264 |
| 252 // Stream operator so HostContentSettingsMap::Pattern can be used in | 265 // Stream operator so HostContentSettingsMap::Pattern can be used in |
| 253 // assertion statements. | 266 // assertion statements. |
| 254 inline std::ostream& operator<<( | 267 inline std::ostream& operator<<( |
| 255 std::ostream& out, const HostContentSettingsMap::Pattern& pattern) { | 268 std::ostream& out, const HostContentSettingsMap::Pattern& pattern) { |
| 256 return out << pattern.AsString(); | 269 return out << pattern.AsString(); |
| 257 } | 270 } |
| 258 | 271 |
| 259 #endif // CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 272 #endif // CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |