| 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_devices_controller.h" | 5 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/content_settings/content_settings_provider.h" | 8 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 11 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 11 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
| 12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory
.h" | 12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory
.h" |
| 13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 14 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/common/content_settings.h" | 19 #include "chrome/common/content_settings.h" |
| 18 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 19 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/common/media_stream_request.h" | 22 #include "content/public/common/media_stream_request.h" |
| 21 | 23 |
| 22 using content::BrowserThread; | 24 using content::BrowserThread; |
| 23 | 25 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 51 has_audio_ = false; | 53 has_audio_ = false; |
| 52 | 54 |
| 53 if (has_video_ && GetDevicePolicy(prefs::kVideoCaptureAllowed) == ALWAYS_DENY) | 55 if (has_video_ && GetDevicePolicy(prefs::kVideoCaptureAllowed) == ALWAYS_DENY) |
| 54 has_video_ = false; | 56 has_video_ = false; |
| 55 } | 57 } |
| 56 | 58 |
| 57 MediaStreamDevicesController::~MediaStreamDevicesController() {} | 59 MediaStreamDevicesController::~MediaStreamDevicesController() {} |
| 58 | 60 |
| 59 // static | 61 // static |
| 60 void MediaStreamDevicesController::RegisterUserPrefs( | 62 void MediaStreamDevicesController::RegisterUserPrefs( |
| 61 PrefServiceSyncable* prefs) { | 63 PrefRegistrySyncable* prefs) { |
| 62 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, | 64 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, |
| 63 true, | 65 true, |
| 64 PrefServiceSyncable::UNSYNCABLE_PREF); | 66 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 65 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, | 67 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, |
| 66 true, | 68 true, |
| 67 PrefServiceSyncable::UNSYNCABLE_PREF); | 69 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 68 } | 70 } |
| 69 | 71 |
| 70 | 72 |
| 71 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { | 73 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { |
| 72 // If this is a no UI check for policies only go straight to accept - policy | 74 // If this is a no UI check for policies only go straight to accept - policy |
| 73 // check will be done automatically on the way. | 75 // check will be done automatically on the way. |
| 74 if (request_.request_type == content::MEDIA_OPEN_DEVICE) { | 76 if (request_.request_type == content::MEDIA_OPEN_DEVICE) { |
| 75 Accept(false); | 77 Accept(false); |
| 76 return true; | 78 return true; |
| 77 } | 79 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (update_content_setting) | 171 if (update_content_setting) |
| 170 SetPermission(false); | 172 SetPermission(false); |
| 171 | 173 |
| 172 callback_.Run(content::MediaStreamDevices()); | 174 callback_.Run(content::MediaStreamDevices()); |
| 173 } | 175 } |
| 174 | 176 |
| 175 MediaStreamDevicesController::DevicePolicy | 177 MediaStreamDevicesController::DevicePolicy |
| 176 MediaStreamDevicesController::GetDevicePolicy(const char* policy_name) const { | 178 MediaStreamDevicesController::GetDevicePolicy(const char* policy_name) const { |
| 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 178 | 180 |
| 179 PrefServiceSyncable* pref = profile_->GetPrefs(); | 181 PrefService* prefs = profile_->GetPrefs(); |
| 180 if (!pref->IsManagedPreference(policy_name)) | 182 if (!prefs->IsManagedPreference(policy_name)) |
| 181 return POLICY_NOT_SET; | 183 return POLICY_NOT_SET; |
| 182 | 184 |
| 183 return pref->GetBoolean(policy_name) ? ALWAYS_ALLOW : ALWAYS_DENY; | 185 return prefs->GetBoolean(policy_name) ? ALWAYS_ALLOW : ALWAYS_DENY; |
| 184 } | 186 } |
| 185 | 187 |
| 186 bool MediaStreamDevicesController::IsRequestAllowedByDefault() const { | 188 bool MediaStreamDevicesController::IsRequestAllowedByDefault() const { |
| 187 // The request from internal objects like chrome://URLs is always allowed. | 189 // The request from internal objects like chrome://URLs is always allowed. |
| 188 if (ShouldAlwaysAllowOrigin()) | 190 if (ShouldAlwaysAllowOrigin()) |
| 189 return true; | 191 return true; |
| 190 | 192 |
| 191 struct { | 193 struct { |
| 192 bool has_capability; | 194 bool has_capability; |
| 193 const char* policy_name; | 195 const char* policy_name; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 317 } |
| 316 if (has_video_) { | 318 if (has_video_) { |
| 317 profile_->GetHostContentSettingsMap()->SetContentSetting( | 319 profile_->GetHostContentSettingsMap()->SetContentSetting( |
| 318 primary_pattern, | 320 primary_pattern, |
| 319 ContentSettingsPattern::Wildcard(), | 321 ContentSettingsPattern::Wildcard(), |
| 320 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 322 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 321 std::string(), | 323 std::string(), |
| 322 content_setting); | 324 content_setting); |
| 323 } | 325 } |
| 324 } | 326 } |
| OLD | NEW |