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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 bool user_gesture, | 81 bool user_gesture, |
82 std::unique_ptr<MediaStreamDevicesController> controller) | 82 std::unique_ptr<MediaStreamDevicesController> controller) |
83 : PermissionInfoBarDelegate( | 83 : PermissionInfoBarDelegate( |
84 controller->GetOrigin(), | 84 controller->GetOrigin(), |
85 // The content setting type and permission type here are only passed | 85 // The content setting type and permission type here are only passed |
86 // in to fit into PermissionInfoBarDelegate, even though media infobar | 86 // in to fit into PermissionInfoBarDelegate, even though media infobar |
87 // controls both mic and camera. This is a temporary state for easy | 87 // controls both mic and camera. This is a temporary state for easy |
88 // refactoring. | 88 // refactoring. |
89 // TODO(lshang): Merge MediaStreamInfoBarDelegateAndroid into | 89 // TODO(lshang): Merge MediaStreamInfoBarDelegateAndroid into |
90 // GroupedPermissionInfoBarDelegate. See crbug.com/606138. | 90 // GroupedPermissionInfoBarDelegate. See crbug.com/606138. |
91 content::PermissionType::AUDIO_CAPTURE, | |
92 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 91 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
93 user_gesture, | 92 user_gesture, |
94 profile, | 93 profile, |
95 // This is only passed in to fit into PermissionInfoBarDelegate. | 94 // This is only passed in to fit into PermissionInfoBarDelegate. |
96 // Infobar accepted/denied/dismissed is handled by controller, not via | 95 // Infobar accepted/denied/dismissed is handled by controller, not via |
97 // callbacks. | 96 // callbacks. |
98 base::Bind(&DoNothing)), | 97 base::Bind(&DoNothing)), |
99 controller_(std::move(controller)) { | 98 controller_(std::move(controller)) { |
100 DCHECK(controller_.get()); | 99 DCHECK(controller_.get()); |
101 DCHECK(controller_->IsAskingForAudio() || controller_->IsAskingForVideo()); | 100 DCHECK(controller_->IsAskingForAudio() || controller_->IsAskingForVideo()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 PermissionUmaUtil::RecordPermissionPromptAccepted( | 144 PermissionUmaUtil::RecordPermissionPromptAccepted( |
146 controller_->GetPermissionRequestType(), | 145 controller_->GetPermissionRequestType(), |
147 PermissionUtil::GetGestureType(user_gesture())); | 146 PermissionUtil::GetGestureType(user_gesture())); |
148 | 147 |
149 bool persist_permission = true; | 148 bool persist_permission = true; |
150 if (ShouldShowPersistenceToggle()) { | 149 if (ShouldShowPersistenceToggle()) { |
151 persist_permission = persist(); | 150 persist_permission = persist(); |
152 | 151 |
153 if (controller_->IsAskingForAudio()) { | 152 if (controller_->IsAskingForAudio()) { |
154 PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle( | 153 PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle( |
155 content::PermissionType::AUDIO_CAPTURE, persist_permission); | 154 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, persist_permission); |
156 } | 155 } |
157 if (controller_->IsAskingForVideo()) { | 156 if (controller_->IsAskingForVideo()) { |
158 PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle( | 157 PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle( |
159 content::PermissionType::VIDEO_CAPTURE, persist_permission); | 158 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, persist_permission); |
160 } | 159 } |
161 } | 160 } |
162 | 161 |
163 controller_->set_persist(persist_permission); | 162 controller_->set_persist(persist_permission); |
164 controller_->PermissionGranted(); | 163 controller_->PermissionGranted(); |
165 return true; | 164 return true; |
166 } | 165 } |
167 | 166 |
168 bool MediaStreamInfoBarDelegateAndroid::Cancel() { | 167 bool MediaStreamInfoBarDelegateAndroid::Cancel() { |
169 // TODO(dominickn): fold these metrics calls into | 168 // TODO(dominickn): fold these metrics calls into |
170 // PermissionUmaUtil::PermissionDenied. See crbug.com/638076. | 169 // PermissionUmaUtil::PermissionDenied. See crbug.com/638076. |
171 PermissionUmaUtil::RecordPermissionPromptDenied( | 170 PermissionUmaUtil::RecordPermissionPromptDenied( |
172 controller_->GetPermissionRequestType(), | 171 controller_->GetPermissionRequestType(), |
173 PermissionUtil::GetGestureType(user_gesture())); | 172 PermissionUtil::GetGestureType(user_gesture())); |
174 | 173 |
175 bool persist_permission = true; | 174 bool persist_permission = true; |
176 if (ShouldShowPersistenceToggle()) { | 175 if (ShouldShowPersistenceToggle()) { |
177 persist_permission = persist(); | 176 persist_permission = persist(); |
178 | 177 |
179 if (controller_->IsAskingForAudio()) { | 178 if (controller_->IsAskingForAudio()) { |
180 PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle( | 179 PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle( |
181 content::PermissionType::AUDIO_CAPTURE, persist_permission); | 180 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, persist_permission); |
182 } | 181 } |
183 if (controller_->IsAskingForVideo()) { | 182 if (controller_->IsAskingForVideo()) { |
184 PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle( | 183 PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle( |
185 content::PermissionType::VIDEO_CAPTURE, persist_permission); | 184 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, persist_permission); |
186 } | 185 } |
187 } | 186 } |
188 controller_->set_persist(persist_permission); | 187 controller_->set_persist(persist_permission); |
189 controller_->PermissionDenied(); | 188 controller_->PermissionDenied(); |
190 return true; | 189 return true; |
191 } | 190 } |
192 | 191 |
193 base::string16 MediaStreamInfoBarDelegateAndroid::GetLinkText() const { | 192 base::string16 MediaStreamInfoBarDelegateAndroid::GetLinkText() const { |
194 return base::string16(); | 193 return base::string16(); |
195 } | 194 } |
196 | 195 |
197 GURL MediaStreamInfoBarDelegateAndroid::GetLinkURL() const { | 196 GURL MediaStreamInfoBarDelegateAndroid::GetLinkURL() const { |
198 return GURL(chrome::kMediaAccessLearnMoreUrl); | 197 return GURL(chrome::kMediaAccessLearnMoreUrl); |
199 } | 198 } |
200 | 199 |
201 std::vector<int> MediaStreamInfoBarDelegateAndroid::content_settings_types() | 200 std::vector<int> MediaStreamInfoBarDelegateAndroid::content_settings_types() |
202 const { | 201 const { |
203 std::vector<int> types; | 202 std::vector<int> types; |
204 if (controller_->IsAskingForAudio()) | 203 if (controller_->IsAskingForAudio()) |
205 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 204 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
206 if (controller_->IsAskingForVideo()) | 205 if (controller_->IsAskingForVideo()) |
207 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 206 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
208 return types; | 207 return types; |
209 } | 208 } |
OLD | NEW |