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_capture_devices_dispatcher.h" | 5 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
6 | 6 |
7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/field_trial.h" | |
11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
12 #include "base/prefs/scoped_user_pref_update.h" | 13 #include "base/prefs/scoped_user_pref_update.h" |
13 #include "base/sha1.h" | 14 #include "base/sha1.h" |
14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 18 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
18 #include "chrome/browser/media/desktop_streams_registry.h" | 19 #include "chrome/browser/media/desktop_streams_registry.h" |
19 #include "chrome/browser/media/media_stream_capture_indicator.h" | 20 #include "chrome/browser/media/media_stream_capture_indicator.h" |
20 #include "chrome/browser/media/media_stream_infobar_delegate.h" | 21 #include "chrome/browser/media/media_stream_infobar_delegate.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 #define AUDIO_STREAM_MONITORING | 58 #define AUDIO_STREAM_MONITORING |
58 #include "chrome/browser/media/audio_stream_monitor.h" | 59 #include "chrome/browser/media/audio_stream_monitor.h" |
59 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 60 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
60 | 61 |
61 using content::BrowserThread; | 62 using content::BrowserThread; |
62 using content::MediaCaptureDevices; | 63 using content::MediaCaptureDevices; |
63 using content::MediaStreamDevices; | 64 using content::MediaStreamDevices; |
64 | 65 |
65 namespace { | 66 namespace { |
66 | 67 |
68 // A finch experiment to enable the permission bubble for media requests only. | |
69 bool WebRTCPermissionBubbleExperimentEnabled() { | |
Sergey Ulanov
2014/05/19 18:39:17
s/WebRTC/MediaSstream/. WebRTC is too generic in t
Greg Billock
2014/05/27 18:08:40
Done.
| |
70 const std::string group = | |
71 base::FieldTrialList::FindFullName("WebRTCPermissionBubble"); | |
72 if (group == "enabled") | |
73 return true; | |
74 | |
75 return false; | |
76 } | |
77 | |
67 // Finds a device in |devices| that has |device_id|, or NULL if not found. | 78 // Finds a device in |devices| that has |device_id|, or NULL if not found. |
68 const content::MediaStreamDevice* FindDeviceWithId( | 79 const content::MediaStreamDevice* FindDeviceWithId( |
69 const content::MediaStreamDevices& devices, | 80 const content::MediaStreamDevices& devices, |
70 const std::string& device_id) { | 81 const std::string& device_id) { |
71 content::MediaStreamDevices::const_iterator iter = devices.begin(); | 82 content::MediaStreamDevices::const_iterator iter = devices.begin(); |
72 for (; iter != devices.end(); ++iter) { | 83 for (; iter != devices.end(); ++iter) { |
73 if (iter->id == device_id) { | 84 if (iter->id == device_id) { |
74 return &(*iter); | 85 return &(*iter); |
75 } | 86 } |
76 } | 87 } |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 std::map<content::WebContents*, RequestsQueue>::iterator it = | 627 std::map<content::WebContents*, RequestsQueue>::iterator it = |
617 pending_requests_.find(web_contents); | 628 pending_requests_.find(web_contents); |
618 | 629 |
619 if (it == pending_requests_.end() || it->second.empty()) { | 630 if (it == pending_requests_.end() || it->second.empty()) { |
620 // Don't do anything if the tab was closed. | 631 // Don't do anything if the tab was closed. |
621 return; | 632 return; |
622 } | 633 } |
623 | 634 |
624 DCHECK(!it->second.empty()); | 635 DCHECK(!it->second.empty()); |
625 | 636 |
626 if (PermissionBubbleManager::Enabled()) { | 637 if (PermissionBubbleManager::Enabled() || |
638 WebRTCPermissionBubbleExperimentEnabled()) { | |
627 scoped_ptr<MediaStreamDevicesController> controller( | 639 scoped_ptr<MediaStreamDevicesController> controller( |
628 new MediaStreamDevicesController(web_contents, | 640 new MediaStreamDevicesController(web_contents, |
629 it->second.front().request, | 641 it->second.front().request, |
630 base::Bind(&MediaCaptureDevicesDispatcher::OnAccessRequestResponse, | 642 base::Bind(&MediaCaptureDevicesDispatcher::OnAccessRequestResponse, |
631 base::Unretained(this), web_contents))); | 643 base::Unretained(this), web_contents))); |
632 if (controller->DismissInfoBarAndTakeActionOnSettings()) | 644 if (controller->DismissInfoBarAndTakeActionOnSettings()) |
633 return; | 645 return; |
634 PermissionBubbleManager* bubble_manager = | 646 PermissionBubbleManager* bubble_manager = |
635 PermissionBubbleManager::FromWebContents(web_contents); | 647 PermissionBubbleManager::FromWebContents(web_contents); |
636 if (bubble_manager) | 648 if (bubble_manager) |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 | 963 |
952 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 964 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
953 const MediaStreamDevices& devices) { | 965 const MediaStreamDevices& devices) { |
954 test_audio_devices_ = devices; | 966 test_audio_devices_ = devices; |
955 } | 967 } |
956 | 968 |
957 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 969 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
958 const MediaStreamDevices& devices) { | 970 const MediaStreamDevices& devices) { |
959 test_video_devices_ = devices; | 971 test_video_devices_ = devices; |
960 } | 972 } |
OLD | NEW |