| 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..14550014a217c2505067f6c5a52de40d439d3f17 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,13 @@ void HostContentSettingsMap::SetContentSetting(
|
| const std::string& resource_identifier,
|
| ContentSetting setting) {
|
| DCHECK(!ContentTypeHasCompoundValue(content_type));
|
| +
|
| + if (setting == CONTENT_SETTING_ALLOW &&
|
| + (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
|
| + content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)) {
|
| + UpdateLastUsageByPattern(primary_pattern, secondary_pattern, content_type);
|
| + }
|
| +
|
| base::Value* value = NULL;
|
| if (setting != CONTENT_SETTING_DEFAULT)
|
| value = base::Value::CreateIntegerValue(setting);
|
| @@ -308,6 +316,72 @@ void HostContentSettingsMap::SetContentSetting(
|
| value);
|
| }
|
|
|
| +ContentSetting HostContentSettingsMap::GetContentSettingAndMaybeUpdateLastUsage(
|
| + const GURL& primary_url,
|
| + const GURL& secondary_url,
|
| + ContentSettingsType content_type,
|
| + const std::string& resource_identifier) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + ContentSetting setting = GetContentSetting(
|
| + primary_url, secondary_url, content_type, resource_identifier);
|
| + if (setting == CONTENT_SETTING_ALLOW) {
|
| + UpdateLastUsageByPattern(
|
| + ContentSettingsPattern::FromURLNoWildcard(primary_url),
|
| + ContentSettingsPattern::FromURLNoWildcard(secondary_url),
|
| + content_type);
|
| + }
|
| + return setting;
|
| +}
|
| +
|
| +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,
|
|
|