| 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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 return permission.GetPermissionStatus(denial_reason); | 739 return permission.GetPermissionStatus(denial_reason); |
| 740 } | 740 } |
| 741 | 741 |
| 742 ContentSetting MediaStreamDevicesController::GetNewSetting( | 742 ContentSetting MediaStreamDevicesController::GetNewSetting( |
| 743 ContentSettingsType content_type, | 743 ContentSettingsType content_type, |
| 744 ContentSetting old_setting, | 744 ContentSetting old_setting, |
| 745 ContentSetting user_decision) const { | 745 ContentSetting user_decision) const { |
| 746 DCHECK(user_decision == CONTENT_SETTING_ALLOW || | 746 DCHECK(user_decision == CONTENT_SETTING_ALLOW || |
| 747 user_decision == CONTENT_SETTING_BLOCK); | 747 user_decision == CONTENT_SETTING_BLOCK); |
| 748 ContentSetting result = old_setting; | 748 ContentSetting result = old_setting; |
| 749 if (old_setting == CONTENT_SETTING_ASK) { | 749 if (old_setting == CONTENT_SETTING_ASK) |
| 750 if (user_decision == CONTENT_SETTING_ALLOW && | 750 result = user_decision; |
| 751 IsUserAcceptAllowed(content_type)) { | |
| 752 result = CONTENT_SETTING_ALLOW; | |
| 753 } else if (user_decision == CONTENT_SETTING_BLOCK) { | |
| 754 result = CONTENT_SETTING_BLOCK; | |
| 755 } | |
| 756 } | |
| 757 return result; | 751 return result; |
| 758 } | 752 } |
| 759 | 753 |
| 760 bool MediaStreamDevicesController::IsUserAcceptAllowed( | 754 bool MediaStreamDevicesController::IsUserAcceptAllowed( |
| 761 ContentSettingsType content_type) const { | 755 ContentSettingsType content_type) const { |
| 762 #if defined(OS_ANDROID) | 756 #if defined(OS_ANDROID) |
| 763 content::ContentViewCore* cvc = | 757 content::ContentViewCore* cvc = |
| 764 content::ContentViewCore::FromWebContents(web_contents_); | 758 content::ContentViewCore::FromWebContents(web_contents_); |
| 765 if (!cvc) | 759 if (!cvc) |
| 766 return false; | 760 return false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 779 } | 773 } |
| 780 } | 774 } |
| 781 | 775 |
| 782 // Don't approve device requests if the tab was hidden. | 776 // Don't approve device requests if the tab was hidden. |
| 783 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 777 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 784 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 778 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 785 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 779 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 786 #endif | 780 #endif |
| 787 return true; | 781 return true; |
| 788 } | 782 } |
| OLD | NEW |