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/ui/extensions/shell_window.h" | 5 #include "chrome/browser/ui/extensions/shell_window.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" | 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "content/public/browser/notification_details.h" | 32 #include "content/public/browser/notification_details.h" |
33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
34 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
35 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
36 #include "content/public/browser/render_process_host.h" | 36 #include "content/public/browser/render_process_host.h" |
37 #include "content/public/browser/render_view_host.h" | 37 #include "content/public/browser/render_view_host.h" |
38 #include "content/public/browser/resource_dispatcher_host.h" | 38 #include "content/public/browser/resource_dispatcher_host.h" |
39 #include "content/public/browser/site_instance.h" | 39 #include "content/public/browser/site_instance.h" |
40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
41 #include "content/public/browser/web_intents_dispatcher.h" | 41 #include "content/public/browser/web_intents_dispatcher.h" |
| 42 #include "content/public/common/media_stream_request.h" |
42 #include "content/public/common/renderer_preferences.h" | 43 #include "content/public/common/renderer_preferences.h" |
43 | 44 |
44 using content::BrowserThread; | 45 using content::BrowserThread; |
45 using content::ConsoleMessageLevel; | 46 using content::ConsoleMessageLevel; |
46 using content::RenderViewHost; | 47 using content::RenderViewHost; |
47 using content::ResourceDispatcherHost; | 48 using content::ResourceDispatcherHost; |
48 using content::SiteInstance; | 49 using content::SiteInstance; |
49 using content::WebContents; | 50 using content::WebContents; |
50 using extensions::APIPermission; | 51 using extensions::APIPermission; |
51 | 52 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // Remove shutdown prevention. | 184 // Remove shutdown prevention. |
184 browser::EndKeepAlive(); | 185 browser::EndKeepAlive(); |
185 } | 186 } |
186 | 187 |
187 void ShellWindow::RequestMediaAccessPermission( | 188 void ShellWindow::RequestMediaAccessPermission( |
188 content::WebContents* web_contents, | 189 content::WebContents* web_contents, |
189 const content::MediaStreamRequest* request, | 190 const content::MediaStreamRequest* request, |
190 const content::MediaResponseCallback& callback) { | 191 const content::MediaResponseCallback& callback) { |
191 content::MediaStreamDevices devices; | 192 content::MediaStreamDevices devices; |
192 | 193 |
193 content::MediaStreamDeviceMap::const_iterator iter = | 194 // Auto-accept the first audio device and the first video device from the |
194 request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE); | 195 // request when the appropriate API permissions exist. |
195 if (iter != request->devices.end() && | 196 bool accepted_an_audio_device = false; |
196 extension()->HasAPIPermission(APIPermission::kAudioCapture) && | 197 bool accepted_a_video_device = false; |
197 !iter->second.empty()) { | 198 for (content::MediaStreamDeviceMap::const_iterator it = |
198 devices.push_back(iter->second[0]); | 199 request->devices.begin(); |
199 } | 200 it != request->devices.end(); ++it) { |
200 | 201 if (!accepted_an_audio_device && |
201 iter = request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); | 202 content::IsAudioMediaType(it->first) && |
202 if (iter != request->devices.end() && | 203 extension()->HasAPIPermission(APIPermission::kAudioCapture) && |
203 extension()->HasAPIPermission(APIPermission::kVideoCapture) && | 204 !it->second.empty()) { |
204 !iter->second.empty()) { | 205 devices.push_back(it->second.front()); |
205 devices.push_back(iter->second[0]); | 206 accepted_an_audio_device = true; |
| 207 } else if (!accepted_a_video_device && |
| 208 content::IsVideoMediaType(it->first) && |
| 209 extension()->HasAPIPermission(APIPermission::kVideoCapture) && |
| 210 !it->second.empty()) { |
| 211 devices.push_back(it->second.front()); |
| 212 accepted_a_video_device = true; |
| 213 } |
206 } | 214 } |
207 | 215 |
208 callback.Run(devices); | 216 callback.Run(devices); |
209 } | 217 } |
210 | 218 |
211 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, | 219 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, |
212 const content::OpenURLParams& params) { | 220 const content::OpenURLParams& params) { |
213 DCHECK(source == web_contents_); | 221 DCHECK(source == web_contents_); |
214 | 222 |
215 if (params.url.host() == extension_->id()) { | 223 if (params.url.host() == extension_->id()) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 if (window_key_.empty()) | 454 if (window_key_.empty()) |
447 return; | 455 return; |
448 | 456 |
449 extensions::ShellWindowGeometryCache* cache = | 457 extensions::ShellWindowGeometryCache* cache = |
450 extensions::ExtensionSystem::Get(profile())-> | 458 extensions::ExtensionSystem::Get(profile())-> |
451 shell_window_geometry_cache(); | 459 shell_window_geometry_cache(); |
452 | 460 |
453 gfx::Rect bounds = native_window_->GetBounds(); | 461 gfx::Rect bounds = native_window_->GetBounds(); |
454 cache->SaveGeometry(extension()->id(), window_key_, bounds); | 462 cache->SaveGeometry(extension()->id(), window_key_, bounds); |
455 } | 463 } |
456 | |
OLD | NEW |