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

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

Issue 2458453002: [sensors] Add Permission guard to the generic sensor apis.
Patch Set: Remove resetPermission + Rebase Created 4 years 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 "build/build_config.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 30 matching lines...) Expand all
41 case content::PermissionType::AUDIO_CAPTURE: 41 case content::PermissionType::AUDIO_CAPTURE:
42 return "AudioCapture"; 42 return "AudioCapture";
43 case content::PermissionType::VIDEO_CAPTURE: 43 case content::PermissionType::VIDEO_CAPTURE:
44 return "VideoCapture"; 44 return "VideoCapture";
45 case content::PermissionType::MIDI: 45 case content::PermissionType::MIDI:
46 return "Midi"; 46 return "Midi";
47 case content::PermissionType::BACKGROUND_SYNC: 47 case content::PermissionType::BACKGROUND_SYNC:
48 return "BackgroundSync"; 48 return "BackgroundSync";
49 case content::PermissionType::FLASH: 49 case content::PermissionType::FLASH:
50 return "Flash"; 50 return "Flash";
51 case content::PermissionType::SENSORS:
52 return "Sensors";
51 case content::PermissionType::NUM: 53 case content::PermissionType::NUM:
52 break; 54 break;
53 } 55 }
54 NOTREACHED(); 56 NOTREACHED();
55 return std::string(); 57 return std::string();
56 } 58 }
57 59
58 PermissionRequestType PermissionUtil::GetRequestType( 60 PermissionRequestType PermissionUtil::GetRequestType(
59 content::PermissionType type) { 61 content::PermissionType type) {
60 switch (type) { 62 switch (type) {
61 case content::PermissionType::GEOLOCATION: 63 case content::PermissionType::GEOLOCATION:
62 return PermissionRequestType::PERMISSION_GEOLOCATION; 64 return PermissionRequestType::PERMISSION_GEOLOCATION;
63 #if defined(ENABLE_NOTIFICATIONS) 65 #if defined(ENABLE_NOTIFICATIONS)
64 case content::PermissionType::NOTIFICATIONS: 66 case content::PermissionType::NOTIFICATIONS:
65 return PermissionRequestType::PERMISSION_NOTIFICATIONS; 67 return PermissionRequestType::PERMISSION_NOTIFICATIONS;
66 #endif 68 #endif
67 case content::PermissionType::MIDI_SYSEX: 69 case content::PermissionType::MIDI_SYSEX:
68 return PermissionRequestType::PERMISSION_MIDI_SYSEX; 70 return PermissionRequestType::PERMISSION_MIDI_SYSEX;
71 case content::PermissionType::SENSORS:
72 return PermissionRequestType::PERMISSION_SENSORS;
69 case content::PermissionType::PUSH_MESSAGING: 73 case content::PermissionType::PUSH_MESSAGING:
70 return PermissionRequestType::PERMISSION_PUSH_MESSAGING; 74 return PermissionRequestType::PERMISSION_PUSH_MESSAGING;
71 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: 75 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
72 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER; 76 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER;
73 case content::PermissionType::FLASH: 77 case content::PermissionType::FLASH:
74 return PermissionRequestType::PERMISSION_FLASH; 78 return PermissionRequestType::PERMISSION_FLASH;
75 default: 79 default:
76 NOTREACHED(); 80 NOTREACHED();
77 return PermissionRequestType::UNKNOWN; 81 return PermissionRequestType::UNKNOWN;
78 } 82 }
(...skipping 11 matching lines...) Expand all
90 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 94 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
91 *out = PermissionType::NOTIFICATIONS; 95 *out = PermissionType::NOTIFICATIONS;
92 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 96 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
93 *out = PermissionType::MIDI_SYSEX; 97 *out = PermissionType::MIDI_SYSEX;
94 } else if (type == CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) { 98 } else if (type == CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) {
95 *out = PermissionType::DURABLE_STORAGE; 99 *out = PermissionType::DURABLE_STORAGE;
96 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { 100 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
97 *out = PermissionType::VIDEO_CAPTURE; 101 *out = PermissionType::VIDEO_CAPTURE;
98 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { 102 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
99 *out = PermissionType::AUDIO_CAPTURE; 103 *out = PermissionType::AUDIO_CAPTURE;
104 } else if (type == CONTENT_SETTINGS_TYPE_SENSORS) {
105 *out = PermissionType::SENSORS;
100 } else if (type == CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC) { 106 } else if (type == CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC) {
101 *out = PermissionType::BACKGROUND_SYNC; 107 *out = PermissionType::BACKGROUND_SYNC;
102 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 108 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
103 } else if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) { 109 } else if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) {
104 *out = PermissionType::PROTECTED_MEDIA_IDENTIFIER; 110 *out = PermissionType::PROTECTED_MEDIA_IDENTIFIER;
105 #endif 111 #endif
106 } else { 112 } else {
107 return false; 113 return false;
108 } 114 }
109 return true; 115 return true;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 ContentSetting final_content_setting = settings_map->GetContentSetting( 166 ContentSetting final_content_setting = settings_map->GetContentSetting(
161 primary_url_, secondary_url_, content_type_, std::string()); 167 primary_url_, secondary_url_, content_type_, std::string());
162 if (final_content_setting != CONTENT_SETTING_ALLOW) { 168 if (final_content_setting != CONTENT_SETTING_ALLOW) {
163 PermissionType permission_type; 169 PermissionType permission_type;
164 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { 170 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) {
165 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_, 171 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_,
166 primary_url_, profile_); 172 primary_url_, profile_);
167 } 173 }
168 } 174 }
169 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698