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 // The details send with notifications about content setting changes. | |
6 | |
7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ |
8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ |
9 #pragma once | 7 #pragma once |
10 | 8 |
11 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
12 #include "chrome/browser/content_settings/content_settings_pattern.h" | 10 #include "chrome/browser/content_settings/content_settings_pattern.h" |
13 #include "chrome/common/content_settings.h" | 11 #include "chrome/common/content_settings.h" |
14 | 12 |
15 // Details for the CONTENT_SETTINGS_CHANGED notification. This is sent when | 13 // Details for the CONTENT_SETTINGS_CHANGED notification. This is sent when |
16 // content settings change for at least one host. If settings change for more | 14 // content settings change for at least one host. If settings change for more |
17 // than one pattern in one user interaction, this will usually send a single | 15 // than one pattern in one user interaction, this will usually send a single |
18 // notification with update_all() returning true instead of one notification | 16 // notification with update_all() returning true instead of one notification |
19 // for each pattern. | 17 // for each pattern. |
20 class ContentSettingsDetails { | 18 class ContentSettingsDetails { |
21 public: | 19 public: |
22 // Update the setting that matches this pattern/content type/resource. | 20 // Update the setting that matches this pattern/content type/resource. |
23 ContentSettingsDetails(const ContentSettingsPattern& pattern, | 21 ContentSettingsDetails(const ContentSettingsPattern& pattern, |
24 ContentSettingsType type, | 22 ContentSettingsType type, |
25 const std::string& resource_identifier) | 23 const std::string& resource_identifier); |
26 : pattern_(pattern), | |
27 type_(type), | |
28 resource_identifier_(resource_identifier) {} | |
29 | 24 |
30 // The pattern whose settings have changed. | 25 // The pattern whose settings have changed. |
31 const ContentSettingsPattern& pattern() const { return pattern_; } | 26 const ContentSettingsPattern& pattern() const { return pattern_; } |
32 | 27 |
33 // True if all settings should be updated for the given type. | 28 // True if all settings should be updated for the given type. |
34 bool update_all() const { return pattern_.ToString().empty(); } | 29 bool update_all() const { return !pattern_.IsValid(); } |
battre
2011/06/03 18:48:36
should this be renamed to update_all_patterns() gi
| |
35 | 30 |
36 // The type of the pattern whose settings have changed. | 31 // The type of the pattern whose settings have changed. |
37 ContentSettingsType type() const { return type_; } | 32 ContentSettingsType type() const { return type_; } |
38 | 33 |
39 // The resource identifier for the settings type that has changed. | 34 // The resource identifier for the settings type that has changed. |
40 const std::string& resource_identifier() const { | 35 const std::string& resource_identifier() const { |
41 return resource_identifier_; | 36 return resource_identifier_; |
42 } | 37 } |
43 | 38 |
44 // True if all types should be updated. If update_all() is false, this will | 39 // True if all types should be updated. If update_all() is false, this will |
45 // be false as well (although the reverse does not hold true). | 40 // be false as well (although the reverse does not hold true). |
46 bool update_all_types() const { | 41 bool update_all_types() const { |
47 return CONTENT_SETTINGS_TYPE_DEFAULT == type_; | 42 return CONTENT_SETTINGS_TYPE_DEFAULT == type_; |
48 } | 43 } |
49 | 44 |
50 private: | 45 private: |
51 ContentSettingsPattern pattern_; | 46 ContentSettingsPattern pattern_; |
52 ContentSettingsType type_; | 47 ContentSettingsType type_; |
53 std::string resource_identifier_; | 48 std::string resource_identifier_; |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(ContentSettingsDetails); | |
54 }; | 51 }; |
55 | 52 |
56 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ | 53 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ |
OLD | NEW |