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

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

Issue 1849673002: Add metrics for user manually added exceptions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix patch failures 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 (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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/metrics/histogram_macros.h"
19 #include "base/stl_util.h" 20 #include "base/stl_util.h"
20 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "base/values.h" 23 #include "base/values.h"
23 #include "build/build_config.h" 24 #include "build/build_config.h"
24 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 27 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
27 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" 28 #include "chrome/browser/content_settings/web_site_settings_uma_util.h"
28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1526
1526 ContentSetting setting_type; 1527 ContentSetting setting_type;
1527 bool result = 1528 bool result =
1528 content_settings::ContentSettingFromString(setting, &setting_type); 1529 content_settings::ContentSettingFromString(setting, &setting_type);
1529 DCHECK(result); 1530 DCHECK(result);
1530 1531
1531 settings_map->SetContentSettingCustomScope( 1532 settings_map->SetContentSettingCustomScope(
1532 ContentSettingsPattern::FromString(pattern), 1533 ContentSettingsPattern::FromString(pattern),
1533 ContentSettingsPattern::Wildcard(), type, std::string(), setting_type); 1534 ContentSettingsPattern::Wildcard(), type, std::string(), setting_type);
1534 WebSiteSettingsUmaUtil::LogPermissionChange(type, setting_type); 1535 WebSiteSettingsUmaUtil::LogPermissionChange(type, setting_type);
1536
1537 size_t num_values;
1538 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
1539 UMA_HISTOGRAM_ENUMERATION("ContentSettings.AddManualException",
1540 histogram_value, num_values);
raymes 2016/04/12 23:22:39 Do you think this histogram will be useful?
lshang 2016/04/14 04:55:29 Done.
1535 } 1541 }
1536 } 1542 }
1537 1543
1538 void ContentSettingsHandler::CheckExceptionPatternValidity( 1544 void ContentSettingsHandler::CheckExceptionPatternValidity(
1539 const base::ListValue* args) { 1545 const base::ListValue* args) {
1540 std::string type_string; 1546 std::string type_string;
1541 CHECK(args->GetString(0, &type_string)); 1547 CHECK(args->GetString(0, &type_string));
1542 std::string mode_string; 1548 std::string mode_string;
1543 CHECK(args->GetString(1, &mode_string)); 1549 CHECK(args->GetString(1, &mode_string));
1544 std::string pattern_string; 1550 std::string pattern_string;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 1711
1706 // Exceptions apply only when the feature is enabled. 1712 // Exceptions apply only when the feature is enabled.
1707 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1713 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1708 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1714 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1709 web_ui()->CallJavascriptFunction( 1715 web_ui()->CallJavascriptFunction(
1710 "ContentSettings.enableProtectedContentExceptions", 1716 "ContentSettings.enableProtectedContentExceptions",
1711 base::FundamentalValue(enable_exceptions)); 1717 base::FundamentalValue(enable_exceptions));
1712 } 1718 }
1713 1719
1714 } // namespace options 1720 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698