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

Side by Side Diff: chrome/browser/ui/webui/settings/site_settings_handler.cc

Issue 1882793002: Site Settings: Use only string values for permissions on the JS side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ui/webui/settings/site_settings_handler.h" 5 #include "chrome/browser/ui/webui/settings/site_settings_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" 8 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 new BrowsingDataLocalStorageHelper(profile_); 147 new BrowsingDataLocalStorageHelper(profile_);
148 local_storage_helper->DeleteOrigin(url); 148 local_storage_helper->DeleteOrigin(url);
149 } 149 }
150 } 150 }
151 151
152 void SiteSettingsHandler::HandleSetDefaultValueForContentType( 152 void SiteSettingsHandler::HandleSetDefaultValueForContentType(
153 const base::ListValue* args) { 153 const base::ListValue* args) {
154 CHECK_EQ(2U, args->GetSize()); 154 CHECK_EQ(2U, args->GetSize());
155 double content_type; 155 double content_type;
156 CHECK(args->GetDouble(0, &content_type)); 156 CHECK(args->GetDouble(0, &content_type));
157 double default_setting; 157 std::string setting;
158 CHECK(args->GetDouble(1, &default_setting)); 158 CHECK(args->GetString(1, &setting));
159 ContentSetting default_setting;
160 CHECK(content_settings::ContentSettingFromString(setting, &default_setting));
159 161
160 HostContentSettingsMap* map = 162 HostContentSettingsMap* map =
161 HostContentSettingsMapFactory::GetForProfile(profile_); 163 HostContentSettingsMapFactory::GetForProfile(profile_);
162 map->SetDefaultContentSetting( 164 map->SetDefaultContentSetting(
163 static_cast<ContentSettingsType>(static_cast<int>(content_type)), 165 static_cast<ContentSettingsType>(static_cast<int>(content_type)),
164 static_cast<ContentSetting>(static_cast<int>(default_setting))); 166 default_setting);
165 } 167 }
166 168
167 void SiteSettingsHandler::HandleGetDefaultValueForContentType( 169 void SiteSettingsHandler::HandleGetDefaultValueForContentType(
168 const base::ListValue* args) { 170 const base::ListValue* args) {
169 CHECK_EQ(2U, args->GetSize()); 171 CHECK_EQ(2U, args->GetSize());
170 const base::Value* callback_id; 172 const base::Value* callback_id;
171 CHECK(args->Get(0, &callback_id)); 173 CHECK(args->Get(0, &callback_id));
172 double type; 174 double type;
173 CHECK(args->GetDouble(1, &type)); 175 CHECK(args->GetDouble(1, &type));
174 176
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 232
231 void SiteSettingsHandler::HandleSetCategoryPermissionForOrigin( 233 void SiteSettingsHandler::HandleSetCategoryPermissionForOrigin(
232 const base::ListValue* args) { 234 const base::ListValue* args) {
233 CHECK_EQ(4U, args->GetSize()); 235 CHECK_EQ(4U, args->GetSize());
234 std::string primary_pattern; 236 std::string primary_pattern;
235 CHECK(args->GetString(0, &primary_pattern)); 237 CHECK(args->GetString(0, &primary_pattern));
236 std::string secondary_pattern; 238 std::string secondary_pattern;
237 CHECK(args->GetString(1, &secondary_pattern)); 239 CHECK(args->GetString(1, &secondary_pattern));
238 double type; 240 double type;
239 CHECK(args->GetDouble(2, &type)); 241 CHECK(args->GetDouble(2, &type));
240 double value; 242 std::string value;
241 CHECK(args->GetDouble(3, &value)); 243 CHECK(args->GetString(3, &value));
242 244
243 ContentSettingsType content_type = 245 ContentSettingsType content_type =
244 static_cast<ContentSettingsType>(static_cast<int>(type)); 246 static_cast<ContentSettingsType>(static_cast<int>(type));
245 ContentSetting setting = static_cast<ContentSetting>(static_cast<int>(value)); 247 ContentSetting setting;
248 CHECK(content_settings::ContentSettingFromString(value, &setting));
246 249
247 HostContentSettingsMap* map = 250 HostContentSettingsMap* map =
248 HostContentSettingsMapFactory::GetForProfile(profile_); 251 HostContentSettingsMapFactory::GetForProfile(profile_);
249 map->SetContentSettingCustomScope( 252 map->SetContentSettingCustomScope(
250 ContentSettingsPattern::FromString(primary_pattern), 253 ContentSettingsPattern::FromString(primary_pattern),
251 secondary_pattern.empty() ? 254 secondary_pattern.empty() ?
252 ContentSettingsPattern::Wildcard() : 255 ContentSettingsPattern::Wildcard() :
253 ContentSettingsPattern::FromString(secondary_pattern), 256 ContentSettingsPattern::FromString(secondary_pattern),
254 content_type, "", setting); 257 content_type, "", setting);
255 } 258 }
256 259
257 } // namespace settings 260 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698