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

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

Issue 2463393003: Record permission prompt gesture metrics on Android. (Closed)
Patch Set: Address comments 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
« no previous file with comments | « chrome/browser/permissions/permission_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
72 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER;
73 case content::PermissionType::FLASH:
74 return PermissionRequestType::PERMISSION_FLASH;
75 default:
76 NOTREACHED();
77 return PermissionRequestType::UNKNOWN;
78 }
79 }
80
81 PermissionRequestGestureType PermissionUtil::GetGestureType(bool user_gesture) {
82 return user_gesture ? PermissionRequestGestureType::GESTURE
83 : PermissionRequestGestureType::NO_GESTURE;
84 }
85
57 bool PermissionUtil::GetPermissionType(ContentSettingsType type, 86 bool PermissionUtil::GetPermissionType(ContentSettingsType type,
58 PermissionType* out) { 87 PermissionType* out) {
59 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 88 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
60 *out = PermissionType::GEOLOCATION; 89 *out = PermissionType::GEOLOCATION;
61 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 90 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
62 *out = PermissionType::NOTIFICATIONS; 91 *out = PermissionType::NOTIFICATIONS;
63 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 92 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
64 *out = PermissionType::MIDI_SYSEX; 93 *out = PermissionType::MIDI_SYSEX;
65 } else if (type == CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) { 94 } else if (type == CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) {
66 *out = PermissionType::DURABLE_STORAGE; 95 *out = PermissionType::DURABLE_STORAGE;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ContentSetting final_content_setting = settings_map->GetContentSetting( 160 ContentSetting final_content_setting = settings_map->GetContentSetting(
132 primary_url_, secondary_url_, content_type_, std::string()); 161 primary_url_, secondary_url_, content_type_, std::string());
133 if (final_content_setting != CONTENT_SETTING_ALLOW) { 162 if (final_content_setting != CONTENT_SETTING_ALLOW) {
134 PermissionType permission_type; 163 PermissionType permission_type;
135 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { 164 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) {
136 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_, 165 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_,
137 primary_url_, profile_); 166 primary_url_, profile_);
138 } 167 }
139 } 168 }
140 } 169 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698