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

Side by Side Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 2180723002: Add revocation metrics from OIB and content setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@revocation-reporter
Patch Set: Remove set custom host map Created 4 years, 5 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 (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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 12 matching lines...) Expand all
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/chrome_notification_types.h" 25 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
27 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" 27 #include "chrome/browser/content_settings/web_site_settings_uma_util.h"
28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
29 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 29 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
30 #include "chrome/browser/extensions/extension_special_storage_policy.h" 30 #include "chrome/browser/extensions/extension_special_storage_policy.h"
31 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 31 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
32 #include "chrome/browser/permissions/chooser_context_base.h" 32 #include "chrome/browser/permissions/chooser_context_base.h"
33 #include "chrome/browser/permissions/permission_uma_util.h"
34 #include "chrome/browser/permissions/permission_util.h"
33 #include "chrome/browser/profiles/profile.h" 35 #include "chrome/browser/profiles/profile.h"
34 #include "chrome/browser/ui/browser_list.h" 36 #include "chrome/browser/ui/browser_list.h"
35 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" 37 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
36 #include "chrome/browser/ui/webui/site_settings_helper.h" 38 #include "chrome/browser/ui/webui/site_settings_helper.h"
37 #include "chrome/browser/usb/usb_chooser_context.h" 39 #include "chrome/browser/usb/usb_chooser_context.h"
38 #include "chrome/browser/usb/usb_chooser_context_factory.h" 40 #include "chrome/browser/usb/usb_chooser_context_factory.h"
39 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
40 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 42 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
41 #include "chrome/common/features.h" 43 #include "chrome/common/features.h"
42 #include "chrome/common/pref_names.h" 44 #include "chrome/common/pref_names.h"
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 ContentSettingsType type) { 1292 ContentSettingsType type) {
1291 std::string mode; 1293 std::string mode;
1292 bool rv = args->GetString(1, &mode); 1294 bool rv = args->GetString(1, &mode);
1293 DCHECK(rv); 1295 DCHECK(rv);
1294 1296
1295 std::string pattern; 1297 std::string pattern;
1296 rv = args->GetString(2, &pattern); 1298 rv = args->GetString(2, &pattern);
1297 DCHECK(rv); 1299 DCHECK(rv);
1298 1300
1299 // The fourth argument to this handler is optional. 1301 // The fourth argument to this handler is optional.
1300 std::string secondary_pattern; 1302 std::string secondary_pattern_string;
1301 if (args->GetSize() >= 4U) { 1303 if (args->GetSize() >= 4U) {
1302 rv = args->GetString(3, &secondary_pattern); 1304 rv = args->GetString(3, &secondary_pattern_string);
1303 DCHECK(rv); 1305 DCHECK(rv);
1304 } 1306 }
1305 1307
1306 HostContentSettingsMap* settings_map = 1308 HostContentSettingsMap* settings_map =
1307 mode == "normal" ? GetContentSettingsMap() : 1309 mode == "normal" ? GetContentSettingsMap() :
1308 GetOTRContentSettingsMap(); 1310 GetOTRContentSettingsMap();
1309 if (settings_map) { 1311 if (settings_map) {
1312 Profile* profile = Profile::FromWebUI(web_ui());
1313 if (mode != "normal")
1314 profile = profile->GetOffTheRecordProfile();
raymes 2016/07/26 07:50:03 I think we should probably simplify this - possibl
stefanocs 2016/07/26 12:00:05 Done.
1315 ContentSettingsPattern primary_pattern =
1316 ContentSettingsPattern::FromString(pattern);
1317 ContentSettingsPattern secondary_pattern =
1318 secondary_pattern_string.empty()
1319 ? ContentSettingsPattern::Wildcard()
1320 : ContentSettingsPattern::FromString(secondary_pattern_string);
1321 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
1322 profile, primary_pattern, secondary_pattern, type,
1323 PermissionSourceUI::SITE_SETTINGS);
1324
1310 settings_map->SetContentSettingCustomScope( 1325 settings_map->SetContentSettingCustomScope(
1311 ContentSettingsPattern::FromString(pattern), 1326 primary_pattern, secondary_pattern, type, std::string(),
1312 secondary_pattern.empty() 1327 CONTENT_SETTING_DEFAULT);
1313 ? ContentSettingsPattern::Wildcard()
1314 : ContentSettingsPattern::FromString(secondary_pattern),
1315 type, std::string(), CONTENT_SETTING_DEFAULT);
1316 } 1328 }
1317 } 1329 }
1318 1330
1319 void ContentSettingsHandler::RemoveZoomLevelException( 1331 void ContentSettingsHandler::RemoveZoomLevelException(
1320 const base::ListValue* args) { 1332 const base::ListValue* args) {
1321 std::string mode; 1333 std::string mode;
1322 bool rv = args->GetString(1, &mode); 1334 bool rv = args->GetString(1, &mode);
1323 DCHECK(rv); 1335 DCHECK(rv);
1324 1336
1325 std::string pattern; 1337 std::string pattern;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 // The settings map could be null if the mode was OTR but the OTR profile 1487 // The settings map could be null if the mode was OTR but the OTR profile
1476 // got destroyed before we received this message. 1488 // got destroyed before we received this message.
1477 if (!settings_map) 1489 if (!settings_map)
1478 return; 1490 return;
1479 1491
1480 ContentSetting setting_type; 1492 ContentSetting setting_type;
1481 bool result = 1493 bool result =
1482 content_settings::ContentSettingFromString(setting, &setting_type); 1494 content_settings::ContentSettingFromString(setting, &setting_type);
1483 DCHECK(result); 1495 DCHECK(result);
1484 1496
1497 Profile* profile = Profile::FromWebUI(web_ui());
1498 if (mode != "normal")
1499 profile = profile->GetOffTheRecordProfile();
1500
1501 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
1502 profile, ContentSettingsPattern::FromString(pattern),
1503 ContentSettingsPattern::Wildcard(), type,
1504 PermissionSourceUI::SITE_SETTINGS);
1505
1485 settings_map->SetContentSettingCustomScope( 1506 settings_map->SetContentSettingCustomScope(
1486 ContentSettingsPattern::FromString(pattern), 1507 ContentSettingsPattern::FromString(pattern),
1487 ContentSettingsPattern::Wildcard(), type, std::string(), setting_type); 1508 ContentSettingsPattern::Wildcard(), type, std::string(), setting_type);
1488 WebSiteSettingsUmaUtil::LogPermissionChange(type, setting_type); 1509 WebSiteSettingsUmaUtil::LogPermissionChange(type, setting_type);
1489 } 1510 }
1490 } 1511 }
1491 1512
1492 void ContentSettingsHandler::CheckExceptionPatternValidity( 1513 void ContentSettingsHandler::CheckExceptionPatternValidity(
1493 const base::ListValue* args) { 1514 const base::ListValue* args) {
1494 std::string type_string; 1515 std::string type_string;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 1666
1646 // Exceptions apply only when the feature is enabled. 1667 // Exceptions apply only when the feature is enabled.
1647 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1668 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1648 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1669 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1649 web_ui()->CallJavascriptFunctionUnsafe( 1670 web_ui()->CallJavascriptFunctionUnsafe(
1650 "ContentSettings.enableProtectedContentExceptions", 1671 "ContentSettings.enableProtectedContentExceptions",
1651 base::FundamentalValue(enable_exceptions)); 1672 base::FundamentalValue(enable_exceptions));
1652 } 1673 }
1653 1674
1654 } // namespace options 1675 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698