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

Side by Side Diff: chrome/browser/permissions/permission_util.cc

Issue 2463393003: Record permission prompt gesture metrics on Android. (Closed)
Patch Set: Record Accepted and Denied Created 4 years, 1 month 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 "build/build_config.h"
7 #include "base/feature_list.h" 8 #include "base/feature_list.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
10 #include "chrome/browser/permissions/permission_uma_util.h" 11 #include "chrome/browser/permissions/permission_uma_util.h"
11 #include "chrome/common/chrome_features.h" 12 #include "chrome/common/chrome_features.h"
12 #include "components/content_settings/core/browser/host_content_settings_map.h" 13 #include "components/content_settings/core/browser/host_content_settings_map.h"
13 #include "content/public/browser/permission_type.h" 14 #include "content/public/browser/permission_type.h"
14 15
15 using content::PermissionType; 16 using content::PermissionType;
16 17
(...skipping 30 matching lines...) Expand all
47 return "BackgroundSync"; 48 return "BackgroundSync";
48 case content::PermissionType::FLASH: 49 case content::PermissionType::FLASH:
49 return "Flash"; 50 return "Flash";
50 case content::PermissionType::NUM: 51 case content::PermissionType::NUM:
51 break; 52 break;
52 } 53 }
53 NOTREACHED(); 54 NOTREACHED();
54 return std::string(); 55 return std::string();
55 } 56 }
56 57
58 PermissionRequestType PermissionUtil::GetRequestType(
59 content::PermissionType type) {
60 switch (type) {
61 case content::PermissionType::GEOLOCATION:
62 return PermissionRequestType::PERMISSION_GEOLOCATION;
63 #if defined(ENABLE_NOTIFICATIONS)
64 case content::PermissionType::NOTIFICATIONS:
65 return PermissionRequestType::PERMISSION_NOTIFICATIONS;
66 #endif
67 case content::PermissionType::MIDI_SYSEX:
68 return PermissionRequestType::PERMISSION_MIDI_SYSEX;
69 case content::PermissionType::PUSH_MESSAGING:
70 return PermissionRequestType::PERMISSION_PUSH_MESSAGING;
71 #if defined(OS_CHROMEOS)
72 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
73 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER;
74 #endif
75 case content::PermissionType::FLASH:
76 return PermissionRequestType::PERMISSION_FLASH;
77 default:
78 NOTREACHED();
79 return PermissionRequestType::UNKNOWN;
80 }
81 }
82
83 PermissionRequestGestureType PermissionUtil::GetGestureType(bool user_gesture) {
84 return user_gesture ? PermissionRequestGestureType::GESTURE
85 : PermissionRequestGestureType::NO_GESTURE;
86 }
87
57 bool PermissionUtil::GetPermissionType(ContentSettingsType type, 88 bool PermissionUtil::GetPermissionType(ContentSettingsType type,
58 PermissionType* out) { 89 PermissionType* out) {
59 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 90 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
60 *out = PermissionType::GEOLOCATION; 91 *out = PermissionType::GEOLOCATION;
61 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 92 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
62 *out = PermissionType::NOTIFICATIONS; 93 *out = PermissionType::NOTIFICATIONS;
63 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 94 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
64 *out = PermissionType::MIDI_SYSEX; 95 *out = PermissionType::MIDI_SYSEX;
65 } else if (type == CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) { 96 } else if (type == CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) {
66 *out = PermissionType::DURABLE_STORAGE; 97 *out = PermissionType::DURABLE_STORAGE;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ContentSetting final_content_setting = settings_map->GetContentSetting( 162 ContentSetting final_content_setting = settings_map->GetContentSetting(
132 primary_url_, secondary_url_, content_type_, std::string()); 163 primary_url_, secondary_url_, content_type_, std::string());
133 if (final_content_setting != CONTENT_SETTING_ALLOW) { 164 if (final_content_setting != CONTENT_SETTING_ALLOW) {
134 PermissionType permission_type; 165 PermissionType permission_type;
135 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { 166 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) {
136 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_, 167 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_,
137 primary_url_, profile_); 168 primary_url_, profile_);
138 } 169 }
139 } 170 }
140 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698