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

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: Add CONTENT_EXPORT to resolve linker issues on components builds. Also, IWYU. 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/shell_window_registry.h" 9 #include "chrome/browser/extensions/shell_window_registry.h"
10 #include "chrome/browser/file_select_helper.h" 10 #include "chrome/browser/file_select_helper.h"
(...skipping 19 matching lines...) Expand all
30 #include "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
31 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
32 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
33 #include "content/public/browser/notification_types.h" 33 #include "content/public/browser/notification_types.h"
34 #include "content/public/browser/render_process_host.h" 34 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/render_view_host.h" 35 #include "content/public/browser/render_view_host.h"
36 #include "content/public/browser/resource_dispatcher_host.h" 36 #include "content/public/browser/resource_dispatcher_host.h"
37 #include "content/public/browser/site_instance.h" 37 #include "content/public/browser/site_instance.h"
38 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
39 #include "content/public/browser/web_intents_dispatcher.h" 39 #include "content/public/browser/web_intents_dispatcher.h"
40 #include "content/public/common/media_stream_request.h"
40 #include "content/public/common/renderer_preferences.h" 41 #include "content/public/common/renderer_preferences.h"
41 42
42 using content::BrowserThread; 43 using content::BrowserThread;
43 using content::ConsoleMessageLevel; 44 using content::ConsoleMessageLevel;
44 using content::RenderViewHost; 45 using content::RenderViewHost;
45 using content::ResourceDispatcherHost; 46 using content::ResourceDispatcherHost;
46 using content::SiteInstance; 47 using content::SiteInstance;
47 using content::WebContents; 48 using content::WebContents;
48 using extensions::APIPermission; 49 using extensions::APIPermission;
49 50
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Remove shutdown prevention. 146 // Remove shutdown prevention.
146 browser::EndKeepAlive(); 147 browser::EndKeepAlive();
147 } 148 }
148 149
149 void ShellWindow::RequestMediaAccessPermission( 150 void ShellWindow::RequestMediaAccessPermission(
150 content::WebContents* web_contents, 151 content::WebContents* web_contents,
151 const content::MediaStreamRequest* request, 152 const content::MediaStreamRequest* request,
152 const content::MediaResponseCallback& callback) { 153 const content::MediaResponseCallback& callback) {
153 content::MediaStreamDevices devices; 154 content::MediaStreamDevices devices;
154 155
155 content::MediaStreamDeviceMap::const_iterator iter = 156 // Auto-accept the first audio device and the first video device from the
156 request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE); 157 // request when the appropriate API permissions exist.
157 if (iter != request->devices.end() && 158 bool accepted_an_audio_device = false;
158 extension()->HasAPIPermission(APIPermission::kAudioCapture) && 159 bool accepted_a_video_device = false;
159 !iter->second.empty()) { 160 for (content::MediaStreamDeviceMap::const_iterator it =
160 devices.push_back(iter->second[0]); 161 request->devices.begin();
161 } 162 it != request->devices.end(); ++it) {
162 163 if (!accepted_an_audio_device &&
163 iter = request->devices.find(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE); 164 content::IsAudioMediaStreamDeviceType(it->first) &&
164 if (iter != request->devices.end() && 165 extension()->HasAPIPermission(APIPermission::kAudioCapture) &&
165 extension()->HasAPIPermission(APIPermission::kVideoCapture) && 166 !it->second.empty()) {
166 !iter->second.empty()) { 167 devices.push_back(it->second.front());
167 devices.push_back(iter->second[0]); 168 accepted_an_audio_device = true;
169 } else if (!accepted_a_video_device &&
170 content::IsVideoMediaStreamDeviceType(it->first) &&
171 extension()->HasAPIPermission(APIPermission::kVideoCapture) &&
172 !it->second.empty()) {
173 devices.push_back(it->second.front());
174 accepted_a_video_device = true;
175 }
168 } 176 }
169 177
170 callback.Run(devices); 178 callback.Run(devices);
171 } 179 }
172 180
173 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, 181 WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
174 const content::OpenURLParams& params) { 182 const content::OpenURLParams& params) {
175 DCHECK(source == web_contents_); 183 DCHECK(source == web_contents_);
176 184
177 if (params.url.host() == extension_->id()) { 185 if (params.url.host() == extension_->id()) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 extension_function_dispatcher_.Dispatch(params, 377 extension_function_dispatcher_.Dispatch(params,
370 web_contents_->GetRenderViewHost()); 378 web_contents_->GetRenderViewHost());
371 } 379 }
372 380
373 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, 381 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level,
374 const std::string& message) { 382 const std::string& message) {
375 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); 383 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
376 rvh->Send(new ExtensionMsg_AddMessageToConsole( 384 rvh->Send(new ExtensionMsg_AddMessageToConsole(
377 rvh->GetRoutingID(), level, message)); 385 rvh->GetRoutingID(), level, message));
378 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698