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_registry.h" | 5 #include "components/content_settings/core/browser/website_settings_registry.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 return nullptr; | 52 return nullptr; |
53 } | 53 } |
54 | 54 |
55 const WebsiteSettingsInfo* WebsiteSettingsRegistry::Register( | 55 const WebsiteSettingsInfo* WebsiteSettingsRegistry::Register( |
56 ContentSettingsType type, | 56 ContentSettingsType type, |
57 const std::string& name, | 57 const std::string& name, |
58 std::unique_ptr<base::Value> initial_default_value, | 58 std::unique_ptr<base::Value> initial_default_value, |
59 WebsiteSettingsInfo::SyncStatus sync_status, | 59 WebsiteSettingsInfo::SyncStatus sync_status, |
60 WebsiteSettingsInfo::LossyStatus lossy_status, | 60 WebsiteSettingsInfo::LossyStatus lossy_status, |
61 WebsiteSettingsInfo::ScopingType scoping_type, | 61 WebsiteSettingsInfo::ScopingType scoping_type, |
| 62 Platforms platform, |
62 WebsiteSettingsInfo::IncognitoBehavior incognito_behavior) { | 63 WebsiteSettingsInfo::IncognitoBehavior incognito_behavior) { |
| 64 |
| 65 #if defined(OS_WIN) |
| 66 if (!(platform & PLATFORM_WINDOWS)) |
| 67 return nullptr; |
| 68 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 69 if (!(platform & PLATFORM_LINUX)) |
| 70 return nullptr; |
| 71 #elif defined(OS_MACOSX) && !defined(OS_IOS) |
| 72 if (!(platform & PLATFORM_MAC)) |
| 73 return nullptr; |
| 74 #elif defined(OS_CHROMEOS) |
| 75 if (!(platform & PLATFORM_CHROMEOS)) |
| 76 return nullptr; |
| 77 #elif defined(OS_ANDROID) |
| 78 if (!(platform & PLATFORM_ANDROID)) |
| 79 return nullptr; |
| 80 #elif defined(OS_IOS) |
| 81 if (!(platform & PLATFORM_IOS)) |
| 82 return nullptr; |
| 83 // Only default settings for Cookies and Popups are used in iOS. Exceptions |
| 84 // and all the other content setting types are not used in iOS currently. So |
| 85 // make content settings unsyncable on iOS for now. |
| 86 // TODO(lshang): address this once we have proper content settings on iOS. |
| 87 sync_status = WebsiteSettingsInfo::UNSYNCABLE; |
| 88 #else |
| 89 #error "Unsupported platform" |
| 90 #endif |
| 91 |
63 WebsiteSettingsInfo* info = new WebsiteSettingsInfo( | 92 WebsiteSettingsInfo* info = new WebsiteSettingsInfo( |
64 type, name, std::move(initial_default_value), sync_status, lossy_status, | 93 type, name, std::move(initial_default_value), sync_status, lossy_status, |
65 scoping_type, incognito_behavior); | 94 scoping_type, incognito_behavior); |
66 website_settings_info_[info->type()] = base::WrapUnique(info); | 95 website_settings_info_[info->type()] = base::WrapUnique(info); |
67 return info; | 96 return info; |
68 } | 97 } |
69 | 98 |
70 WebsiteSettingsRegistry::const_iterator WebsiteSettingsRegistry::begin() const { | 99 WebsiteSettingsRegistry::const_iterator WebsiteSettingsRegistry::begin() const { |
71 return const_iterator(website_settings_info_.begin()); | 100 return const_iterator(website_settings_info_.begin()); |
72 } | 101 } |
73 | 102 |
74 WebsiteSettingsRegistry::const_iterator WebsiteSettingsRegistry::end() const { | 103 WebsiteSettingsRegistry::const_iterator WebsiteSettingsRegistry::end() const { |
75 return const_iterator(website_settings_info_.end()); | 104 return const_iterator(website_settings_info_.end()); |
76 } | 105 } |
77 | 106 |
78 void WebsiteSettingsRegistry::Init() { | 107 void WebsiteSettingsRegistry::Init() { |
79 // TODO(raymes): This registration code should not have to be in a single | 108 // TODO(raymes): This registration code should not have to be in a single |
80 // location. It should be possible to register a setting from the code | 109 // location. It should be possible to register a setting from the code |
81 // associated with it. | 110 // associated with it. |
82 | 111 |
83 // WARNING: The string names of the permissions passed in below are used to | 112 // WARNING: The string names of the permissions passed in below are used to |
84 // generate preference names and should never be changed! | 113 // generate preference names and should never be changed! |
85 | 114 |
86 // Website settings. | 115 // Website settings. |
87 Register(CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 116 Register(CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
88 "auto-select-certificate", nullptr, WebsiteSettingsInfo::UNSYNCABLE, | 117 "auto-select-certificate", nullptr, WebsiteSettingsInfo::UNSYNCABLE, |
89 WebsiteSettingsInfo::NOT_LOSSY, | 118 WebsiteSettingsInfo::NOT_LOSSY, |
90 WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE, | 119 WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE, ALL_PLATFORMS, |
91 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); | 120 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); |
92 Register(CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions", | 121 Register(CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, |
93 nullptr, WebsiteSettingsInfo::UNSYNCABLE, | 122 "ssl-cert-decisions", nullptr, WebsiteSettingsInfo::UNSYNCABLE, |
94 WebsiteSettingsInfo::NOT_LOSSY, | 123 WebsiteSettingsInfo::NOT_LOSSY, |
95 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, | 124 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| 125 DESKTOP | PLATFORM_ANDROID, |
96 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); | 126 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); |
97 Register(CONTENT_SETTINGS_TYPE_APP_BANNER, "app-banner", nullptr, | 127 Register(CONTENT_SETTINGS_TYPE_APP_BANNER, "app-banner", nullptr, |
98 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::LOSSY, | 128 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::LOSSY, |
99 WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE, | 129 WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE, |
| 130 DESKTOP | PLATFORM_ANDROID, |
100 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); | 131 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); |
101 Register(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, "site-engagement", nullptr, | 132 Register(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, "site-engagement", nullptr, |
102 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::LOSSY, | 133 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::LOSSY, |
103 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, | 134 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| 135 DESKTOP | PLATFORM_ANDROID, |
104 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); | 136 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); |
105 Register(CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, "usb-chooser-data", nullptr, | 137 Register(CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, "usb-chooser-data", nullptr, |
106 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::NOT_LOSSY, | 138 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::NOT_LOSSY, |
107 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, | 139 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, |
| 140 DESKTOP | PLATFORM_ANDROID, |
108 WebsiteSettingsInfo::DONT_INHERIT_IN_INCOGNITO); | 141 WebsiteSettingsInfo::DONT_INHERIT_IN_INCOGNITO); |
109 } | 142 } |
110 | 143 |
111 } // namespace content_settings | 144 } // namespace content_settings |
OLD | NEW |