| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 void MediaStreamDevicesController::PermissionDenied() { | 308 void MediaStreamDevicesController::PermissionDenied() { |
| 309 RecordPermissionAction(request_, profile_, | 309 RecordPermissionAction(request_, profile_, |
| 310 base::Bind(PermissionUmaUtil::PermissionDenied)); | 310 base::Bind(PermissionUmaUtil::PermissionDenied)); |
| 311 RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 311 RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| 312 old_audio_setting_, CONTENT_SETTING_BLOCK), | 312 old_audio_setting_, CONTENT_SETTING_BLOCK), |
| 313 GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 313 GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 314 old_video_setting_, CONTENT_SETTING_BLOCK), | 314 old_video_setting_, CONTENT_SETTING_BLOCK), |
| 315 content::MEDIA_DEVICE_PERMISSION_DENIED); | 315 content::MEDIA_DEVICE_PERMISSION_DENIED); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void MediaStreamDevicesController::GroupedRequestFinished(bool audio_accepted, | |
| 319 bool video_accepted) { | |
| 320 RecordSinglePermissionAction( | |
| 321 request_, content::PermissionType::AUDIO_CAPTURE, profile_, | |
| 322 base::Bind(audio_accepted ? PermissionUmaUtil::PermissionGranted | |
| 323 : PermissionUmaUtil::PermissionDenied)); | |
| 324 RecordSinglePermissionAction( | |
| 325 request_, content::PermissionType::VIDEO_CAPTURE, profile_, | |
| 326 base::Bind(video_accepted ? PermissionUmaUtil::PermissionGranted | |
| 327 : PermissionUmaUtil::PermissionDenied)); | |
| 328 | |
| 329 ContentSetting audio_setting = | |
| 330 audio_accepted ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | |
| 331 ContentSetting video_setting = | |
| 332 video_accepted ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | |
| 333 RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | |
| 334 old_audio_setting_, audio_setting), | |
| 335 GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | |
| 336 old_video_setting_, video_setting), | |
| 337 content::MEDIA_DEVICE_PERMISSION_DENIED); | |
| 338 } | |
| 339 | |
| 340 bool MediaStreamDevicesController::ShouldShowPersistenceToggle() const { | 318 bool MediaStreamDevicesController::ShouldShowPersistenceToggle() const { |
| 341 return PermissionUtil::ShouldShowPersistenceToggle(); | 319 return PermissionUtil::ShouldShowPersistenceToggle(); |
| 342 } | 320 } |
| 343 | 321 |
| 344 void MediaStreamDevicesController::Cancelled() { | 322 void MediaStreamDevicesController::Cancelled() { |
| 345 RecordPermissionAction(request_, profile_, | 323 RecordPermissionAction(request_, profile_, |
| 346 base::Bind(PermissionUmaUtil::PermissionDismissed)); | 324 base::Bind(PermissionUmaUtil::PermissionDismissed)); |
| 347 RunCallback(old_audio_setting_, old_video_setting_, | 325 RunCallback(old_audio_setting_, old_video_setting_, |
| 348 content::MEDIA_DEVICE_PERMISSION_DISMISSED); | 326 content::MEDIA_DEVICE_PERMISSION_DISMISSED); |
| 349 } | 327 } |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 if (android_permission_blocked) | 624 if (android_permission_blocked) |
| 647 return false; | 625 return false; |
| 648 | 626 |
| 649 // Don't approve device requests if the tab was hidden. | 627 // Don't approve device requests if the tab was hidden. |
| 650 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 628 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 651 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 629 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 652 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 630 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 653 #endif | 631 #endif |
| 654 return true; | 632 return true; |
| 655 } | 633 } |
| OLD | NEW |