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

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

Issue 2788483006: [sensors][permission] Constant permission for Acceleromter and Gyroscope.
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | 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_manager.h" 5 #include "chrome/browser/permissions/permission_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 NOTREACHED() << "Unknown content setting for permission " 119 NOTREACHED() << "Unknown content setting for permission "
120 << static_cast<int>(permission); 120 << static_cast<int>(permission);
121 return CONTENT_SETTINGS_TYPE_DEFAULT; 121 return CONTENT_SETTINGS_TYPE_DEFAULT;
122 } 122 }
123 123
124 // Returns whether the permission has a constant ContentSetting value (i.e. 124 // Returns whether the permission has a constant ContentSetting value (i.e.
125 // always approved or always denied) 125 // always approved or always denied)
126 // The ContentSettingsTypes for which true is returned will also return nullptr 126 // The ContentSettingsTypes for which true is returned will also return nullptr
127 // in PermissionManager::GetPermissionContext since they don't have a context. 127 // in PermissionManager::GetPermissionContext since they don't have a context.
128 bool IsConstantPermission(ContentSettingsType type) { 128 bool IsConstantPermission(ContentSettingsType type) {
129 return type == CONTENT_SETTINGS_TYPE_MIDI; 129 return (type == CONTENT_SETTINGS_TYPE_MIDI ||
130 CONTENT_SETTINGS_TYPE_ACCELEROMETER ||
131 CONTENT_SETTINGS_TYPE_GYROSCOPE);
130 } 132 }
131 133
132 void SubscriptionCallbackWrapper( 134 void SubscriptionCallbackWrapper(
133 const base::Callback<void(PermissionStatus)>& callback, 135 const base::Callback<void(PermissionStatus)>& callback,
134 ContentSetting content_setting) { 136 ContentSetting content_setting) {
135 callback.Run(ContentSettingToPermissionStatus(content_setting)); 137 callback.Run(ContentSettingToPermissionStatus(content_setting));
136 } 138 }
137 139
138 void PermissionStatusCallbackWrapper( 140 void PermissionStatusCallbackWrapper(
139 const base::Callback<void(PermissionStatus)>& callback, 141 const base::Callback<void(PermissionStatus)>& callback,
(...skipping 23 matching lines...) Expand all
163 // value i.e. they are always approved or always denied etc. 165 // value i.e. they are always approved or always denied etc.
164 // CONTENT_SETTING_DEFAULT is returned if the permission needs further handling. 166 // CONTENT_SETTING_DEFAULT is returned if the permission needs further handling.
165 // This function should only be called when IsConstantPermission has returned 167 // This function should only be called when IsConstantPermission has returned
166 // true for the PermissionType. 168 // true for the PermissionType.
167 ContentSetting GetContentSettingForConstantPermission( 169 ContentSetting GetContentSettingForConstantPermission(
168 ContentSettingsType type) { 170 ContentSettingsType type) {
169 DCHECK(IsConstantPermission(type)); 171 DCHECK(IsConstantPermission(type));
170 switch (type) { 172 switch (type) {
171 case CONTENT_SETTINGS_TYPE_MIDI: 173 case CONTENT_SETTINGS_TYPE_MIDI:
172 return CONTENT_SETTING_ALLOW; 174 return CONTENT_SETTING_ALLOW;
175 case CONTENT_SETTINGS_TYPE_ACCELEROMETER:
176 return CONTENT_SETTING_ALLOW;
177 case CONTENT_SETTINGS_TYPE_GYROSCOPE:
178 return CONTENT_SETTING_ALLOW;
173 default: 179 default:
174 return CONTENT_SETTING_BLOCK; 180 return CONTENT_SETTING_BLOCK;
175 } 181 }
176 } 182 }
177 183
178 } // anonymous namespace 184 } // anonymous namespace
179 185
180 class PermissionManager::PendingRequest { 186 class PermissionManager::PendingRequest {
181 public: 187 public:
182 PendingRequest( 188 PendingRequest(
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 564 }
559 PermissionContextBase* context = GetPermissionContext(permission); 565 PermissionContextBase* context = GetPermissionContext(permission);
560 PermissionResult result = context->GetPermissionStatus( 566 PermissionResult result = context->GetPermissionStatus(
561 nullptr /* render_frame_host */, requesting_origin.GetOrigin(), 567 nullptr /* render_frame_host */, requesting_origin.GetOrigin(),
562 embedding_origin.GetOrigin()); 568 embedding_origin.GetOrigin());
563 DCHECK(result.content_setting == CONTENT_SETTING_ALLOW || 569 DCHECK(result.content_setting == CONTENT_SETTING_ALLOW ||
564 result.content_setting == CONTENT_SETTING_ASK || 570 result.content_setting == CONTENT_SETTING_ASK ||
565 result.content_setting == CONTENT_SETTING_BLOCK); 571 result.content_setting == CONTENT_SETTING_BLOCK);
566 return result; 572 return result;
567 } 573 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698