Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / components / content_settings / core / browser / website_settings_info.cc
blob20faa27ca069bca24fee0ae147a8ec9d4a1bde04
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
3 // found in the LICENSE file.
5 #include "components/content_settings/core/browser/website_settings_info.h"
7 #include "base/logging.h"
8 #include "base/prefs/pref_registry.h"
9 #include "base/strings/string_util.h"
10 #include "base/values.h"
11 #include "components/pref_registry/pref_registry_syncable.h"
13 namespace {
15 const char kPrefPrefix[] = "profile.content_settings.exceptions.";
16 const char kDefaultPrefPrefix[] = "profile.default_content_setting_values.";
18 std::string GetPrefName(const std::string& name, const char* prefix) {
19 std::string pref_name = name;
20 base::ReplaceChars(pref_name, "-", "_", &pref_name);
21 return std::string(prefix).append(pref_name);
24 } // namespace
26 namespace content_settings {
28 WebsiteSettingsInfo::WebsiteSettingsInfo(
29 ContentSettingsType type,
30 const std::string& name,
31 scoped_ptr<base::Value> initial_default_value,
32 SyncStatus sync_status,
33 LossyStatus lossy_status)
34 : type_(type),
35 name_(name),
36 pref_name_(GetPrefName(name, kPrefPrefix)),
37 default_value_pref_name_(GetPrefName(name, kDefaultPrefPrefix)),
38 initial_default_value_(initial_default_value.Pass()),
39 sync_status_(sync_status),
40 lossy_status_(lossy_status) {
41 // For legacy reasons the default value is currently restricted to be an int.
42 // TODO(raymes): We should migrate the underlying pref to be a dictionary
43 // rather than an int.
44 DCHECK(!initial_default_value_ ||
45 initial_default_value_->IsType(base::Value::TYPE_INTEGER));
48 WebsiteSettingsInfo::~WebsiteSettingsInfo() {}
50 uint32 WebsiteSettingsInfo::GetPrefRegistrationFlags() const {
51 uint32 flags = PrefRegistry::NO_REGISTRATION_FLAGS;
53 if (sync_status_ == SYNCABLE)
54 flags |= user_prefs::PrefRegistrySyncable::SYNCABLE_PREF;
56 if (lossy_status_ == LOSSY)
57 flags |= PrefRegistry::LOSSY_PREF;
59 return flags;
62 } // namespace content_settings