| 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_infobar_delegate_android.h" | 5 #include "chrome/browser/media/media_stream_infobar_delegate_android.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // Get a list of content types being requested. Note that the order of the | 31 // Get a list of content types being requested. Note that the order of the |
| 32 // resulting array corresponds to the kGroupedInfobarAudio/VideoPermission | 32 // resulting array corresponds to the kGroupedInfobarAudio/VideoPermission |
| 33 // constants. | 33 // constants. |
| 34 std::vector<ContentSettingsType> GetContentSettingsTypes( | 34 std::vector<ContentSettingsType> GetContentSettingsTypes( |
| 35 MediaStreamDevicesController* controller) { | 35 MediaStreamDevicesController* controller) { |
| 36 std::vector<ContentSettingsType> types; | 36 std::vector<ContentSettingsType> types; |
| 37 if (controller->IsAskingForAudio()) | 37 if (controller->IsAskingForAudio()) |
| 38 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 38 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 39 if (controller->IsAskingForVideo()) | 39 if (controller->IsAskingForVideo()) |
| 40 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 40 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 41 if (controller->IsAskingForScreenCapture()) |
| 42 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_SCREEN); |
| 41 return types; | 43 return types; |
| 42 } | 44 } |
| 43 | 45 |
| 44 } // namespace | 46 } // namespace |
| 45 | 47 |
| 46 MediaStreamInfoBarDelegateAndroid::~MediaStreamInfoBarDelegateAndroid() {} | 48 MediaStreamInfoBarDelegateAndroid::~MediaStreamInfoBarDelegateAndroid() {} |
| 47 | 49 |
| 48 // static | 50 // static |
| 49 bool MediaStreamInfoBarDelegateAndroid::Create( | 51 bool MediaStreamInfoBarDelegateAndroid::Create( |
| 50 content::WebContents* web_contents, | 52 content::WebContents* web_contents, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 78 return MEDIA_STREAM_INFOBAR_DELEGATE_ANDROID; | 80 return MEDIA_STREAM_INFOBAR_DELEGATE_ANDROID; |
| 79 } | 81 } |
| 80 | 82 |
| 81 MediaStreamInfoBarDelegateAndroid::MediaStreamInfoBarDelegateAndroid( | 83 MediaStreamInfoBarDelegateAndroid::MediaStreamInfoBarDelegateAndroid( |
| 82 std::unique_ptr<MediaStreamDevicesController> controller) | 84 std::unique_ptr<MediaStreamDevicesController> controller) |
| 83 : GroupedPermissionInfoBarDelegate( | 85 : GroupedPermissionInfoBarDelegate( |
| 84 controller->GetOrigin(), | 86 controller->GetOrigin(), |
| 85 GetContentSettingsTypes(controller.get())), | 87 GetContentSettingsTypes(controller.get())), |
| 86 controller_(std::move(controller)) { | 88 controller_(std::move(controller)) { |
| 87 DCHECK(controller_.get()); | 89 DCHECK(controller_.get()); |
| 88 DCHECK(controller_->IsAskingForAudio() || controller_->IsAskingForVideo()); | 90 DCHECK(controller_->IsAskingForAudio() || controller_->IsAskingForVideo() || |
| 91 controller_->IsAskingForScreenCapture()); |
| 89 } | 92 } |
| 90 | 93 |
| 91 void MediaStreamInfoBarDelegateAndroid::InfoBarDismissed() { | 94 void MediaStreamInfoBarDelegateAndroid::InfoBarDismissed() { |
| 92 // Deny the request if the infobar was closed with the 'x' button, since | 95 // Deny the request if the infobar was closed with the 'x' button, since |
| 93 // we don't want WebRTC to be waiting for an answer that will never come. | 96 // we don't want WebRTC to be waiting for an answer that will never come. |
| 94 controller_->Cancelled(); | 97 controller_->Cancelled(); |
| 95 } | 98 } |
| 96 | 99 |
| 97 MediaStreamInfoBarDelegateAndroid* | 100 MediaStreamInfoBarDelegateAndroid* |
| 98 MediaStreamInfoBarDelegateAndroid::AsMediaStreamInfoBarDelegateAndroid() { | 101 MediaStreamInfoBarDelegateAndroid::AsMediaStreamInfoBarDelegateAndroid() { |
| 99 return this; | 102 return this; |
| 100 } | 103 } |
| 101 | 104 |
| 102 bool MediaStreamInfoBarDelegateAndroid::Accept() { | 105 bool MediaStreamInfoBarDelegateAndroid::Accept() { |
| 103 if (GetPermissionCount() == 2) { | 106 if (GetPermissionCount() == 2) { |
| 104 controller_->GroupedRequestFinished( | 107 controller_->GroupedRequestFinished( |
| 105 GetAcceptState(kGroupedInfobarAudioPosition), | 108 GetAcceptState(kGroupedInfobarAudioPosition), |
| 106 GetAcceptState(kGroupedInfobarVideoPosition)); | 109 GetAcceptState(kGroupedInfobarVideoPosition)); |
| 107 } else { | 110 } else { |
| 108 DCHECK_EQ(1, GetPermissionCount()); | 111 DCHECK_EQ(1, GetPermissionCount()); |
| 109 controller_->PermissionGranted(); | 112 controller_->PermissionGranted(); |
| 110 } | 113 } |
| 111 return true; | 114 return true; |
| 112 } | 115 } |
| 113 | 116 |
| 114 bool MediaStreamInfoBarDelegateAndroid::Cancel() { | 117 bool MediaStreamInfoBarDelegateAndroid::Cancel() { |
| 115 controller_->PermissionDenied(); | 118 controller_->PermissionDenied(); |
| 116 return true; | 119 return true; |
| 117 } | 120 } |
| OLD | NEW |