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

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

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/desktop_capture_access_handler.h" 5 #include "chrome/browser/media/desktop_capture_access_handler.h"
6 6
7 #include <utility>
8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
11 #include "build/build_config.h" 13 #include "build/build_config.h"
12 #include "chrome/browser/media/desktop_streams_registry.h" 14 #include "chrome/browser/media/desktop_streams_registry.h"
13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 15 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
14 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (application_title == registered_extension_name) { 115 if (application_title == registered_extension_name) {
114 ui = ScreenCaptureNotificationUI::Create(l10n_util::GetStringFUTF16( 116 ui = ScreenCaptureNotificationUI::Create(l10n_util::GetStringFUTF16(
115 IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_TEXT, application_title)); 117 IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_TEXT, application_title));
116 } else { 118 } else {
117 ui = ScreenCaptureNotificationUI::Create(l10n_util::GetStringFUTF16( 119 ui = ScreenCaptureNotificationUI::Create(l10n_util::GetStringFUTF16(
118 IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_TEXT_DELEGATED, 120 IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_TEXT_DELEGATED,
119 registered_extension_name, application_title)); 121 registered_extension_name, application_title));
120 } 122 }
121 } 123 }
122 124
123 return ui.Pass(); 125 return ui;
124 } 126 }
125 127
126 #if !defined(OS_ANDROID) 128 #if !defined(OS_ANDROID)
127 // Find browser or app window from a given |web_contents|. 129 // Find browser or app window from a given |web_contents|.
128 gfx::NativeWindow FindParentWindowForWebContents( 130 gfx::NativeWindow FindParentWindowForWebContents(
129 content::WebContents* web_contents) { 131 content::WebContents* web_contents) {
130 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 132 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
131 if (browser && browser->window()) 133 if (browser && browser->window())
132 return browser->window()->GetNativeWindow(); 134 return browser->window()->GetNativeWindow();
133 135
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 application_title); 262 application_title);
261 DCHECK(!devices.empty()); 263 DCHECK(!devices.empty());
262 } 264 }
263 265
264 // The only case when devices can be empty is if the user has denied 266 // The only case when devices can be empty is if the user has denied
265 // permission. 267 // permission.
266 result = devices.empty() ? content::MEDIA_DEVICE_PERMISSION_DENIED 268 result = devices.empty() ? content::MEDIA_DEVICE_PERMISSION_DENIED
267 : content::MEDIA_DEVICE_OK; 269 : content::MEDIA_DEVICE_OK;
268 } 270 }
269 271
270 callback.Run(devices, result, ui.Pass()); 272 callback.Run(devices, result, std::move(ui));
271 } 273 }
272 274
273 bool DesktopCaptureAccessHandler::SupportsStreamType( 275 bool DesktopCaptureAccessHandler::SupportsStreamType(
274 const content::MediaStreamType type, 276 const content::MediaStreamType type,
275 const extensions::Extension* extension) { 277 const extensions::Extension* extension) {
276 return type == content::MEDIA_DESKTOP_VIDEO_CAPTURE || 278 return type == content::MEDIA_DESKTOP_VIDEO_CAPTURE ||
277 type == content::MEDIA_DESKTOP_AUDIO_CAPTURE; 279 type == content::MEDIA_DESKTOP_AUDIO_CAPTURE;
278 } 280 }
279 281
280 bool DesktopCaptureAccessHandler::CheckMediaAccessPermission( 282 bool DesktopCaptureAccessHandler::CheckMediaAccessPermission(
281 content::WebContents* web_contents, 283 content::WebContents* web_contents,
282 const GURL& security_origin, 284 const GURL& security_origin,
283 content::MediaStreamType type, 285 content::MediaStreamType type,
284 const extensions::Extension* extension) { 286 const extensions::Extension* extension) {
285 return false; 287 return false;
286 } 288 }
287 289
288 void DesktopCaptureAccessHandler::HandleRequest( 290 void DesktopCaptureAccessHandler::HandleRequest(
289 content::WebContents* web_contents, 291 content::WebContents* web_contents,
290 const content::MediaStreamRequest& request, 292 const content::MediaStreamRequest& request,
291 const content::MediaResponseCallback& callback, 293 const content::MediaResponseCallback& callback,
292 const extensions::Extension* extension) { 294 const extensions::Extension* extension) {
293 content::MediaStreamDevices devices; 295 content::MediaStreamDevices devices;
294 scoped_ptr<content::MediaStreamUI> ui; 296 scoped_ptr<content::MediaStreamUI> ui;
295 297
296 if (request.video_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) { 298 if (request.video_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) {
297 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass()); 299 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::move(ui));
298 return; 300 return;
299 } 301 }
300 302
301 // If the device id wasn't specified then this is a screen capture request 303 // If the device id wasn't specified then this is a screen capture request
302 // (i.e. chooseDesktopMedia() API wasn't used to generate device id). 304 // (i.e. chooseDesktopMedia() API wasn't used to generate device id).
303 if (request.requested_video_device_id.empty()) { 305 if (request.requested_video_device_id.empty()) {
304 ProcessScreenCaptureAccessRequest(web_contents, request, callback, 306 ProcessScreenCaptureAccessRequest(web_contents, request, callback,
305 extension); 307 extension);
306 return; 308 return;
307 } 309 }
(...skipping 16 matching lines...) Expand all
324 ->GetDesktopStreamsRegistry() 326 ->GetDesktopStreamsRegistry()
325 ->RequestMediaForStreamId(request.requested_video_device_id, 327 ->RequestMediaForStreamId(request.requested_video_device_id,
326 main_frame->GetProcess()->GetID(), 328 main_frame->GetProcess()->GetID(),
327 main_frame->GetRoutingID(), 329 main_frame->GetRoutingID(),
328 request.security_origin, 330 request.security_origin,
329 &original_extension_name); 331 &original_extension_name);
330 } 332 }
331 333
332 // Received invalid device id. 334 // Received invalid device id.
333 if (media_id.type == content::DesktopMediaID::TYPE_NONE) { 335 if (media_id.type == content::DesktopMediaID::TYPE_NONE) {
334 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass()); 336 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::move(ui));
335 return; 337 return;
336 } 338 }
337 339
338 bool loopback_audio_supported = false; 340 bool loopback_audio_supported = false;
339 #if defined(USE_CRAS) || defined(OS_WIN) 341 #if defined(USE_CRAS) || defined(OS_WIN)
340 // Currently loopback audio capture is supported only on Windows and ChromeOS. 342 // Currently loopback audio capture is supported only on Windows and ChromeOS.
341 loopback_audio_supported = true; 343 loopback_audio_supported = true;
342 #endif 344 #endif
343 345
344 // Audio is only supported for screen capture streams. 346 // Audio is only supported for screen capture streams.
345 bool capture_audio = 347 bool capture_audio =
346 (media_id.type == content::DesktopMediaID::TYPE_SCREEN && 348 (media_id.type == content::DesktopMediaID::TYPE_SCREEN &&
347 request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE && 349 request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE &&
348 loopback_audio_supported); 350 loopback_audio_supported);
349 351
350 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true, 352 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true,
351 GetApplicationTitle(web_contents, extension), 353 GetApplicationTitle(web_contents, extension),
352 base::UTF8ToUTF16(original_extension_name)); 354 base::UTF8ToUTF16(original_extension_name));
353 355
354 callback.Run(devices, content::MEDIA_DEVICE_OK, ui.Pass()); 356 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui));
355 } 357 }
356 358
357 void DesktopCaptureAccessHandler::UpdateMediaRequestState( 359 void DesktopCaptureAccessHandler::UpdateMediaRequestState(
358 int render_process_id, 360 int render_process_id,
359 int render_frame_id, 361 int render_frame_id,
360 int page_request_id, 362 int page_request_id,
361 content::MediaStreamType stream_type, 363 content::MediaStreamType stream_type,
362 content::MediaRequestState state) { 364 content::MediaRequestState state) {
363 DCHECK_CURRENTLY_ON(BrowserThread::UI); 365 DCHECK_CURRENTLY_ON(BrowserThread::UI);
364 // Track desktop capture sessions. Tracking is necessary to avoid unbalanced 366 // Track desktop capture sessions. Tracking is necessary to avoid unbalanced
(...skipping 16 matching lines...) Expand all
381 desktop_capture_sessions_.erase(it); 383 desktop_capture_sessions_.erase(it);
382 break; 384 break;
383 } 385 }
384 } 386 }
385 } 387 }
386 } 388 }
387 389
388 bool DesktopCaptureAccessHandler::IsCaptureInProgress() { 390 bool DesktopCaptureAccessHandler::IsCaptureInProgress() {
389 return desktop_capture_sessions_.size() > 0; 391 return desktop_capture_sessions_.size() > 0;
390 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698