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

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: Add auditing for actual usage, too. Created 6 years, 6 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..f3d7a95b98420c17a647fb0137ed2d8631e1a414 100644
--- a/chrome/browser/content_settings/host_content_settings_map.h
+++ b/chrome/browser/content_settings/host_content_settings_map.h
@@ -27,6 +27,7 @@ class GURL;
class PrefService;
namespace base {
+class Clock;
class Value;
}
@@ -199,6 +200,37 @@ 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,
Michael van Ouwerkerk 2014/07/01 12:53:36 Do primary_url and secondary_url correspond to req
Daniel Nishi 2014/07/01 18:37:48 That's how it seems to work from Geolocations perm
Michael van Ouwerkerk 2014/07/02 18:51:15 Right. It's for distinguishing between iframes and
+ const GURL& secondary_url,
+ ContentSettingsType content_type,
+ const std::string& resource_identifier);
+
+ void UpdateLastUsage(const GURL& primary_url,
Michael van Ouwerkerk 2014/07/01 11:02:23 Please document this public method.
Daniel Nishi 2014/07/01 18:37:48 Done.
+ 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(base::Clock* clock);
+
private:
friend class base::RefCountedThreadSafe<HostContentSettingsMap>;
friend class HostContentSettingsMapTest_NonDefaultSettings_Test;
@@ -236,6 +268,12 @@ 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);
+
#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