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

Side by Side Diff: components/content_settings/core/browser/website_settings_registry.cc

Issue 1991623005: Only Register() platform specific content settings types on different platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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
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 uint32_t platform,
62 WebsiteSettingsInfo::IncognitoBehavior incognito_behavior) { 63 WebsiteSettingsInfo::IncognitoBehavior incognito_behavior) {
64 #if defined(OS_WIN)
65 if (!(platform & WebsiteSettingsInfo::PLATFORM_WINDOWS))
66 return nullptr;
67 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
68 if (!(platform & WebsiteSettingsInfo::PLATFORM_LINUX))
69 return nullptr;
70 #elif defined(OS_MACOSX) && !defined(OS_IOS)
71 if (!(platform & WebsiteSettingsInfo::PLATFORM_MAC))
72 return nullptr;
73 #elif defined(OS_CHROMEOS)
74 if (!(platform & WebsiteSettingsInfo::PLATFORM_CHROMEOS))
75 return nullptr;
76 #elif defined(OS_ANDROID)
77 if (!(platform & WebsiteSettingsInfo::PLATFORM_ANDROID))
78 return nullptr;
79 #elif defined(OS_IOS)
80 if (!(platform & WebsiteSettingsInfo::PLATFORM_IOS))
81 return nullptr;
82 // Make content settings unsyncable on ios.
raymes 2016/05/25 03:36:07 nit: maybe expand on why we do this, because excep
lshang 2016/05/25 10:38:16 Done.
83 sync_status = WebsiteSettingsInfo::UNSYNCABLE;
84 #endif
raymes 2016/05/25 03:36:07 Should we have: #else #error "Unsupported platform
lshang 2016/05/25 10:38:16 Done.
85
63 WebsiteSettingsInfo* info = new WebsiteSettingsInfo( 86 WebsiteSettingsInfo* info = new WebsiteSettingsInfo(
64 type, name, std::move(initial_default_value), sync_status, lossy_status, 87 type, name, std::move(initial_default_value), sync_status, lossy_status,
65 scoping_type, incognito_behavior); 88 scoping_type, incognito_behavior);
66 website_settings_info_[info->type()] = base::WrapUnique(info); 89 website_settings_info_[info->type()] = base::WrapUnique(info);
67 return info; 90 return info;
68 } 91 }
69 92
70 WebsiteSettingsRegistry::const_iterator WebsiteSettingsRegistry::begin() const { 93 WebsiteSettingsRegistry::const_iterator WebsiteSettingsRegistry::begin() const {
71 return const_iterator(website_settings_info_.begin()); 94 return const_iterator(website_settings_info_.begin());
72 } 95 }
73 96
74 WebsiteSettingsRegistry::const_iterator WebsiteSettingsRegistry::end() const { 97 WebsiteSettingsRegistry::const_iterator WebsiteSettingsRegistry::end() const {
75 return const_iterator(website_settings_info_.end()); 98 return const_iterator(website_settings_info_.end());
76 } 99 }
77 100
78 void WebsiteSettingsRegistry::Init() { 101 void WebsiteSettingsRegistry::Init() {
79 // TODO(raymes): This registration code should not have to be in a single 102 // 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 103 // location. It should be possible to register a setting from the code
81 // associated with it. 104 // associated with it.
82 105
83 // WARNING: The string names of the permissions passed in below are used to 106 // WARNING: The string names of the permissions passed in below are used to
84 // generate preference names and should never be changed! 107 // generate preference names and should never be changed!
85 108
86 // Website settings. 109 // Website settings.
87 Register(CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 110 Register(CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
88 "auto-select-certificate", nullptr, WebsiteSettingsInfo::UNSYNCABLE, 111 "auto-select-certificate", nullptr, WebsiteSettingsInfo::UNSYNCABLE,
89 WebsiteSettingsInfo::NOT_LOSSY, 112 WebsiteSettingsInfo::NOT_LOSSY,
90 WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE, 113 WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE,
114 WebsiteSettingsInfo::ALL_PLATFORMS,
91 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); 115 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO);
92 Register(CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions", 116 Register(CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions",
93 nullptr, WebsiteSettingsInfo::UNSYNCABLE, 117 nullptr, WebsiteSettingsInfo::UNSYNCABLE,
94 WebsiteSettingsInfo::NOT_LOSSY, 118 WebsiteSettingsInfo::NOT_LOSSY,
95 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, 119 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
120 WebsiteSettingsInfo::DESKTOP | WebsiteSettingsInfo::PLATFORM_ANDROID,
96 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); 121 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO);
97 Register(CONTENT_SETTINGS_TYPE_APP_BANNER, "app-banner", nullptr, 122 Register(CONTENT_SETTINGS_TYPE_APP_BANNER, "app-banner", nullptr,
98 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::LOSSY, 123 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::LOSSY,
99 WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE, 124 WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE,
125 WebsiteSettingsInfo::DESKTOP | WebsiteSettingsInfo::PLATFORM_ANDROID,
100 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); 126 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO);
101 Register(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, "site-engagement", nullptr, 127 Register(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, "site-engagement", nullptr,
102 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::LOSSY, 128 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::LOSSY,
103 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, 129 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
130 WebsiteSettingsInfo::DESKTOP | WebsiteSettingsInfo::PLATFORM_ANDROID,
104 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); 131 WebsiteSettingsInfo::INHERIT_IN_INCOGNITO);
105 Register(CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, "usb-chooser-data", nullptr, 132 Register(CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, "usb-chooser-data", nullptr,
106 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::NOT_LOSSY, 133 WebsiteSettingsInfo::UNSYNCABLE, WebsiteSettingsInfo::NOT_LOSSY,
107 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, 134 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE,
135 WebsiteSettingsInfo::DESKTOP | WebsiteSettingsInfo::PLATFORM_ANDROID,
108 WebsiteSettingsInfo::DONT_INHERIT_IN_INCOGNITO); 136 WebsiteSettingsInfo::DONT_INHERIT_IN_INCOGNITO);
109 } 137 }
110 138
111 } // namespace content_settings 139 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698