| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Remove shutdown prevention. | 175 // Remove shutdown prevention. |
| 175 browser::EndKeepAlive(); | 176 browser::EndKeepAlive(); |
| 176 } | 177 } |
| 177 | 178 |
| 178 void ShellWindow::RequestMediaAccessPermission( | 179 void ShellWindow::RequestMediaAccessPermission( |
| 179 content::WebContents* web_contents, | 180 content::WebContents* web_contents, |
| 180 const content::MediaStreamRequest* request, | 181 const content::MediaStreamRequest* request, |
| 181 const content::MediaResponseCallback& callback) { | 182 const content::MediaResponseCallback& callback) { |
| 182 content::MediaStreamDevices devices; | 183 content::MediaStreamDevices devices; |
| 183 | 184 |
| 184 content::MediaStreamDeviceMap::const_iterator iter = | 185 // Auto-accept the first audio device and the first video device from the |
| 185 request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE); | 186 // request when the appropriate API permissions exist. |
| 186 if (iter != request->devices.end() && | 187 bool accepted_an_audio_device = false; |
| 187 extension()->HasAPIPermission(APIPermission::kAudioCapture) && | 188 bool accepted_a_video_device = false; |
| 188 !iter->second.empty()) { | 189 for (content::MediaStreamDeviceMap::const_iterator it = |
| 189 devices.push_back(iter->second[0]); | 190 request->devices.begin(); |
| 190 } | 191 it != request->devices.end(); ++it) { |
| 191 | 192 if (!accepted_an_audio_device && |
| 192 iter = request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); | 193 content::IsAudioMediaType(it->first) && |
| 193 if (iter != request->devices.end() && | 194 extension()->HasAPIPermission(APIPermission::kAudioCapture) && |
| 194 extension()->HasAPIPermission(APIPermission::kVideoCapture) && | 195 !it->second.empty()) { |
| 195 !iter->second.empty()) { | 196 devices.push_back(it->second.front()); |
| 196 devices.push_back(iter->second[0]); | 197 accepted_an_audio_device = true; |
| 198 } else if (!accepted_a_video_device && |
| 199 content::IsVideoMediaType(it->first) && |
| 200 extension()->HasAPIPermission(APIPermission::kVideoCapture) && |
| 201 !it->second.empty()) { |
| 202 devices.push_back(it->second.front()); |
| 203 accepted_a_video_device = true; |
| 204 } |
| 197 } | 205 } |
| 198 | 206 |
| 199 callback.Run(devices); | 207 callback.Run(devices); |
| 200 } | 208 } |
| 201 | 209 |
| 202 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, | 210 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, |
| 203 const content::OpenURLParams& params) { | 211 const content::OpenURLParams& params) { |
| 204 DCHECK(source == web_contents_); | 212 DCHECK(source == web_contents_); |
| 205 | 213 |
| 206 if (params.url.host() == extension_->id()) { | 214 if (params.url.host() == extension_->id()) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if (window_key_.empty()) | 421 if (window_key_.empty()) |
| 414 return; | 422 return; |
| 415 | 423 |
| 416 extensions::ShellWindowGeometryCache* cache = | 424 extensions::ShellWindowGeometryCache* cache = |
| 417 extensions::ExtensionSystem::Get(profile())-> | 425 extensions::ExtensionSystem::Get(profile())-> |
| 418 shell_window_geometry_cache(); | 426 shell_window_geometry_cache(); |
| 419 | 427 |
| 420 gfx::Rect bounds = native_window_->GetBounds(); | 428 gfx::Rect bounds = native_window_->GetBounds(); |
| 421 cache->SaveGeometry(extension()->id(), window_key_, bounds); | 429 cache->SaveGeometry(extension()->id(), window_key_, bounds); |
| 422 } | 430 } |
| 423 | |
| OLD | NEW |