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

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

Issue 1252073002: Move pref names and default value into WebsiteSettingsInfo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@website-settings-registry-simple
Patch Set: Created 5 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: components/content_settings/core/browser/website_settings_info.cc
diff --git a/components/content_settings/core/browser/website_settings_info.cc b/components/content_settings/core/browser/website_settings_info.cc
index fa19d9cf561f24f28edbc6581a843d7ce4e92556..5d7500837d1177708414a0cadaba3f07af89fa03 100644
--- a/components/content_settings/core/browser/website_settings_info.cc
+++ b/components/content_settings/core/browser/website_settings_info.cc
@@ -4,11 +4,40 @@
#include "components/content_settings/core/browser/website_settings_info.h"
+#include "base/logging.h"
+#include "base/strings/string_util.h"
+#include "base/values.h"
+
+namespace {
+
+const char* kPrefPrefix = "profile.content_settings.exceptions.";
+const char* kDefaultPrefPrefix = "profile.default_content_setting_values.";
+
+std::string GetPrefName(const std::string& name, const char* prefix) {
+ std::string pref_name = name;
+ base::ReplaceChars(pref_name, "-", "_", &pref_name);
+ return std::string(prefix).append(pref_name);
+}
+
+} // namespace
+
namespace content_settings {
-WebsiteSettingsInfo::WebsiteSettingsInfo(ContentSettingsType type,
- const std::string& name)
- : type_(type), name_(name) {}
+WebsiteSettingsInfo::WebsiteSettingsInfo(
+ ContentSettingsType type,
+ const std::string& name,
+ scoped_ptr<base::Value> initial_default_value)
+ : type_(type),
+ name_(name),
+ pref_name_(GetPrefName(name, kPrefPrefix)),
+ default_value_pref_name_(GetPrefName(name, kDefaultPrefPrefix)),
+ initial_default_value_(initial_default_value.release()) {
Bernhard Bauer 2015/08/03 07:33:52 Use .Pass()
raymes 2015/08/03 07:41:41 Done.
+ // For legacy reasons the default value is currently restricted to be an int.
+ // TODO(raymes): We should migrate the underlying pref to be a dictionary
+ // rather than an int.
+ DCHECK(!initial_default_value_ ||
+ initial_default_value_->IsType(base::Value::TYPE_INTEGER));
+}
WebsiteSettingsInfo::~WebsiteSettingsInfo() {}

Powered by Google App Engine
This is Rietveld 408576698