OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/permissions/permission_uma_util.h" | 5 #include "chrome/browser/permissions/permission_uma_util.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
12 #include "chrome/browser/permissions/permission_manager.h" | 13 #include "chrome/browser/permissions/permission_manager.h" |
13 #include "chrome/browser/permissions/permission_util.h" | 14 #include "chrome/browser/permissions/permission_util.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
15 #include "components/rappor/rappor_service.h" | 17 #include "components/rappor/rappor_service.h" |
16 #include "components/rappor/rappor_utils.h" | 18 #include "components/rappor/rappor_utils.h" |
17 #include "content/public/browser/permission_type.h" | 19 #include "content/public/browser/permission_type.h" |
18 #include "content/public/common/origin_util.h" | 20 #include "content/public/common/origin_util.h" |
19 #include "url/gurl.h" | 21 #include "url/gurl.h" |
20 | 22 |
21 // UMA keys need to be statically initialized so plain function would not | 23 // UMA keys need to be statically initialized so plain function would not |
22 // work. Use a Macro instead. | 24 // work. Use a Macro instead. |
23 #define PERMISSION_ACTION_UMA(secure_origin, permission, permission_secure, \ | 25 #define PERMISSION_ACTION_UMA(secure_origin, permission, permission_secure, \ |
24 permission_insecure, action) \ | 26 permission_insecure, action) \ |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 const GURL& revoked_origin) { | 286 const GURL& revoked_origin) { |
285 // TODO(tsergeant): Expand metrics definitions for revocation to include all | 287 // TODO(tsergeant): Expand metrics definitions for revocation to include all |
286 // permissions. | 288 // permissions. |
287 if (permission == PermissionType::NOTIFICATIONS || | 289 if (permission == PermissionType::NOTIFICATIONS || |
288 permission == PermissionType::GEOLOCATION || | 290 permission == PermissionType::GEOLOCATION || |
289 permission == PermissionType::AUDIO_CAPTURE || | 291 permission == PermissionType::AUDIO_CAPTURE || |
290 permission == PermissionType::VIDEO_CAPTURE) { | 292 permission == PermissionType::VIDEO_CAPTURE) { |
291 RecordPermissionAction(permission, REVOKED, revoked_origin); | 293 RecordPermissionAction(permission, REVOKED, revoked_origin); |
292 } | 294 } |
293 } | 295 } |
| 296 |
| 297 void PermissionUmaUtil::OnContentsettingChanged( |
| 298 Profile* profile, |
| 299 const ContentSettingsPattern& primary_pattern, |
| 300 const ContentSettingsPattern& secondary_pattern, |
| 301 ContentSettingsType content_type, |
| 302 ContentSetting previous_value) { |
| 303 if (primary_pattern.HasNoWildcard()) { |
| 304 GURL primary_url(primary_pattern.ToString()); |
| 305 GURL secondary_url; |
| 306 if (secondary_pattern.HasNoWildcard()) |
| 307 secondary_url = GURL(secondary_pattern.ToString()); |
| 308 else |
| 309 secondary_url = primary_url; |
| 310 |
| 311 ContentSetting new_value = |
| 312 HostContentSettingsMapFactory::GetForProfile(profile) |
| 313 ->GetContentSetting(primary_url, secondary_url, content_type, ""); |
| 314 |
| 315 if (previous_value == CONTENT_SETTING_ALLOW && |
| 316 (new_value == CONTENT_SETTING_BLOCK || |
| 317 new_value == CONTENT_SETTING_DEFAULT)) { |
| 318 // This was a revocation action |
| 319 } |
| 320 } |
| 321 } |
OLD | NEW |