Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: chrome/browser/media/media_stream_devices_controller.cc

Issue 965103004: Stop using the MEDIASTREAM content setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase over 1004733003. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_devices_controller.h" 5 #include "chrome/browser/media/media_stream_devices_controller.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/scoped_user_pref_update.h" 8 #include "base/prefs/scoped_user_pref_update.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 kCancel, kPermissionActionsMax); 493 kCancel, kPermissionActionsMax);
494 Deny(false, content::MEDIA_DEVICE_PERMISSION_DISMISSED); 494 Deny(false, content::MEDIA_DEVICE_PERMISSION_DISMISSED);
495 } 495 }
496 496
497 void MediaStreamDevicesController::RequestFinished() { 497 void MediaStreamDevicesController::RequestFinished() {
498 delete this; 498 delete this;
499 } 499 }
500 500
501 bool MediaStreamDevicesController::IsRequestAllowedByDefault() const { 501 bool MediaStreamDevicesController::IsRequestAllowedByDefault() const {
502 // The request from internal objects like chrome://URLs is always allowed. 502 // The request from internal objects like chrome://URLs is always allowed.
503 if (CheckAllowAllMediaStreamContentForOrigin(profile_, 503 if (CheckAllowAllMediaStreamContentForOrigin(
504 request_.security_origin)) { 504 profile_, request_.security_origin,
505 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) &&
506 CheckAllowAllMediaStreamContentForOrigin(
507 profile_, request_.security_origin,
508 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)) {
505 return true; 509 return true;
506 } 510 }
507 511
508 struct { 512 struct {
509 bool has_capability; 513 bool has_capability;
510 const char* policy_name; 514 const char* policy_name;
511 const char* list_policy_name; 515 const char* list_policy_name;
512 ContentSettingsType settings_type; 516 ContentSettingsType settings_type;
513 } device_checks[] = { 517 } device_checks[] = {
514 { IsDeviceAudioCaptureRequestedAndAllowed(), prefs::kAudioCaptureAllowed, 518 { IsDeviceAudioCaptureRequestedAndAllowed(), prefs::kAudioCaptureAllowed,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 } else { 583 } else {
580 ++requested_devices; 584 ++requested_devices;
581 } 585 }
582 } 586 }
583 587
584 return requested_devices; 588 return requested_devices;
585 } 589 }
586 590
587 bool MediaStreamDevicesController::IsDefaultMediaAccessBlocked() const { 591 bool MediaStreamDevicesController::IsDefaultMediaAccessBlocked() const {
588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 592 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
589 // TODO(markusheintz): Replace CONTENT_SETTINGS_TYPE_MEDIA_STREAM with the 593 return (profile_->GetHostContentSettingsMap()->GetDefaultContentSetting(
590 // appropriate new CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC and 594 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, NULL)
591 // CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA. 595 == CONTENT_SETTING_BLOCK &&
592 ContentSetting current_setting = 596 profile_->GetHostContentSettingsMap()->GetDefaultContentSetting(
593 profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( 597 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, NULL)
594 CONTENT_SETTINGS_TYPE_MEDIASTREAM, NULL); 598 == CONTENT_SETTING_BLOCK);
595 return (current_setting == CONTENT_SETTING_BLOCK);
596 } 599 }
597 600
598 bool MediaStreamDevicesController::IsSchemeSecure() const { 601 bool MediaStreamDevicesController::IsSchemeSecure() const {
599 return request_.security_origin.SchemeIsSecure() || 602 return request_.security_origin.SchemeIsSecure() ||
600 request_.security_origin.SchemeIs(extensions::kExtensionScheme); 603 request_.security_origin.SchemeIs(extensions::kExtensionScheme);
601 } 604 }
602 605
603 void MediaStreamDevicesController::StorePermission(bool allowed) const { 606 void MediaStreamDevicesController::StorePermission(bool allowed) const {
604 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
605 ContentSettingsPattern primary_pattern = 608 ContentSettingsPattern primary_pattern =
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } 680 }
678 681
679 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { 682 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const {
680 #if defined(OS_ANDROID) 683 #if defined(OS_ANDROID)
681 // Don't approve device requests if the tab was hidden. 684 // Don't approve device requests if the tab was hidden.
682 // TODO(qinmin): Add a test for this. http://crbug.com/396869. 685 // TODO(qinmin): Add a test for this. http://crbug.com/396869.
683 return web_contents_->GetRenderWidgetHostView()->IsShowing(); 686 return web_contents_->GetRenderWidgetHostView()->IsShowing();
684 #endif 687 #endif
685 return true; 688 return true;
686 } 689 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698