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

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

Issue 1873293002: Report if video capturing meets output protection requirement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 !base::CommandLine::ForCurrentProcess()->HasSwitch( 438 !base::CommandLine::ForCurrentProcess()->HasSwitch(
439 extensions::switches::kDisableDesktopCaptureAudio); 439 extensions::switches::kDisableDesktopCaptureAudio);
440 const bool capture_audio = 440 const bool capture_audio =
441 (check_audio_permission ? audio_permitted : true) && audio_requested && 441 (check_audio_permission ? audio_permitted : true) && audio_requested &&
442 audio_supported; 442 audio_supported;
443 443
444 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true, 444 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true,
445 GetApplicationTitle(web_contents, extension), 445 GetApplicationTitle(web_contents, extension),
446 base::UTF8ToUTF16(original_extension_name)); 446 base::UTF8ToUTF16(original_extension_name));
447 447
448 extension_whitelisted_ = MediaCaptureDevicesDispatcher::IsOriginForCasting(
miu 2016/04/16 00:05:29 This value will be different for each session. In
xjz 2016/04/21 23:50:44 Done.
449 request.security_origin) ||
450 IsExtensionWhitelistedForScreenCapture(extension) ||
451 IsBuiltInExtension(request.security_origin);
452
448 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui)); 453 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui));
449 } 454 }
450 455
451 void DesktopCaptureAccessHandler::UpdateMediaRequestState( 456 void DesktopCaptureAccessHandler::UpdateMediaRequestState(
452 int render_process_id, 457 int render_process_id,
453 int render_frame_id, 458 int render_frame_id,
454 int page_request_id, 459 int page_request_id,
455 content::MediaStreamType stream_type, 460 content::MediaStreamType stream_type,
456 content::MediaRequestState state) { 461 content::MediaRequestState state) {
457 DCHECK_CURRENTLY_ON(BrowserThread::UI); 462 DCHECK_CURRENTLY_ON(BrowserThread::UI);
458 // Track desktop capture sessions. Tracking is necessary to avoid unbalanced 463 // Track desktop capture sessions. Tracking is necessary to avoid unbalanced
459 // session counts since not all requests will reach MEDIA_REQUEST_STATE_DONE, 464 // session counts since not all requests will reach MEDIA_REQUEST_STATE_DONE,
460 // but they will all reach MEDIA_REQUEST_STATE_CLOSING. 465 // but they will all reach MEDIA_REQUEST_STATE_CLOSING.
461 if (stream_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) 466 if (stream_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE)
462 return; 467 return;
463 468
464 if (state == content::MEDIA_REQUEST_STATE_DONE) { 469 if (state == content::MEDIA_REQUEST_STATE_DONE) {
465 DesktopCaptureSession session = { 470 DesktopCaptureSession session = {render_process_id, render_frame_id,
466 render_process_id, render_frame_id, page_request_id}; 471 page_request_id, false};
467 desktop_capture_sessions_.push_back(session); 472 desktop_capture_sessions_.push_back(session);
468 } else if (state == content::MEDIA_REQUEST_STATE_CLOSING) { 473 } else if (state == content::MEDIA_REQUEST_STATE_CLOSING) {
469 for (DesktopCaptureSessions::iterator it = 474 for (DesktopCaptureSessions::iterator it =
470 desktop_capture_sessions_.begin(); 475 desktop_capture_sessions_.begin();
471 it != desktop_capture_sessions_.end(); ++it) { 476 it != desktop_capture_sessions_.end(); ++it) {
472 if (it->render_process_id == render_process_id && 477 if (it->render_process_id == render_process_id &&
473 it->render_frame_id == render_frame_id && 478 it->render_frame_id == render_frame_id &&
474 it->page_request_id == page_request_id) { 479 it->page_request_id == page_request_id) {
475 desktop_capture_sessions_.erase(it); 480 desktop_capture_sessions_.erase(it);
476 break; 481 break;
477 } 482 }
478 } 483 }
479 } 484 }
480 } 485 }
481 486
482 bool DesktopCaptureAccessHandler::IsCaptureInProgress() { 487 bool DesktopCaptureAccessHandler::IsCaptureInProgress() {
483 return desktop_capture_sessions_.size() > 0; 488 return desktop_capture_sessions_.size() > 0;
484 } 489 }
490
491 bool DesktopCaptureAccessHandler::IsCaptureInProgress(int render_process_id,
492 int render_frame_id,
493 bool* is_link_secure) {
494 *is_link_secure = false;
495 if (desktop_capture_sessions_.size() <= 0)
496 return false;
497 for (DesktopCaptureSessions::iterator it = desktop_capture_sessions_.begin();
498 it != desktop_capture_sessions_.end(); ++it) {
499 if (it->render_process_id == render_process_id &&
500 it->render_frame_id == render_frame_id) {
miu 2016/04/16 00:05:29 You're not checking page_request_id here. So, sho
xjz 2016/04/21 23:50:44 Done. Check all sessions with same render frame.
501 *is_link_secure = it->is_capturing_link_secure && extension_whitelisted_;
502 return true;
503 }
504 }
505 return false;
506 }
507
508 void DesktopCaptureAccessHandler::UpdateCapturingLinkSecured(
509 int render_process_id,
510 int render_frame_id,
511 int page_request_id,
512 content::MediaStreamType stream_type,
miu 2016/04/16 00:05:29 IMO, passing and checking the stream_type here is
xjz 2016/04/21 23:50:44 Done.
513 bool is_secure) {
514 if (stream_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE)
515 return;
516 for (DesktopCaptureSessions::iterator it = desktop_capture_sessions_.begin();
517 it != desktop_capture_sessions_.end(); ++it) {
518 if (it->render_process_id == render_process_id &&
519 it->render_frame_id == render_frame_id &&
520 it->page_request_id == page_request_id) {
521 it->is_capturing_link_secure = is_secure;
522 VLOG(1) << "DesktopCaptureAccessHandler:"
523 << " render_process_id: " << render_process_id
524 << " render_frame_id: " << render_frame_id
525 << " is_capturing_link_secure: " << is_secure;
526 }
527 }
528 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698