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

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 10912004: Begin adding support for tab mirroring via the MediaStream audio/video capturing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify: Use only one AudioInputDeviceManager and VideoCaptureManager, like before. Created 8 years, 3 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/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
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // Remove shutdown prevention. 182 // Remove shutdown prevention.
182 browser::EndKeepAlive(); 183 browser::EndKeepAlive();
183 } 184 }
184 185
185 void ShellWindow::RequestMediaAccessPermission( 186 void ShellWindow::RequestMediaAccessPermission(
186 content::WebContents* web_contents, 187 content::WebContents* web_contents,
187 const content::MediaStreamRequest* request, 188 const content::MediaStreamRequest* request,
188 const content::MediaResponseCallback& callback) { 189 const content::MediaResponseCallback& callback) {
189 content::MediaStreamDevices devices; 190 content::MediaStreamDevices devices;
190 191
191 content::MediaStreamDeviceMap::const_iterator iter = 192 // Auto-accept the first audio device and the first video device from the
192 request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE); 193 // request when the appropriate API permissions exist.
193 if (iter != request->devices.end() && 194 bool accepted_an_audio_device = false;
194 extension()->HasAPIPermission(APIPermission::kAudioCapture) && 195 bool accepted_a_video_device = false;
195 !iter->second.empty()) { 196 for (content::MediaStreamDeviceMap::const_iterator it =
196 devices.push_back(iter->second[0]); 197 request->devices.begin();
197 } 198 it != request->devices.end(); ++it) {
198 199 if (!accepted_an_audio_device &&
199 iter = request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); 200 content::IsAudioMediaType(it->first) &&
200 if (iter != request->devices.end() && 201 extension()->HasAPIPermission(APIPermission::kAudioCapture) &&
201 extension()->HasAPIPermission(APIPermission::kVideoCapture) && 202 !it->second.empty()) {
202 !iter->second.empty()) { 203 devices.push_back(it->second.front());
203 devices.push_back(iter->second[0]); 204 accepted_an_audio_device = true;
205 } else if (!accepted_a_video_device &&
206 content::IsVideoMediaType(it->first) &&
207 extension()->HasAPIPermission(APIPermission::kVideoCapture) &&
208 !it->second.empty()) {
209 devices.push_back(it->second.front());
210 accepted_a_video_device = true;
211 }
204 } 212 }
205 213
206 callback.Run(devices); 214 callback.Run(devices);
207 } 215 }
208 216
209 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, 217 WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
210 const content::OpenURLParams& params) { 218 const content::OpenURLParams& params) {
211 DCHECK(source == web_contents_); 219 DCHECK(source == web_contents_);
212 220
213 if (params.url.host() == extension_->id()) { 221 if (params.url.host() == extension_->id()) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 if (window_key_.empty()) 428 if (window_key_.empty())
421 return; 429 return;
422 430
423 extensions::ShellWindowGeometryCache* cache = 431 extensions::ShellWindowGeometryCache* cache =
424 extensions::ExtensionSystem::Get(profile())-> 432 extensions::ExtensionSystem::Get(profile())->
425 shell_window_geometry_cache(); 433 shell_window_geometry_cache();
426 434
427 gfx::Rect bounds = native_window_->GetBounds(); 435 gfx::Rect bounds = native_window_->GetBounds();
428 cache->SaveGeometry(extension()->id(), window_key_, bounds); 436 cache->SaveGeometry(extension()->id(), window_key_, bounds);
429 } 437 }
430
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698