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<void(content::PermissionType, |
75 base::Callback<void(content::PermissionType, const GURL&, Profile*)>; | 75 bool /* user_gesture */, |
Sergey Ulanov
2016/07/21 19:32:47
nit: don't need to have the name commented (and ca
stefanocs
2016/07/22 00:56:11
Done.
| |
76 const GURL&, | |
77 Profile*)>; | |
76 | 78 |
77 void RecordSinglePermissionAction(const content::MediaStreamRequest& request, | 79 void RecordSinglePermissionAction(const content::MediaStreamRequest& request, |
78 content::PermissionType permission_type, | 80 content::PermissionType permission_type, |
79 Profile* profile, | 81 Profile* profile, |
80 PermissionActionCallback callback) { | 82 PermissionActionCallback callback) { |
81 if (ContentTypeIsRequested(permission_type, request)) { | 83 if (ContentTypeIsRequested(permission_type, request)) { |
82 callback.Run(permission_type, request.security_origin, profile); | 84 // TODO(stefanocs): Pass the actual |user_gesture| once this file has been |
85 // refactored into PermissionContext. | |
86 callback.Run(permission_type, false /* user_gesture */, | |
87 request.security_origin, profile); | |
83 } | 88 } |
84 } | 89 } |
85 | 90 |
86 // Calls |action_function| for each permission requested by |request|. | 91 // Calls |action_function| for each permission requested by |request|. |
87 void RecordPermissionAction(const content::MediaStreamRequest& request, | 92 void RecordPermissionAction(const content::MediaStreamRequest& request, |
88 Profile* profile, | 93 Profile* profile, |
89 PermissionActionCallback callback) { | 94 PermissionActionCallback callback) { |
90 RecordSinglePermissionAction(request, content::PermissionType::AUDIO_CAPTURE, | 95 RecordSinglePermissionAction(request, content::PermissionType::AUDIO_CAPTURE, |
91 profile, callback); | 96 profile, callback); |
92 RecordSinglePermissionAction(request, content::PermissionType::VIDEO_CAPTURE, | 97 RecordSinglePermissionAction(request, content::PermissionType::VIDEO_CAPTURE, |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 if (android_permission_blocked) | 639 if (android_permission_blocked) |
635 return false; | 640 return false; |
636 | 641 |
637 // Don't approve device requests if the tab was hidden. | 642 // Don't approve device requests if the tab was hidden. |
638 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 643 // 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? | 644 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
640 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 645 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
641 #endif | 646 #endif |
642 return true; | 647 return true; |
643 } | 648 } |
OLD | NEW |