Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media/media_stream_devices_controller.h" | 5 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 | 64 |
| 65 if (type == content::PermissionType::AUDIO_CAPTURE) | 65 if (type == content::PermissionType::AUDIO_CAPTURE) |
| 66 return request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE; | 66 return request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE; |
| 67 | 67 |
| 68 if (type == content::PermissionType::VIDEO_CAPTURE) | 68 if (type == content::PermissionType::VIDEO_CAPTURE) |
| 69 return request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE; | 69 return request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE; |
| 70 | 70 |
| 71 return false; | 71 return false; |
| 72 } | 72 } |
| 73 | 73 |
| 74 using PermissionActionCallback = | 74 using PermissionActionCallback = base::Callback< |
|
kcarattini
2016/07/06 06:54:08
Make sure you coordinate with Liu who is refactori
stefanocs
2016/07/07 01:26:03
Done. She is okay with this.
| |
| 75 base::Callback<void(content::PermissionType, const GURL&, Profile*)>; | 75 void(content::PermissionType, const GURL&, SourceUI, Profile*)>; |
| 76 | 76 |
| 77 void RecordSinglePermissionAction(const content::MediaStreamRequest& request, | 77 void RecordSinglePermissionAction(const content::MediaStreamRequest& request, |
| 78 content::PermissionType permission_type, | 78 content::PermissionType permission_type, |
| 79 Profile* profile, | 79 Profile* profile, |
| 80 PermissionActionCallback callback) { | 80 PermissionActionCallback callback) { |
| 81 if (ContentTypeIsRequested(permission_type, request)) { | 81 if (ContentTypeIsRequested(permission_type, request)) { |
| 82 callback.Run(permission_type, request.security_origin, profile); | 82 callback.Run(permission_type, request.security_origin, PROMPT, profile); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Calls |action_function| for each permission requested by |request|. | 86 // Calls |action_function| for each permission requested by |request|. |
| 87 void RecordPermissionAction(const content::MediaStreamRequest& request, | 87 void RecordPermissionAction(const content::MediaStreamRequest& request, |
| 88 Profile* profile, | 88 Profile* profile, |
| 89 PermissionActionCallback callback) { | 89 PermissionActionCallback callback) { |
| 90 RecordSinglePermissionAction(request, content::PermissionType::AUDIO_CAPTURE, | 90 RecordSinglePermissionAction(request, content::PermissionType::AUDIO_CAPTURE, |
| 91 profile, callback); | 91 profile, callback); |
| 92 RecordSinglePermissionAction(request, content::PermissionType::VIDEO_CAPTURE, | 92 RecordSinglePermissionAction(request, content::PermissionType::VIDEO_CAPTURE, |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 if (android_permission_blocked) | 634 if (android_permission_blocked) |
| 635 return false; | 635 return false; |
| 636 | 636 |
| 637 // Don't approve device requests if the tab was hidden. | 637 // Don't approve device requests if the tab was hidden. |
| 638 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 638 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 639 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 639 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 640 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 640 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 641 #endif | 641 #endif |
| 642 return true; | 642 return true; |
| 643 } | 643 } |
| OLD | NEW |