Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "chrome/browser/permissions/permission_context.h" | 8 #include "chrome/browser/permissions/permission_context.h" |
| 9 #include "chrome/browser/permissions/permission_context_base.h" | 9 #include "chrome/browser/permissions/permission_context_base.h" |
| 10 #include "chrome/browser/permissions/permission_request_id.h" | 10 #include "chrome/browser/permissions/permission_request_id.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER; | 56 return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER; |
| 57 #else | 57 #else |
| 58 NOTIMPLEMENTED(); | 58 NOTIMPLEMENTED(); |
| 59 break; | 59 break; |
| 60 #endif | 60 #endif |
| 61 case PermissionType::DURABLE_STORAGE: | 61 case PermissionType::DURABLE_STORAGE: |
| 62 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; | 62 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; |
| 63 case PermissionType::MIDI: | 63 case PermissionType::MIDI: |
| 64 // This will hit the NOTREACHED below. | 64 // This will hit the NOTREACHED below. |
| 65 break; | 65 break; |
| 66 case PermissionType::AUDIO_CAPTURE: | |
| 67 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; | |
| 68 case PermissionType::VIDEO_CAPTURE: | |
| 69 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | |
| 66 case PermissionType::NUM: | 70 case PermissionType::NUM: |
| 67 // This will hit the NOTREACHED below. | 71 // This will hit the NOTREACHED below. |
|
palmer
2015/09/01 18:31:04
Same here: just put the default case inside the sw
guoweis_left_chromium
2015/09/01 19:36:34
intentionally leave out default to have compiler c
| |
| 68 break; | 72 break; |
| 69 } | 73 } |
| 70 | 74 |
| 71 NOTREACHED() << "Unknown content setting for permission " | 75 NOTREACHED() << "Unknown content setting for permission " |
| 72 << static_cast<int>(permission); | 76 << static_cast<int>(permission); |
| 73 return CONTENT_SETTINGS_TYPE_DEFAULT; | 77 return CONTENT_SETTINGS_TYPE_DEFAULT; |
| 74 } | 78 } |
| 75 | 79 |
| 76 // Helper method that wraps a callback a void(PermissionStatus) | 80 // Helper method that wraps a callback a void(PermissionStatus) |
| 77 // callback into a void(ContentSetting) callback. | 81 // callback into a void(ContentSetting) callback. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 PermissionType permission, | 204 PermissionType permission, |
| 201 const GURL& requesting_origin, | 205 const GURL& requesting_origin, |
| 202 const GURL& embedding_origin) { | 206 const GURL& embedding_origin) { |
| 203 if (IsConstantPermission(permission)) | 207 if (IsConstantPermission(permission)) |
| 204 return GetPermissionStatusForConstantPermission(permission); | 208 return GetPermissionStatusForConstantPermission(permission); |
| 205 | 209 |
| 206 PermissionContextBase* context = PermissionContext::Get(profile_, permission); | 210 PermissionContextBase* context = PermissionContext::Get(profile_, permission); |
| 207 if (!context) | 211 if (!context) |
| 208 return content::PERMISSION_STATUS_DENIED; | 212 return content::PERMISSION_STATUS_DENIED; |
| 209 | 213 |
| 210 return ContentSettingToPermissionStatus( | 214 return ContentSettingToPermissionStatus(context->GetPermissionStatus( |
| 211 context->GetPermissionStatus(requesting_origin.GetOrigin(), | 215 requesting_origin.GetOrigin(), embedding_origin.GetOrigin())); |
|
palmer
2015/09/01 18:31:04
I'm still really anxious about this. I believe it
guoweis_left_chromium
2015/09/01 19:36:34
crbug.com/527149 filed for this.
| |
| 212 embedding_origin.GetOrigin())); | |
| 213 } | 216 } |
| 214 | 217 |
| 215 void PermissionManager::RegisterPermissionUsage(PermissionType permission, | 218 void PermissionManager::RegisterPermissionUsage(PermissionType permission, |
| 216 const GURL& requesting_origin, | 219 const GURL& requesting_origin, |
| 217 const GURL& embedding_origin) { | 220 const GURL& embedding_origin) { |
| 218 // This is required because constant permissions don't have a | 221 // This is required because constant permissions don't have a |
| 219 // ContentSettingsType. | 222 // ContentSettingsType. |
| 220 if (IsConstantPermission(permission)) | 223 if (IsConstantPermission(permission)) |
| 221 return; | 224 return; |
| 222 | 225 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 // Add the callback to |callbacks| which will be run after the loop to | 297 // Add the callback to |callbacks| which will be run after the loop to |
| 295 // prevent re-entrance issues. | 298 // prevent re-entrance issues. |
| 296 callbacks.push_back( | 299 callbacks.push_back( |
| 297 base::Bind(subscription->callback, | 300 base::Bind(subscription->callback, |
| 298 ContentSettingToPermissionStatus(new_value))); | 301 ContentSettingToPermissionStatus(new_value))); |
| 299 } | 302 } |
| 300 | 303 |
| 301 for (const auto& callback : callbacks) | 304 for (const auto& callback : callbacks) |
| 302 callback.Run(); | 305 callback.Run(); |
| 303 } | 306 } |
| OLD | NEW |