| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options/content_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 base::Bind(&ContentSettingsHandler::RemoveException, | 1229 base::Bind(&ContentSettingsHandler::RemoveException, |
| 1230 base::Unretained(this))); | 1230 base::Unretained(this))); |
| 1231 web_ui()->RegisterMessageCallback("setException", | 1231 web_ui()->RegisterMessageCallback("setException", |
| 1232 base::Bind(&ContentSettingsHandler::SetException, | 1232 base::Bind(&ContentSettingsHandler::SetException, |
| 1233 base::Unretained(this))); | 1233 base::Unretained(this))); |
| 1234 web_ui()->RegisterMessageCallback("checkExceptionPatternValidity", | 1234 web_ui()->RegisterMessageCallback("checkExceptionPatternValidity", |
| 1235 base::Bind(&ContentSettingsHandler::CheckExceptionPatternValidity, | 1235 base::Bind(&ContentSettingsHandler::CheckExceptionPatternValidity, |
| 1236 base::Unretained(this))); | 1236 base::Unretained(this))); |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 void ContentSettingsHandler::ApplyWhitelist(ContentSettingsType content_type, | |
| 1240 ContentSetting default_setting) { | |
| 1241 HostContentSettingsMap* map = GetContentSettingsMap(); | |
| 1242 if (content_type != CONTENT_SETTINGS_TYPE_PLUGINS) | |
| 1243 return; | |
| 1244 const int kDefaultWhitelistVersion = 1; | |
| 1245 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | |
| 1246 int version = prefs->GetInteger( | |
| 1247 prefs::kContentSettingsDefaultWhitelistVersion); | |
| 1248 if (version >= kDefaultWhitelistVersion) | |
| 1249 return; | |
| 1250 ContentSetting old_setting = | |
| 1251 map->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, NULL); | |
| 1252 // TODO(bauerb): Remove this once the Google Talk plug-in works nicely with | |
| 1253 // click-to-play (b/6090625). | |
| 1254 if (old_setting == CONTENT_SETTING_ALLOW && | |
| 1255 default_setting == CONTENT_SETTING_ASK) { | |
| 1256 map->SetWebsiteSetting( | |
| 1257 ContentSettingsPattern::Wildcard(), | |
| 1258 ContentSettingsPattern::Wildcard(), | |
| 1259 CONTENT_SETTINGS_TYPE_PLUGINS, | |
| 1260 "google-talk", | |
| 1261 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); | |
| 1262 } | |
| 1263 prefs->SetInteger(prefs::kContentSettingsDefaultWhitelistVersion, | |
| 1264 kDefaultWhitelistVersion); | |
| 1265 } | |
| 1266 | |
| 1267 void ContentSettingsHandler::SetContentFilter(const base::ListValue* args) { | 1239 void ContentSettingsHandler::SetContentFilter(const base::ListValue* args) { |
| 1268 DCHECK_EQ(2U, args->GetSize()); | 1240 DCHECK_EQ(2U, args->GetSize()); |
| 1269 std::string group, setting; | 1241 std::string group, setting; |
| 1270 if (!(args->GetString(0, &group) && | 1242 if (!(args->GetString(0, &group) && |
| 1271 args->GetString(1, &setting))) { | 1243 args->GetString(1, &setting))) { |
| 1272 NOTREACHED(); | 1244 NOTREACHED(); |
| 1273 return; | 1245 return; |
| 1274 } | 1246 } |
| 1275 | 1247 |
| 1276 ContentSetting default_setting = ContentSettingFromString(setting); | 1248 ContentSetting default_setting = ContentSettingFromString(setting); |
| 1277 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); | 1249 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); |
| 1278 Profile* profile = Profile::FromWebUI(web_ui()); | 1250 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1279 | 1251 |
| 1280 #if defined(OS_CHROMEOS) | 1252 #if defined(OS_CHROMEOS) |
| 1281 // ChromeOS special case : in Guest mode settings are opened in Incognito | 1253 // ChromeOS special case : in Guest mode settings are opened in Incognito |
| 1282 // mode, so we need original profile to actually modify settings. | 1254 // mode, so we need original profile to actually modify settings. |
| 1283 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 1255 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
| 1284 profile = profile->GetOriginalProfile(); | 1256 profile = profile->GetOriginalProfile(); |
| 1285 #endif | 1257 #endif |
| 1286 | 1258 |
| 1287 | 1259 |
| 1288 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | 1260 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
| 1289 ApplyWhitelist(content_type, default_setting); | |
| 1290 map->SetDefaultContentSetting(content_type, default_setting); | 1261 map->SetDefaultContentSetting(content_type, default_setting); |
| 1291 | 1262 |
| 1292 switch (content_type) { | 1263 switch (content_type) { |
| 1293 case CONTENT_SETTINGS_TYPE_COOKIES: | 1264 case CONTENT_SETTINGS_TYPE_COOKIES: |
| 1294 content::RecordAction( | 1265 content::RecordAction( |
| 1295 UserMetricsAction("Options_DefaultCookieSettingChanged")); | 1266 UserMetricsAction("Options_DefaultCookieSettingChanged")); |
| 1296 break; | 1267 break; |
| 1297 case CONTENT_SETTINGS_TYPE_IMAGES: | 1268 case CONTENT_SETTINGS_TYPE_IMAGES: |
| 1298 content::RecordAction( | 1269 content::RecordAction( |
| 1299 UserMetricsAction("Options_DefaultImagesSettingChanged")); | 1270 UserMetricsAction("Options_DefaultImagesSettingChanged")); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { | 1509 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { |
| 1539 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1510 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1540 // Exceptions apply only when the feature is enabled. | 1511 // Exceptions apply only when the feature is enabled. |
| 1541 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1512 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1542 web_ui()->CallJavascriptFunction( | 1513 web_ui()->CallJavascriptFunction( |
| 1543 "ContentSettings.enableProtectedContentExceptions", | 1514 "ContentSettings.enableProtectedContentExceptions", |
| 1544 base::FundamentalValue(enable_exceptions)); | 1515 base::FundamentalValue(enable_exceptions)); |
| 1545 } | 1516 } |
| 1546 | 1517 |
| 1547 } // namespace options | 1518 } // namespace options |
| OLD | NEW |