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(ContentSettingsType type, |
10 const std::string& name) | 27 const std::string& name, |
11 : type_(type), name_(name) {} | 28 base::Value* initial_default_value) |
msramek
2015/07/29 09:20:07
It seems a bit unnecessary that we convert Content
raymes
2015/07/30 05:25:03
Done. Since it's only used in one place I haven't
msramek
2015/07/31 15:27:49
Abstraction on top for permission-like things also
| |
29 : type_(type), | |
30 name_(name), | |
31 pref_name_(GetPrefName(name, kPrefPrefix)), | |
32 default_value_pref_name_(GetPrefName(name, kDefaultPrefPrefix)), | |
33 initial_default_value_(0) { | |
34 // For legacy reasons the default value is currently restricted to be an int. | |
35 // TODO(raymes): We should migrate the underlying pref to be a dictionary | |
36 // rather than an int. | |
37 if (initial_default_value) { | |
38 bool success = initial_default_value->GetAsInteger(&initial_default_value_); | |
39 DCHECK(success); | |
40 } | |
41 } | |
12 | 42 |
13 WebsiteSettingsInfo::~WebsiteSettingsInfo() {} | 43 WebsiteSettingsInfo::~WebsiteSettingsInfo() {} |
14 | 44 |
15 } // namespace content_settings | 45 } // namespace content_settings |
OLD | NEW |