Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: chrome/browser/content_settings/host_content_settings_map.h

Issue 356543003: Audit the last usage of Geolocation and Notification permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Jam nits. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/content_settings/host_content_settings_map.h
diff --git a/chrome/browser/content_settings/host_content_settings_map.h b/chrome/browser/content_settings/host_content_settings_map.h
index 8d5681a1536a92a9e18978146b253f66554431db..915c4a7582da102720c2dd9bdb0aecd22d816c5d 100644
--- a/chrome/browser/content_settings/host_content_settings_map.h
+++ b/chrome/browser/content_settings/host_content_settings_map.h
@@ -27,11 +27,13 @@ class GURL;
class PrefService;
namespace base {
+class Clock;
class Value;
}
namespace content_settings {
class ProviderInterface;
+class PrefProvider;
}
namespace user_prefs {
@@ -199,6 +201,39 @@ class HostContentSettingsMap
return is_off_the_record_;
}
+ // Returns a single |ContentSetting| which applies to the given URLs, just as
+ // |GetContentSetting| does. If the setting is allowed, it also records the
+ // last usage to preferences.
+ //
+ // This should only be called on the UI thread, unlike |GetContentSetting|.
+ ContentSetting GetContentSettingAndMaybeUpdateLastUsage(
+ const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsType content_type,
+ const std::string& resource_identifier);
+
+ // Sets the last time that a given content type has been used for the pattern
+ // which matches the URLs to the current time.
+ void UpdateLastUsage(const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsType content_type);
+
+ // Returns the last time the pattern that matches the URL has requested
+ // permission for the |content_type| setting.
+ base::Time GetLastUsage(const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsType content_type);
+
+ // Returns the last time the pattern has requested permission for the
+ // |content_type| setting.
+ base::Time GetLastUsageByPattern(
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type);
+
+ // Passes ownership of |clock|.
+ void SetPrefClockForTesting(scoped_ptr<base::Clock> clock);
+
private:
friend class base::RefCountedThreadSafe<HostContentSettingsMap>;
friend class HostContentSettingsMapTest_NonDefaultSettings_Test;
@@ -236,6 +271,14 @@ class HostContentSettingsMap
// it is not being called too late.
void UsedContentSettingsProviders() const;
+ // Convenience method for updating the last usage of a content type for a
+ // pattern.
+ void UpdateLastUsageByPattern(const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type);
+
+ content_settings::PrefProvider* GetPrefProvider();
+
#ifndef NDEBUG
// This starts as the thread ID of the thread that constructs this
// object, and remains until used by a different thread, at which

Powered by Google App Engine
This is Rietveld 408576698