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/media/webrtc/media_stream_devices_controller.h" | 5 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) { | 423 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) { |
424 MediaPermissionRequestLogger::LogRequest( | 424 MediaPermissionRequestLogger::LogRequest( |
425 web_contents, request.render_process_id, request.render_frame_id, | 425 web_contents, request.render_process_id, request.render_frame_id, |
426 content::IsOriginSecure(request.security_origin)); | 426 content::IsOriginSecure(request.security_origin)); |
427 } | 427 } |
428 | 428 |
429 std::unique_ptr<MediaStreamDevicesController> controller( | 429 std::unique_ptr<MediaStreamDevicesController> controller( |
430 new MediaStreamDevicesController(web_contents, request, callback)); | 430 new MediaStreamDevicesController(web_contents, request, callback)); |
431 | 431 |
432 // Show a prompt if needed. | 432 // Show a prompt if needed. |
433 if (controller->IsAskingForAudio() || controller->IsAskingForVideo()) { | 433 bool is_asking_for_audio = controller->IsAskingForAudio(); |
| 434 bool is_asking_for_video = controller->IsAskingForVideo(); |
| 435 if (is_asking_for_audio || is_asking_for_video) { |
434 Profile* profile = | 436 Profile* profile = |
435 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 437 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
436 delegate->ShowPrompt( | 438 delegate->ShowPrompt( |
437 request.user_gesture, web_contents, | 439 request.user_gesture, web_contents, |
438 base::MakeUnique<Request>( | 440 base::MakeUnique<Request>( |
439 profile, controller->IsAskingForAudio(), | 441 profile, is_asking_for_audio, is_asking_for_video, |
440 controller->IsAskingForVideo(), request.security_origin, | 442 request.security_origin, |
441 base::Bind(&MediaStreamDevicesController::PromptAnswered, | 443 base::Bind(&MediaStreamDevicesController::PromptAnswered, |
442 base::Passed(&controller)))); | 444 base::Passed(&controller)))); |
443 return; | 445 return; |
444 } | 446 } |
445 | 447 |
446 #if defined(OS_ANDROID) | 448 #if defined(OS_ANDROID) |
447 // If either audio or video was previously allowed and Chrome no longer has | 449 // If either audio or video was previously allowed and Chrome no longer has |
448 // the necessary permissions, show a infobar to attempt to address this | 450 // the necessary permissions, show a infobar to attempt to address this |
449 // mismatch. | 451 // mismatch. |
450 std::vector<ContentSettingsType> content_settings_types; | 452 std::vector<ContentSettingsType> content_settings_types; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 } | 728 } |
727 } | 729 } |
728 | 730 |
729 // Don't approve device requests if the tab was hidden. | 731 // Don't approve device requests if the tab was hidden. |
730 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 732 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
731 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 733 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
732 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 734 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
733 #endif | 735 #endif |
734 return true; | 736 return true; |
735 } | 737 } |
OLD | NEW |