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

Side by Side Diff: chrome/browser/permissions/permission_util.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: Rebase Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_util.h" 5 #include "chrome/browser/permissions/permission_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
9 #include "chrome/browser/permissions/permission_uma_util.h" 9 #include "chrome/browser/permissions/permission_uma_util.h"
10 #include "components/content_settings/core/browser/host_content_settings_map.h" 10 #include "components/content_settings/core/browser/host_content_settings_map.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 : profile_(profile), 87 : profile_(profile),
88 primary_url_(primary_url), 88 primary_url_(primary_url),
89 secondary_url_(secondary_url), 89 secondary_url_(secondary_url),
90 content_type_(content_type), 90 content_type_(content_type),
91 source_ui_(source_ui) { 91 source_ui_(source_ui) {
92 if (!primary_url_.is_valid() || 92 if (!primary_url_.is_valid() ||
93 (!secondary_url_.is_valid() && !secondary_url_.is_empty())) { 93 (!secondary_url_.is_valid() && !secondary_url_.is_empty())) {
94 is_initially_allowed_ = false; 94 is_initially_allowed_ = false;
95 return; 95 return;
96 } 96 }
97 HostContentSettingsMap* map = 97 HostContentSettingsMap* settings_map =
98 HostContentSettingsMapFactory::GetForProfile(profile_); 98 HostContentSettingsMapFactory::GetForProfile(profile_);
99 ContentSetting initial_content_setting = map->GetContentSetting( 99 ContentSetting initial_content_setting = settings_map->GetContentSetting(
100 primary_url_, secondary_url_, content_type_, std::string()); 100 primary_url_, secondary_url_, content_type_, std::string());
101 is_initially_allowed_ = initial_content_setting == CONTENT_SETTING_ALLOW; 101 is_initially_allowed_ = initial_content_setting == CONTENT_SETTING_ALLOW;
102 } 102 }
103 103
104 PermissionUtil::ScopedRevocationReporter::ScopedRevocationReporter(
105 Profile* profile,
106 const ContentSettingsPattern& primary_pattern,
107 const ContentSettingsPattern& secondary_pattern,
108 ContentSettingsType content_type,
109 PermissionSourceUI source_ui)
110 : ScopedRevocationReporter(
111 profile,
112 GURL(primary_pattern.ToString()),
113 GURL((secondary_pattern == ContentSettingsPattern::Wildcard())
114 ? primary_pattern.ToString()
115 : secondary_pattern.ToString()),
116 content_type,
117 source_ui) {}
118
104 PermissionUtil::ScopedRevocationReporter::~ScopedRevocationReporter() { 119 PermissionUtil::ScopedRevocationReporter::~ScopedRevocationReporter() {
105 if (!is_initially_allowed_) 120 if (!is_initially_allowed_)
106 return; 121 return;
107 HostContentSettingsMap* map = 122 HostContentSettingsMap* settings_map =
108 HostContentSettingsMapFactory::GetForProfile(profile_); 123 HostContentSettingsMapFactory::GetForProfile(profile_);
109 ContentSetting final_content_setting = map->GetContentSetting( 124 ContentSetting final_content_setting = settings_map->GetContentSetting(
110 primary_url_, secondary_url_, content_type_, std::string()); 125 primary_url_, secondary_url_, content_type_, std::string());
111 if (final_content_setting != CONTENT_SETTING_ALLOW) { 126 if (final_content_setting != CONTENT_SETTING_ALLOW) {
112 PermissionType permission_type; 127 PermissionType permission_type;
113 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { 128 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) {
114 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_, 129 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_,
115 primary_url_, profile_); 130 primary_url_, profile_);
116 } 131 }
117 } 132 }
118 } 133 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_util.h ('k') | chrome/browser/permissions/permission_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698