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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 // device id is non-empty, then the corresponding device list must not be | 183 // device id is non-empty, then the corresponding device list must not be |
184 // NULL. | 184 // NULL. |
185 if (!device_id.empty() && !devices->FindById(device_id)) | 185 if (!device_id.empty() && !devices->FindById(device_id)) |
186 return false; | 186 return false; |
187 | 187 |
188 return true; | 188 return true; |
189 } | 189 } |
190 | 190 |
191 } // namespace | 191 } // namespace |
192 | 192 |
193 MediaStreamDevicesController::Request::Request( | |
194 Profile* profile, | |
195 bool is_asking_for_audio, | |
196 bool is_asking_for_video, | |
197 const GURL& security_origin, | |
198 PromptAnsweredCallback prompt_answered_callback) | |
199 : profile_(profile), | |
200 is_asking_for_audio_(is_asking_for_audio), | |
201 is_asking_for_video_(is_asking_for_video), | |
202 security_origin_(security_origin), | |
203 prompt_answered_callback_(prompt_answered_callback) {} | |
204 | |
205 MediaStreamDevicesController::Request::~Request() { | |
206 RecordPermissionAction(is_asking_for_audio_, is_asking_for_video_, | |
Timothy Loh
2017/04/20 03:13:20
I think this needs to be guarded somehow otherwise
raymes
2017/04/20 04:23:37
Thanks, good catch! Done.
| |
207 security_origin_, profile_, | |
208 base::Bind(PermissionUmaUtil::PermissionIgnored)); | |
209 } | |
210 | |
211 bool MediaStreamDevicesController::Request::IsAskingForAudio() const { | |
212 return is_asking_for_audio_; | |
213 } | |
214 | |
215 bool MediaStreamDevicesController::Request::IsAskingForVideo() const { | |
216 return is_asking_for_video_; | |
217 } | |
218 | |
219 base::string16 MediaStreamDevicesController::Request::GetMessageText() const { | |
220 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | |
221 if (!IsAskingForAudio()) | |
222 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | |
223 else if (!IsAskingForVideo()) | |
224 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | |
225 return l10n_util::GetStringFUTF16( | |
226 message_id, | |
227 url_formatter::FormatUrlForSecurityDisplay( | |
228 GetOrigin(), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); | |
229 } | |
230 | |
231 PermissionRequest::IconId MediaStreamDevicesController::Request::GetIconId() | |
232 const { | |
233 #if defined(OS_ANDROID) | |
234 return IsAskingForVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA | |
235 : IDR_INFOBAR_MEDIA_STREAM_MIC; | |
236 #else | |
237 return IsAskingForVideo() ? ui::kVideocamIcon : ui::kMicrophoneIcon; | |
238 #endif | |
239 } | |
240 | |
241 base::string16 MediaStreamDevicesController::Request::GetMessageTextFragment() | |
242 const { | |
243 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; | |
244 if (!IsAskingForAudio()) | |
245 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; | |
246 else if (!IsAskingForVideo()) | |
247 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; | |
248 return l10n_util::GetStringUTF16(message_id); | |
249 } | |
250 | |
251 GURL MediaStreamDevicesController::Request::GetOrigin() const { | |
252 return security_origin_; | |
253 } | |
254 | |
255 void MediaStreamDevicesController::Request::PermissionGranted() { | |
256 RecordPermissionAction(is_asking_for_audio_, is_asking_for_video_, | |
257 security_origin_, profile_, | |
258 base::Bind(PermissionUmaUtil::PermissionGranted)); | |
259 prompt_answered_callback_.Run(CONTENT_SETTING_ALLOW, persist()); | |
260 } | |
261 | |
262 void MediaStreamDevicesController::Request::PermissionDenied() { | |
263 RecordPermissionAction(is_asking_for_audio_, is_asking_for_video_, | |
264 security_origin_, profile_, | |
265 base::Bind(PermissionUmaUtil::PermissionDenied)); | |
266 prompt_answered_callback_.Run(CONTENT_SETTING_BLOCK, persist()); | |
267 } | |
268 | |
269 void MediaStreamDevicesController::Request::Cancelled() { | |
270 RecordPermissionAction(is_asking_for_audio_, is_asking_for_video_, | |
271 security_origin_, profile_, | |
272 base::Bind(PermissionUmaUtil::PermissionDismissed)); | |
273 prompt_answered_callback_.Run(CONTENT_SETTING_ASK, false /* persist */); | |
274 } | |
275 | |
276 void MediaStreamDevicesController::Request::RequestFinished() { | |
277 delete this; | |
278 } | |
279 | |
280 PermissionRequestType | |
281 MediaStreamDevicesController::Request::GetPermissionRequestType() const { | |
282 return PermissionRequestType::MEDIA_STREAM; | |
283 } | |
284 | |
285 bool MediaStreamDevicesController::Request::ShouldShowPersistenceToggle() | |
286 const { | |
287 return PermissionUtil::ShouldShowPersistenceToggle(); | |
288 } | |
289 | |
193 // Implementation of PermissionPromptDelegate which actually shows a permission | 290 // Implementation of PermissionPromptDelegate which actually shows a permission |
194 // prompt. | 291 // prompt. |
195 class MediaStreamDevicesController::PermissionPromptDelegateImpl | 292 class MediaStreamDevicesController::PermissionPromptDelegateImpl |
196 : public internal::PermissionPromptDelegate { | 293 : public MediaStreamDevicesController::PermissionPromptDelegate { |
197 public: | 294 public: |
198 void ShowPrompt( | 295 void ShowPrompt( |
199 bool user_gesture, | 296 bool user_gesture, |
200 content::WebContents* web_contents, | 297 content::WebContents* web_contents, |
201 std::unique_ptr<MediaStreamDevicesController> controller) override { | 298 std::unique_ptr<MediaStreamDevicesController::Request> request) override { |
202 #if defined(OS_ANDROID) | 299 #if defined(OS_ANDROID) |
203 PermissionUmaUtil::RecordPermissionPromptShown( | 300 PermissionUmaUtil::RecordPermissionPromptShown( |
204 controller->GetPermissionRequestType(), | 301 request->GetPermissionRequestType(), |
205 PermissionUtil::GetGestureType(user_gesture)); | 302 PermissionUtil::GetGestureType(user_gesture)); |
206 if (PermissionDialogDelegate::ShouldShowDialog(user_gesture)) { | 303 if (PermissionDialogDelegate::ShouldShowDialog(user_gesture)) { |
207 PermissionDialogDelegate::CreateMediaStreamDialog( | 304 PermissionDialogDelegate::CreateMediaStreamDialog( |
208 web_contents, user_gesture, std::move(controller)); | 305 web_contents, user_gesture, std::move(request)); |
209 } else { | 306 } else { |
210 MediaStreamInfoBarDelegateAndroid::Create(web_contents, user_gesture, | 307 MediaStreamInfoBarDelegateAndroid::Create(web_contents, user_gesture, |
211 std::move(controller)); | 308 std::move(request)); |
212 } | 309 } |
213 #else | 310 #else |
214 PermissionRequestManager* permission_request_manager = | 311 PermissionRequestManager* permission_request_manager = |
215 PermissionRequestManager::FromWebContents(web_contents); | 312 PermissionRequestManager::FromWebContents(web_contents); |
216 if (permission_request_manager) | 313 if (permission_request_manager) |
217 permission_request_manager->AddRequest(controller.release()); | 314 permission_request_manager->AddRequest(request.release()); |
218 #endif | 315 #endif |
219 } | 316 } |
220 }; | 317 }; |
221 | 318 |
222 // static | 319 // static |
223 void MediaStreamDevicesController::RequestPermissions( | 320 void MediaStreamDevicesController::RequestPermissions( |
224 const content::MediaStreamRequest& request, | 321 const content::MediaStreamRequest& request, |
225 const content::MediaResponseCallback& callback) { | 322 const content::MediaResponseCallback& callback) { |
226 PermissionPromptDelegateImpl delegate; | 323 PermissionPromptDelegateImpl delegate; |
227 RequestPermissionsWithDelegate(request, callback, &delegate); | 324 RequestPermissionsWithDelegate(request, callback, &delegate); |
228 } | 325 } |
229 | 326 |
230 // static | 327 // static |
231 void MediaStreamDevicesController::RegisterProfilePrefs( | 328 void MediaStreamDevicesController::RegisterProfilePrefs( |
232 user_prefs::PrefRegistrySyncable* prefs) { | 329 user_prefs::PrefRegistrySyncable* prefs) { |
233 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, true); | 330 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, true); |
234 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, true); | 331 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, true); |
235 prefs->RegisterListPref(prefs::kVideoCaptureAllowedUrls); | 332 prefs->RegisterListPref(prefs::kVideoCaptureAllowedUrls); |
236 prefs->RegisterListPref(prefs::kAudioCaptureAllowedUrls); | 333 prefs->RegisterListPref(prefs::kAudioCaptureAllowedUrls); |
237 } | 334 } |
238 | 335 |
239 MediaStreamDevicesController::~MediaStreamDevicesController() { | 336 MediaStreamDevicesController::~MediaStreamDevicesController() { |
240 if (!callback_.is_null()) { | 337 if (!callback_.is_null()) { |
241 RecordPermissionAction(IsAskingForAudio(), IsAskingForVideo(), GetOrigin(), | |
242 profile_, | |
243 base::Bind(PermissionUmaUtil::PermissionIgnored)); | |
244 callback_.Run(content::MediaStreamDevices(), | 338 callback_.Run(content::MediaStreamDevices(), |
245 content::MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN, | 339 content::MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN, |
246 std::unique_ptr<content::MediaStreamUI>()); | 340 std::unique_ptr<content::MediaStreamUI>()); |
247 } | 341 } |
248 } | 342 } |
249 | 343 |
250 bool MediaStreamDevicesController::IsAskingForAudio() const { | 344 bool MediaStreamDevicesController::IsAskingForAudio() const { |
251 return old_audio_setting_ == CONTENT_SETTING_ASK; | 345 return old_audio_setting_ == CONTENT_SETTING_ASK; |
252 } | 346 } |
253 | 347 |
254 bool MediaStreamDevicesController::IsAskingForVideo() const { | 348 bool MediaStreamDevicesController::IsAskingForVideo() const { |
255 return old_video_setting_ == CONTENT_SETTING_ASK; | 349 return old_video_setting_ == CONTENT_SETTING_ASK; |
256 } | 350 } |
257 | 351 |
258 base::string16 MediaStreamDevicesController::GetMessageText() const { | 352 void MediaStreamDevicesController::PromptAnswered(ContentSetting setting, |
259 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 353 bool persist) { |
260 if (!IsAskingForAudio()) | 354 ContentSetting audio_setting = GetNewSetting( |
261 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 355 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, old_audio_setting_, setting); |
262 else if (!IsAskingForVideo()) | 356 ContentSetting video_setting = GetNewSetting( |
263 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | 357 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, old_video_setting_, setting); |
264 return l10n_util::GetStringFUTF16( | 358 |
265 message_id, | 359 if (persist) |
266 url_formatter::FormatUrlForSecurityDisplay( | 360 StorePermission(audio_setting, video_setting); |
267 GetOrigin(), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); | 361 |
362 content::MediaStreamRequestResult denial_reason = content::MEDIA_DEVICE_OK; | |
363 if (setting == CONTENT_SETTING_ASK) | |
364 denial_reason = content::MEDIA_DEVICE_PERMISSION_DISMISSED; | |
365 else if (setting == CONTENT_SETTING_BLOCK) | |
366 denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; | |
367 | |
368 RunCallback(audio_setting, video_setting, denial_reason); | |
268 } | 369 } |
269 | 370 |
270 #if defined(OS_ANDROID) | 371 #if defined(OS_ANDROID) |
271 void MediaStreamDevicesController::AndroidOSPromptAnswered(bool allowed) { | 372 void MediaStreamDevicesController::AndroidOSPromptAnswered(bool allowed) { |
272 DCHECK(old_audio_setting_ != CONTENT_SETTING_ASK && | 373 DCHECK(old_audio_setting_ != CONTENT_SETTING_ASK && |
273 old_video_setting_ != CONTENT_SETTING_ASK); | 374 old_video_setting_ != CONTENT_SETTING_ASK); |
274 | 375 |
275 ContentSetting audio_setting = old_audio_setting_; | 376 ContentSetting audio_setting = old_audio_setting_; |
276 ContentSetting video_setting = old_video_setting_; | 377 ContentSetting video_setting = old_video_setting_; |
277 | 378 |
278 if (!allowed) { | 379 if (!allowed) { |
279 // Only permissions that were previously ALLOW for a site will have had | 380 // Only permissions that were previously ALLOW for a site will have had |
280 // their android permissions requested. It's only in that case that we need | 381 // their android permissions requested. It's only in that case that we need |
281 // to change the setting to BLOCK to reflect that it wasn't allowed. | 382 // to change the setting to BLOCK to reflect that it wasn't allowed. |
282 if (audio_setting == CONTENT_SETTING_ALLOW) | 383 if (audio_setting == CONTENT_SETTING_ALLOW) |
283 audio_setting = CONTENT_SETTING_BLOCK; | 384 audio_setting = CONTENT_SETTING_BLOCK; |
284 if (video_setting == CONTENT_SETTING_ALLOW) | 385 if (video_setting == CONTENT_SETTING_ALLOW) |
285 video_setting = CONTENT_SETTING_BLOCK; | 386 video_setting = CONTENT_SETTING_BLOCK; |
286 } | 387 } |
287 | 388 |
288 RunCallback(audio_setting, video_setting, | 389 RunCallback(audio_setting, video_setting, |
289 content::MEDIA_DEVICE_PERMISSION_DENIED); | 390 content::MEDIA_DEVICE_PERMISSION_DENIED); |
290 } | 391 } |
291 #endif // defined(OS_ANDROID) | 392 #endif // defined(OS_ANDROID) |
292 | 393 |
293 PermissionRequest::IconId MediaStreamDevicesController::GetIconId() const { | |
294 #if defined(OS_ANDROID) | |
295 return IsAskingForVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA | |
296 : IDR_INFOBAR_MEDIA_STREAM_MIC; | |
297 #else | |
298 return IsAskingForVideo() ? ui::kVideocamIcon : ui::kMicrophoneIcon; | |
299 #endif | |
300 } | |
301 | |
302 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { | |
303 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; | |
304 if (!IsAskingForAudio()) | |
305 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; | |
306 else if (!IsAskingForVideo()) | |
307 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; | |
308 return l10n_util::GetStringUTF16(message_id); | |
309 } | |
310 | |
311 GURL MediaStreamDevicesController::GetOrigin() const { | |
312 return request_.security_origin; | |
313 } | |
314 | |
315 void MediaStreamDevicesController::PermissionGranted() { | |
316 RecordPermissionAction(IsAskingForAudio(), IsAskingForVideo(), GetOrigin(), | |
317 profile_, | |
318 base::Bind(PermissionUmaUtil::PermissionGranted)); | |
319 RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | |
320 old_audio_setting_, CONTENT_SETTING_ALLOW), | |
321 GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | |
322 old_video_setting_, CONTENT_SETTING_ALLOW), | |
323 content::MEDIA_DEVICE_PERMISSION_DENIED); | |
324 } | |
325 | |
326 void MediaStreamDevicesController::PermissionDenied() { | |
327 RecordPermissionAction(IsAskingForAudio(), IsAskingForVideo(), GetOrigin(), | |
328 profile_, | |
329 base::Bind(PermissionUmaUtil::PermissionDenied)); | |
330 RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | |
331 old_audio_setting_, CONTENT_SETTING_BLOCK), | |
332 GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | |
333 old_video_setting_, CONTENT_SETTING_BLOCK), | |
334 content::MEDIA_DEVICE_PERMISSION_DENIED); | |
335 } | |
336 | |
337 bool MediaStreamDevicesController::ShouldShowPersistenceToggle() const { | |
338 return PermissionUtil::ShouldShowPersistenceToggle(); | |
339 } | |
340 | |
341 void MediaStreamDevicesController::Cancelled() { | |
342 RecordPermissionAction(IsAskingForAudio(), IsAskingForVideo(), GetOrigin(), | |
343 profile_, | |
344 base::Bind(PermissionUmaUtil::PermissionDismissed)); | |
345 RunCallback(old_audio_setting_, old_video_setting_, | |
346 content::MEDIA_DEVICE_PERMISSION_DISMISSED); | |
347 } | |
348 | |
349 void MediaStreamDevicesController::RequestFinished() { | |
350 delete this; | |
351 } | |
352 | |
353 PermissionRequestType MediaStreamDevicesController::GetPermissionRequestType() | |
354 const { | |
355 return PermissionRequestType::MEDIA_STREAM; | |
356 } | |
357 | |
358 // static | 394 // static |
359 void MediaStreamDevicesController::RequestPermissionsWithDelegate( | 395 void MediaStreamDevicesController::RequestPermissionsWithDelegate( |
360 const content::MediaStreamRequest& request, | 396 const content::MediaStreamRequest& request, |
361 const content::MediaResponseCallback& callback, | 397 const content::MediaResponseCallback& callback, |
362 internal::PermissionPromptDelegate* delegate) { | 398 PermissionPromptDelegate* delegate) { |
363 content::WebContents* web_contents = | 399 content::WebContents* web_contents = |
364 content::WebContents::FromRenderFrameHost( | 400 content::WebContents::FromRenderFrameHost( |
365 content::RenderFrameHost::FromID(request.render_process_id, | 401 content::RenderFrameHost::FromID(request.render_process_id, |
366 request.render_frame_id)); | 402 request.render_frame_id)); |
367 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) { | 403 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) { |
368 MediaPermissionRequestLogger::LogRequest( | 404 MediaPermissionRequestLogger::LogRequest( |
369 web_contents, request.render_process_id, request.render_frame_id, | 405 web_contents, request.render_process_id, request.render_frame_id, |
370 content::IsOriginSecure(request.security_origin)); | 406 content::IsOriginSecure(request.security_origin)); |
371 } | 407 } |
372 | 408 |
(...skipping 17 matching lines...) Expand all Loading... | |
390 web_contents, content_settings_types)) { | 426 web_contents, content_settings_types)) { |
391 PermissionUpdateInfoBarDelegate::Create( | 427 PermissionUpdateInfoBarDelegate::Create( |
392 web_contents, content_settings_types, | 428 web_contents, content_settings_types, |
393 base::Bind(&MediaStreamDevicesController::AndroidOSPromptAnswered, | 429 base::Bind(&MediaStreamDevicesController::AndroidOSPromptAnswered, |
394 base::Passed(&controller))); | 430 base::Passed(&controller))); |
395 } | 431 } |
396 #endif | 432 #endif |
397 return; | 433 return; |
398 } | 434 } |
399 | 435 |
400 delegate->ShowPrompt(request.user_gesture, web_contents, | 436 Profile* profile = |
401 std::move(controller)); | 437 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
438 delegate->ShowPrompt( | |
439 request.user_gesture, web_contents, | |
440 base::MakeUnique<MediaStreamDevicesController::Request>( | |
441 profile, controller->IsAskingForAudio(), | |
442 controller->IsAskingForVideo(), request.security_origin, | |
443 base::Bind(&MediaStreamDevicesController::PromptAnswered, | |
444 base::Passed(&controller)))); | |
402 } | 445 } |
403 | 446 |
404 MediaStreamDevicesController::MediaStreamDevicesController( | 447 MediaStreamDevicesController::MediaStreamDevicesController( |
405 content::WebContents* web_contents, | 448 content::WebContents* web_contents, |
406 const content::MediaStreamRequest& request, | 449 const content::MediaStreamRequest& request, |
407 const content::MediaResponseCallback& callback) | 450 const content::MediaResponseCallback& callback) |
408 : web_contents_(web_contents), request_(request), callback_(callback) { | 451 : web_contents_(web_contents), request_(request), callback_(callback) { |
409 profile_ = Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 452 profile_ = Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
410 content_settings_ = TabSpecificContentSettings::FromWebContents(web_contents); | 453 content_settings_ = TabSpecificContentSettings::FromWebContents(web_contents); |
411 | 454 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 | 583 |
541 return devices; | 584 return devices; |
542 } | 585 } |
543 | 586 |
544 void MediaStreamDevicesController::RunCallback( | 587 void MediaStreamDevicesController::RunCallback( |
545 ContentSetting audio_setting, | 588 ContentSetting audio_setting, |
546 ContentSetting video_setting, | 589 ContentSetting video_setting, |
547 content::MediaStreamRequestResult denial_reason) { | 590 content::MediaStreamRequestResult denial_reason) { |
548 CHECK(!callback_.is_null()); | 591 CHECK(!callback_.is_null()); |
549 | 592 |
550 // If the kill switch is on we don't update the tab context or persist the | 593 // If the kill switch is on we don't update the tab context. |
551 // setting. | 594 if (denial_reason != content::MEDIA_DEVICE_KILL_SWITCH_ON) |
552 if (denial_reason != content::MEDIA_DEVICE_KILL_SWITCH_ON) { | |
553 if (persist()) | |
554 StorePermission(audio_setting, video_setting); | |
555 UpdateTabSpecificContentSettings(audio_setting, video_setting); | 595 UpdateTabSpecificContentSettings(audio_setting, video_setting); |
556 } | |
557 | 596 |
558 content::MediaStreamDevices devices = | 597 content::MediaStreamDevices devices = |
559 GetDevices(audio_setting, video_setting); | 598 GetDevices(audio_setting, video_setting); |
560 | 599 |
561 // If either audio or video are allowed then the callback should report | 600 // If either audio or video are allowed then the callback should report |
562 // success, otherwise we report |denial_reason|. | 601 // success, otherwise we report |denial_reason|. |
563 content::MediaStreamRequestResult request_result = content::MEDIA_DEVICE_OK; | 602 content::MediaStreamRequestResult request_result = content::MEDIA_DEVICE_OK; |
564 if (audio_setting != CONTENT_SETTING_ALLOW && | 603 if (audio_setting != CONTENT_SETTING_ALLOW && |
565 video_setting != CONTENT_SETTING_ALLOW) { | 604 video_setting != CONTENT_SETTING_ALLOW) { |
566 DCHECK_NE(content::MEDIA_DEVICE_OK, denial_reason); | 605 DCHECK_NE(content::MEDIA_DEVICE_OK, denial_reason); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
687 : content::MEDIA_DEVICE_PERMISSION_DENIED; | 726 : content::MEDIA_DEVICE_PERMISSION_DENIED; |
688 } | 727 } |
689 | 728 |
690 return result.content_setting; | 729 return result.content_setting; |
691 } | 730 } |
692 | 731 |
693 ContentSetting MediaStreamDevicesController::GetNewSetting( | 732 ContentSetting MediaStreamDevicesController::GetNewSetting( |
694 ContentSettingsType content_type, | 733 ContentSettingsType content_type, |
695 ContentSetting old_setting, | 734 ContentSetting old_setting, |
696 ContentSetting user_decision) const { | 735 ContentSetting user_decision) const { |
697 DCHECK(user_decision == CONTENT_SETTING_ALLOW || | |
698 user_decision == CONTENT_SETTING_BLOCK); | |
699 ContentSetting result = old_setting; | 736 ContentSetting result = old_setting; |
700 if (old_setting == CONTENT_SETTING_ASK) | 737 if (old_setting == CONTENT_SETTING_ASK) |
701 result = user_decision; | 738 result = user_decision; |
702 return result; | 739 return result; |
703 } | 740 } |
704 | 741 |
705 bool MediaStreamDevicesController::IsUserAcceptAllowed( | 742 bool MediaStreamDevicesController::IsUserAcceptAllowed( |
706 ContentSettingsType content_type) const { | 743 ContentSettingsType content_type) const { |
707 #if defined(OS_ANDROID) | 744 #if defined(OS_ANDROID) |
708 content::ContentViewCore* cvc = | 745 content::ContentViewCore* cvc = |
(...skipping 15 matching lines...) Expand all Loading... | |
724 } | 761 } |
725 } | 762 } |
726 | 763 |
727 // Don't approve device requests if the tab was hidden. | 764 // Don't approve device requests if the tab was hidden. |
728 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 765 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
729 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 766 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
730 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 767 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
731 #endif | 768 #endif |
732 return true; | 769 return true; |
733 } | 770 } |
OLD | NEW |