| 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/media_stream_devices_controller.h" | 5 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/prefs/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 const char* list_policy_name; | 455 const char* list_policy_name; |
| 456 ContentSettingsType settings_type; | 456 ContentSettingsType settings_type; |
| 457 } device_checks[] = { | 457 } device_checks[] = { |
| 458 { IsDeviceAudioCaptureRequestedAndAllowed(), prefs::kAudioCaptureAllowed, | 458 { IsDeviceAudioCaptureRequestedAndAllowed(), prefs::kAudioCaptureAllowed, |
| 459 prefs::kAudioCaptureAllowedUrls, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC }, | 459 prefs::kAudioCaptureAllowedUrls, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC }, |
| 460 { IsDeviceVideoCaptureRequestedAndAllowed(), prefs::kVideoCaptureAllowed, | 460 { IsDeviceVideoCaptureRequestedAndAllowed(), prefs::kVideoCaptureAllowed, |
| 461 prefs::kVideoCaptureAllowedUrls, | 461 prefs::kVideoCaptureAllowedUrls, |
| 462 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA }, | 462 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA }, |
| 463 }; | 463 }; |
| 464 | 464 |
| 465 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(device_checks); ++i) { | 465 for (size_t i = 0; i < arraysize(device_checks); ++i) { |
| 466 if (!device_checks[i].has_capability) | 466 if (!device_checks[i].has_capability) |
| 467 continue; | 467 continue; |
| 468 | 468 |
| 469 MediaStreamDevicePolicy policy = | 469 MediaStreamDevicePolicy policy = |
| 470 GetDevicePolicy(profile_, | 470 GetDevicePolicy(profile_, |
| 471 request_.security_origin, | 471 request_.security_origin, |
| 472 device_checks[i].policy_name, | 472 device_checks[i].policy_name, |
| 473 device_checks[i].list_policy_name); | 473 device_checks[i].list_policy_name); |
| 474 | 474 |
| 475 if (policy == ALWAYS_DENY) | 475 if (policy == ALWAYS_DENY) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 } | 617 } |
| 618 | 618 |
| 619 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { | 619 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { |
| 620 #if defined(OS_ANDROID) | 620 #if defined(OS_ANDROID) |
| 621 // Don't approve device requests if the tab was hidden. | 621 // Don't approve device requests if the tab was hidden. |
| 622 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 622 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 623 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 623 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 624 #endif | 624 #endif |
| 625 return true; | 625 return true; |
| 626 } | 626 } |
| OLD | NEW |