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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 = |
75 base::Callback<void(content::PermissionType, const GURL&, Profile*)>; | 75 base::Callback<void(content::PermissionType, bool, const GURL&, Profile*)>; |
raymes
2016/07/18 07:31:59
nit: bool /* user_gesture */
stefanocs
2016/07/18 07:40:25
Done.
| |
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 // TODO(stefanocs): Pass the actual |user_gesture| once this file has been |
83 // refactored into PermissionContext. | |
84 callback.Run(permission_type, false /* user_gesture */, | |
85 request.security_origin, profile); | |
83 } | 86 } |
84 } | 87 } |
85 | 88 |
86 // Calls |action_function| for each permission requested by |request|. | 89 // Calls |action_function| for each permission requested by |request|. |
87 void RecordPermissionAction(const content::MediaStreamRequest& request, | 90 void RecordPermissionAction(const content::MediaStreamRequest& request, |
88 Profile* profile, | 91 Profile* profile, |
89 PermissionActionCallback callback) { | 92 PermissionActionCallback callback) { |
90 RecordSinglePermissionAction(request, content::PermissionType::AUDIO_CAPTURE, | 93 RecordSinglePermissionAction(request, content::PermissionType::AUDIO_CAPTURE, |
91 profile, callback); | 94 profile, callback); |
92 RecordSinglePermissionAction(request, content::PermissionType::VIDEO_CAPTURE, | 95 RecordSinglePermissionAction(request, content::PermissionType::VIDEO_CAPTURE, |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 if (android_permission_blocked) | 637 if (android_permission_blocked) |
635 return false; | 638 return false; |
636 | 639 |
637 // Don't approve device requests if the tab was hidden. | 640 // Don't approve device requests if the tab was hidden. |
638 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 641 // 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? | 642 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
640 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 643 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
641 #endif | 644 #endif |
642 return true; | 645 return true; |
643 } | 646 } |
OLD | NEW |