Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Side by Side Diff: chrome/browser/media/media_stream_devices_controller.cc

Issue 12153002: Move chrome://media-internals to content. This allows us to hide implementation details from the pu… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/content_settings/content_settings_provider.h" 8 #include "chrome/browser/content_settings/content_settings_provider.h"
9 #include "chrome/browser/content_settings/host_content_settings_map.h" 9 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
11 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" 11 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h"
12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory .h" 12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory .h"
13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 13 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
14 #include "chrome/browser/media/media_internals.h"
15 #include "chrome/browser/prefs/scoped_user_pref_update.h" 14 #include "chrome/browser/prefs/scoped_user_pref_update.h"
16 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
18 #include "chrome/common/content_settings.h" 17 #include "chrome/common/content_settings.h"
19 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 #include "content/public/common/media_stream_request.h" 20 #include "content/public/common/media_stream_request.h"
22 21
23 using content::BrowserThread; 22 using content::BrowserThread;
24 23
25 namespace { 24 namespace {
26 25
27 bool HasAnyAvailableDevice() { 26 bool HasAnyAvailableDevice() {
28 MediaCaptureDevicesDispatcher* dispatcher =
29 MediaInternals::GetInstance()->GetMediaCaptureDevicesDispatcher();
30 const content::MediaStreamDevices& audio_devices = 27 const content::MediaStreamDevices& audio_devices =
31 dispatcher->GetAudioCaptureDevices(); 28 MediaCaptureDevicesDispatcher::GetInstance()->GetAudioCaptureDevices();
32 const content::MediaStreamDevices& video_devices = 29 const content::MediaStreamDevices& video_devices =
33 dispatcher->GetVideoCaptureDevices(); 30 MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices();
34 31
35 return !audio_devices.empty() || !video_devices.empty(); 32 return !audio_devices.empty() || !video_devices.empty();
36 }; 33 };
37 34
38 } // namespace 35 } // namespace
39 36
40 MediaStreamDevicesController::MediaStreamDevicesController( 37 MediaStreamDevicesController::MediaStreamDevicesController(
41 Profile* profile, 38 Profile* profile,
42 TabSpecificContentSettings* content_settings, 39 TabSpecificContentSettings* content_settings,
43 const content::MediaStreamRequest& request, 40 const content::MediaStreamRequest& request,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void MediaStreamDevicesController::Accept(bool update_content_setting) { 119 void MediaStreamDevicesController::Accept(bool update_content_setting) {
123 content_settings_->OnMediaStreamAccessed(); 120 content_settings_->OnMediaStreamAccessed();
124 121
125 // Get the default devices for the request. 122 // Get the default devices for the request.
126 content::MediaStreamDevices devices; 123 content::MediaStreamDevices devices;
127 if (has_audio_ || has_video_) { 124 if (has_audio_ || has_video_) {
128 switch (request_.request_type) { 125 switch (request_.request_type) {
129 case content::MEDIA_OPEN_DEVICE: 126 case content::MEDIA_OPEN_DEVICE:
130 // For open device request pick the desired device or fall back to the 127 // For open device request pick the desired device or fall back to the
131 // first available of the given type. 128 // first available of the given type.
132 media::GetRequestedDevice(request_.requested_device_id, 129 MediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
133 has_audio_, 130 request_.requested_device_id,
134 has_video_, 131 has_audio_,
135 &devices); 132 has_video_,
133 &devices);
136 break; 134 break;
137 case content::MEDIA_DEVICE_ACCESS: 135 case content::MEDIA_DEVICE_ACCESS:
138 case content::MEDIA_GENERATE_STREAM: 136 case content::MEDIA_GENERATE_STREAM:
139 case content::MEDIA_ENUMERATE_DEVICES: 137 case content::MEDIA_ENUMERATE_DEVICES:
140 // Get the default devices for the request. 138 // Get the default devices for the request.
141 media::GetDefaultDevicesForProfile(profile_, 139 MediaCaptureDevicesDispatcher::GetInstance()->
142 has_audio_, 140 GetDefaultDevicesForProfile(profile_,
143 has_video_, 141 has_audio_,
144 &devices); 142 has_video_,
143 &devices);
145 break; 144 break;
146 } 145 }
147 146
148 if (update_content_setting && IsSchemeSecure() && !devices.empty()) 147 if (update_content_setting && IsSchemeSecure() && !devices.empty())
149 SetPermission(true); 148 SetPermission(true);
150 } 149 }
151 150
152 callback_.Run(devices); 151 callback_.Run(devices);
153 } 152 }
154 153
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 299 }
301 if (has_video_) { 300 if (has_video_) {
302 profile_->GetHostContentSettingsMap()->SetContentSetting( 301 profile_->GetHostContentSettingsMap()->SetContentSetting(
303 primary_pattern, 302 primary_pattern,
304 ContentSettingsPattern::Wildcard(), 303 ContentSettingsPattern::Wildcard(),
305 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 304 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
306 std::string(), 305 std::string(),
307 content_setting); 306 content_setting);
308 } 307 }
309 } 308 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698