| 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 #if defined(OS_ANDROID) | 577 #if defined(OS_ANDROID) |
| 578 content::ContentViewCore* cvc = | 578 content::ContentViewCore* cvc = |
| 579 content::ContentViewCore::FromWebContents(web_contents_); | 579 content::ContentViewCore::FromWebContents(web_contents_); |
| 580 if (!cvc) | 580 if (!cvc) |
| 581 return false; | 581 return false; |
| 582 | 582 |
| 583 ui::WindowAndroid* window_android = cvc->GetWindowAndroid(); | 583 ui::WindowAndroid* window_android = cvc->GetWindowAndroid(); |
| 584 if (!window_android) | 584 if (!window_android) |
| 585 return false; | 585 return false; |
| 586 | 586 |
| 587 std::string android_permission = | 587 std::vector<std::string> android_permissions; |
| 588 PrefServiceBridge::GetAndroidPermissionForContentSetting(content_type); | 588 PrefServiceBridge::GetAndroidPermissionsForContentSetting( |
| 589 bool android_permission_blocked = false; | 589 content_type, &android_permissions); |
| 590 if (!android_permission.empty()) { | 590 for (const auto& android_permission : android_permissions) { |
| 591 android_permission_blocked = | 591 if (!window_android->HasPermission(android_permission) && |
| 592 !window_android->HasPermission(android_permission) && | 592 !window_android->CanRequestPermission(android_permission)) { |
| 593 !window_android->CanRequestPermission(android_permission); | 593 return false; |
| 594 } |
| 594 } | 595 } |
| 595 if (android_permission_blocked) | |
| 596 return false; | |
| 597 | 596 |
| 598 // Don't approve device requests if the tab was hidden. | 597 // Don't approve device requests if the tab was hidden. |
| 599 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 598 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 600 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 599 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 601 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 600 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 602 #endif | 601 #endif |
| 603 return true; | 602 return true; |
| 604 } | 603 } |
| OLD | NEW |