Chromium Code Reviews| 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_DETAILS_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "chrome/common/chrome_content_settings_client.h" | |
| 11 #include "chrome/common/content_settings.h" | 12 #include "chrome/common/content_settings.h" |
| 12 #include "chrome/common/content_settings_pattern.h" | 13 #include "chrome/common/content_settings_pattern.h" |
| 13 #include "components/content_settings/core/common/content_settings_types.h" | 14 #include "components/content_settings/core/common/content_settings_types.h" |
| 14 | 15 |
| 15 // Details for the CONTENT_SETTINGS_CHANGED notification. This is sent when | 16 // 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 | 17 // 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 | 18 // than one pattern in one user interaction, this will usually send a single |
| 18 // notification with update_all() returning true instead of one notification | 19 // notification with update_all() returning true instead of one notification |
| 19 // for each pattern. | 20 // for each pattern. |
| 20 class ContentSettingsDetails { | 21 class ContentSettingsDetails { |
| 21 public: | 22 public: |
| 22 // Update the setting that matches this pattern/content type/resource. | 23 // Update the setting that matches this pattern/content type/resource. |
| 23 ContentSettingsDetails(const ContentSettingsPattern& primary_pattern, | 24 ContentSettingsDetails(const ContentSettingsPattern& primary_pattern, |
| 24 const ContentSettingsPattern& secondary_pattern, | 25 const ContentSettingsPattern& secondary_pattern, |
| 25 ContentSettingsType type, | 26 ContentSettingsType type, |
| 26 const std::string& resource_identifier); | 27 const std::string& resource_identifier); |
| 27 | 28 |
| 28 // The item pattern whose settings have changed. | 29 // The item pattern whose settings have changed. |
| 29 const ContentSettingsPattern& primary_pattern() const { | 30 const ContentSettingsPattern& primary_pattern() const { |
| 30 return primary_pattern_; | 31 return primary_pattern_; |
| 31 } | 32 } |
| 32 | 33 |
| 33 // The top level frame pattern whose settings have changed. | 34 // The top level frame pattern whose settings have changed. |
| 34 const ContentSettingsPattern& secondary_pattern() const { | 35 const ContentSettingsPattern& secondary_pattern() const { |
| 35 return secondary_pattern_; | 36 return secondary_pattern_; |
| 36 } | 37 } |
| 37 | 38 |
| 38 // True if all settings should be updated for the given type. | 39 // True if all settings should be updated for the given type. |
| 39 bool update_all() const { | 40 bool update_all() const { |
| 40 return primary_pattern_.ToString().empty() && | 41 content_settings::ChromeContentSettingsClient client; |
| 41 secondary_pattern_.ToString().empty(); | 42 return primary_pattern_.ToString(&client).empty() && |
|
vabr (Chromium)
2014/08/06 15:14:00
There should be a way to tell if the pattern is em
vasilii
2014/08/11 13:57:18
Markus was against changing this.
| |
| 43 secondary_pattern_.ToString(&client).empty(); | |
| 42 } | 44 } |
| 43 | 45 |
| 44 // The type of the pattern whose settings have changed. | 46 // The type of the pattern whose settings have changed. |
| 45 ContentSettingsType type() const { return type_; } | 47 ContentSettingsType type() const { return type_; } |
| 46 | 48 |
| 47 // The resource identifier for the settings type that has changed. | 49 // The resource identifier for the settings type that has changed. |
| 48 const std::string& resource_identifier() const { | 50 const std::string& resource_identifier() const { |
| 49 return resource_identifier_; | 51 return resource_identifier_; |
| 50 } | 52 } |
| 51 | 53 |
| 52 // True if all types should be updated. If update_all() is false, this will | 54 // True if all types should be updated. If update_all() is false, this will |
| 53 // be false as well (although the reverse does not hold true). | 55 // be false as well (although the reverse does not hold true). |
| 54 bool update_all_types() const { | 56 bool update_all_types() const { |
| 55 return CONTENT_SETTINGS_TYPE_DEFAULT == type_; | 57 return CONTENT_SETTINGS_TYPE_DEFAULT == type_; |
| 56 } | 58 } |
| 57 | 59 |
| 58 private: | 60 private: |
| 59 ContentSettingsPattern primary_pattern_; | 61 ContentSettingsPattern primary_pattern_; |
| 60 ContentSettingsPattern secondary_pattern_; | 62 ContentSettingsPattern secondary_pattern_; |
| 61 ContentSettingsType type_; | 63 ContentSettingsType type_; |
| 62 std::string resource_identifier_; | 64 std::string resource_identifier_; |
| 63 | 65 |
| 64 DISALLOW_COPY_AND_ASSIGN(ContentSettingsDetails); | 66 DISALLOW_COPY_AND_ASSIGN(ContentSettingsDetails); |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ | 69 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_ |
| OLD | NEW |