OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/content_settings/core/browser/website_settings_info.h" | 5 #include "components/content_settings/core/browser/website_settings_info.h" |
6 | 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" |
| 9 #include "base/values.h" |
| 10 |
| 11 namespace { |
| 12 |
| 13 const char* kPrefPrefix = "profile.content_settings.exceptions."; |
| 14 const char* kDefaultPrefPrefix = "profile.default_content_setting_values."; |
| 15 |
| 16 std::string GetPrefName(const std::string& name, const char* prefix) { |
| 17 std::string pref_name = name; |
| 18 base::ReplaceChars(pref_name, "-", "_", &pref_name); |
| 19 return std::string(prefix).append(pref_name); |
| 20 } |
| 21 |
| 22 } // namespace |
| 23 |
7 namespace content_settings { | 24 namespace content_settings { |
8 | 25 |
9 WebsiteSettingsInfo::WebsiteSettingsInfo(ContentSettingsType type, | 26 WebsiteSettingsInfo::WebsiteSettingsInfo( |
10 const std::string& name) | 27 ContentSettingsType type, |
11 : type_(type), name_(name) {} | 28 const std::string& name, |
| 29 scoped_ptr<base::Value> initial_default_value) |
| 30 : type_(type), |
| 31 name_(name), |
| 32 pref_name_(GetPrefName(name, kPrefPrefix)), |
| 33 default_value_pref_name_(GetPrefName(name, kDefaultPrefPrefix)), |
| 34 initial_default_value_(initial_default_value.Pass()) { |
| 35 // For legacy reasons the default value is currently restricted to be an int. |
| 36 // TODO(raymes): We should migrate the underlying pref to be a dictionary |
| 37 // rather than an int. |
| 38 DCHECK(!initial_default_value_ || |
| 39 initial_default_value_->IsType(base::Value::TYPE_INTEGER)); |
| 40 } |
12 | 41 |
13 WebsiteSettingsInfo::~WebsiteSettingsInfo() {} | 42 WebsiteSettingsInfo::~WebsiteSettingsInfo() {} |
14 | 43 |
15 } // namespace content_settings | 44 } // namespace content_settings |
OLD | NEW |