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