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

Unified Diff: components/content_settings/core/browser/content_settings_pref.cc

Issue 2697473002: Remove last usage functions from HostContentSettingsMap and clean up prefs (Closed)
Patch Set: fix up unit test Created 3 years, 10 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: components/content_settings/core/browser/content_settings_pref.cc
diff --git a/components/content_settings/core/browser/content_settings_pref.cc b/components/content_settings/core/browser/content_settings_pref.cc
index 0306c586032ad61ce238716ba50373d24c0e8bf0..df76df0657322578264e4aebb82128cf9745c732 100644
--- a/components/content_settings/core/browser/content_settings_pref.cc
+++ b/components/content_settings/core/browser/content_settings_pref.cc
@@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_split.h"
-#include "base/time/clock.h"
#include "components/content_settings/core/browser/content_settings_info.h"
#include "components/content_settings/core/browser/content_settings_registry.h"
#include "components/content_settings/core/browser/content_settings_rule.h"
@@ -26,7 +25,6 @@ namespace {
const char kSettingPath[] = "setting";
const char kPerResourceIdentifierPrefName[] = "per_resource";
-const char kLastUsed[] = "last_used";
// If the given content type supports resource identifiers in user preferences,
// returns true and sets |pref_key| to the key in the content settings
@@ -178,66 +176,6 @@ void ContentSettingsPref::ClearAllContentSettingsRules() {
ResourceIdentifier());
}
-void ContentSettingsPref::UpdateLastUsage(
- const ContentSettingsPattern& primary_pattern,
- const ContentSettingsPattern& secondary_pattern,
- base::Clock* clock) {
- // Don't write if in incognito.
- if (is_incognito_) {
- return;
- }
-
- // Ensure that |lock_| is not held by this thread, since this function will
- // send out notifications (by |~DictionaryPrefUpdate|).
- AssertLockNotHeld();
-
- base::AutoReset<bool> auto_reset(&updating_preferences_, true);
- {
- DictionaryPrefUpdate update(prefs_, pref_name_);
- base::DictionaryValue* pattern_pairs_settings = update.Get();
-
- std::string pattern_str(
- CreatePatternString(primary_pattern, secondary_pattern));
- base::DictionaryValue* settings_dictionary = NULL;
- bool found = pattern_pairs_settings->GetDictionaryWithoutPathExpansion(
- pattern_str, &settings_dictionary);
-
- if (!found) {
- settings_dictionary = new base::DictionaryValue;
- pattern_pairs_settings->SetWithoutPathExpansion(pattern_str,
- settings_dictionary);
- }
-
- settings_dictionary->SetWithoutPathExpansion(
- kLastUsed, new base::FundamentalValue(clock->Now().ToDoubleT()));
- }
-}
-
-base::Time ContentSettingsPref::GetLastUsage(
- const ContentSettingsPattern& primary_pattern,
- const ContentSettingsPattern& secondary_pattern) {
- const base::DictionaryValue* pattern_pairs_settings =
- prefs_->GetDictionary(pref_name_);
- std::string pattern_str(
- CreatePatternString(primary_pattern, secondary_pattern));
-
- const base::DictionaryValue* settings_dictionary = NULL;
- bool found = pattern_pairs_settings->GetDictionaryWithoutPathExpansion(
- pattern_str, &settings_dictionary);
-
- if (!found)
- return base::Time();
-
- double last_used_time;
- found = settings_dictionary->GetDoubleWithoutPathExpansion(
- kLastUsed, &last_used_time);
-
- if (!found)
- return base::Time();
-
- return base::Time::FromDoubleT(last_used_time);
-}
-
size_t ContentSettingsPref::GetNumExceptions() {
return value_map_.size();
}
@@ -436,7 +374,6 @@ void ContentSettingsPref::UpdatePref(
// Update settings dictionary.
if (value == NULL) {
settings_dictionary->RemoveWithoutPathExpansion(kSettingPath, NULL);
- settings_dictionary->RemoveWithoutPathExpansion(kLastUsed, NULL);
} else {
settings_dictionary->SetWithoutPathExpansion(
kSettingPath, value->DeepCopy());

Powered by Google App Engine
This is Rietveld 408576698