Chromium Code Reviews| Index: chrome/browser/content_settings/host_content_settings_map.cc |
| diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc |
| index a1ff14c776a34c7e224d358a578ad0037efcfcf0..0cd06eef63536c0c6de1b90b933de29d62795173 100644 |
| --- a/chrome/browser/content_settings/host_content_settings_map.cc |
| +++ b/chrome/browser/content_settings/host_content_settings_map.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/stl_util.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "base/time/clock.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/content_settings/content_settings_custom_extension_provider.h" |
| #include "chrome/browser/content_settings/content_settings_default_provider.h" |
| @@ -298,6 +299,12 @@ void HostContentSettingsMap::SetContentSetting( |
| const std::string& resource_identifier, |
| ContentSetting setting) { |
| DCHECK(!ContentTypeHasCompoundValue(content_type)); |
| + |
| + if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION || |
| + content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| + UpdateLastUsageByPattern(primary_pattern, secondary_pattern, content_type); |
|
dewittj
2014/06/26 23:17:47
why is it only these two types?
Daniel Nishi
2014/06/27 17:25:19
At the time of the patch, these are the two types
|
| + } |
| + |
| base::Value* value = NULL; |
| if (setting != CONTENT_SETTING_DEFAULT) |
| value = base::Value::CreateIntegerValue(setting); |
| @@ -308,6 +315,54 @@ void HostContentSettingsMap::SetContentSetting( |
| value); |
| } |
| +void HostContentSettingsMap::UpdateLastUsage(const GURL& primary_url, |
| + const GURL& secondary_url, |
| + ContentSettingsType content_type) { |
| + UpdateLastUsageByPattern( |
| + ContentSettingsPattern::FromURLNoWildcard(primary_url), |
| + ContentSettingsPattern::FromURLNoWildcard(secondary_url), |
| + content_type); |
| +} |
| + |
| +void HostContentSettingsMap::UpdateLastUsageByPattern( |
| + const ContentSettingsPattern& primary_pattern, |
| + const ContentSettingsPattern& secondary_pattern, |
| + ContentSettingsType content_type) { |
| + UsedContentSettingsProviders(); |
| + |
| + static_cast<content_settings::PrefProvider*>( |
| + content_settings_providers_[PREF_PROVIDER]) |
| + ->UpdateLastUsage(primary_pattern, secondary_pattern, content_type); |
| +} |
| + |
| +base::Time HostContentSettingsMap::GetLastUsage( |
| + const GURL& primary_url, |
| + const GURL& secondary_url, |
| + ContentSettingsType content_type) { |
| + return GetLastUsageByPattern( |
| + ContentSettingsPattern::FromURLNoWildcard(primary_url), |
| + ContentSettingsPattern::FromURLNoWildcard(secondary_url), |
| + content_type); |
| +} |
| + |
| +base::Time HostContentSettingsMap::GetLastUsageByPattern( |
| + const ContentSettingsPattern& primary_pattern, |
| + const ContentSettingsPattern& secondary_pattern, |
| + ContentSettingsType content_type) { |
| + UsedContentSettingsProviders(); |
| + |
| + return static_cast<content_settings::PrefProvider*>( |
| + content_settings_providers_[PREF_PROVIDER]) |
| + ->GetLastUsage(primary_pattern, secondary_pattern, content_type); |
| +} |
| + |
| +void HostContentSettingsMap::SetPrefClockForTesting(base::Clock* clock) { |
| + UsedContentSettingsProviders(); |
| + |
| + static_cast<content_settings::PrefProvider*>( |
| + content_settings_providers_[PREF_PROVIDER])->SetClockForTesting(clock); |
| +} |
| + |
| void HostContentSettingsMap::AddExceptionForURL( |
| const GURL& primary_url, |
| const GURL& secondary_url, |