| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_device_permissions.h" | 5 #include "chrome/browser/media/media_stream_device_permissions.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "components/content_settings/core/browser/host_content_settings_map.h" | 10 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 11 #include "components/content_settings/core/common/content_settings_pattern.h" | 11 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/common/origin_util.h" | 13 #include "content/public/common/origin_util.h" |
| 14 #include "extensions/common/constants.h" | 14 #include "extensions/common/constants.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 bool ShouldPersistContentSetting(ContentSetting setting, | 17 bool ShouldPersistContentSetting(ContentSetting setting, |
| 18 const GURL& origin, | 18 const GURL& origin, |
| 19 content::MediaStreamRequestType type) { | 19 bool is_pepper_request) { |
| 20 // When the request is from an invalid scheme we don't persist it. | 20 // When the request is from an invalid scheme we don't persist it. |
| 21 if (!ContentSettingsPattern::FromURLNoWildcard(origin).IsValid()) | 21 if (!ContentSettingsPattern::FromURLNoWildcard(origin).IsValid()) |
| 22 return false; | 22 return false; |
| 23 | 23 |
| 24 // It's safe to persist block settings all the time. | 24 // It's safe to persist block settings all the time. |
| 25 if (setting == CONTENT_SETTING_BLOCK) | 25 if (setting == CONTENT_SETTING_BLOCK) |
| 26 return true; | 26 return true; |
| 27 | 27 |
| 28 // Pepper requests should always be persisted to prevent annoying users of | 28 // Pepper requests should always be persisted to prevent annoying users of |
| 29 // plugins. | 29 // plugins. |
| 30 if (type == content::MEDIA_OPEN_DEVICE) | 30 if (is_pepper_request) |
| 31 return true; | 31 return true; |
| 32 | 32 |
| 33 // We persist requests from secure origins. | 33 // We persist requests from secure origins. |
| 34 if (content::IsOriginSecure(origin)) | 34 if (content::IsOriginSecure(origin)) |
| 35 return true; | 35 return true; |
| 36 | 36 |
| 37 return false; | 37 return false; |
| 38 } | 38 } |
| 39 | 39 |
| 40 MediaStreamDevicePolicy GetDevicePolicy(const Profile* profile, | 40 MediaStreamDevicePolicy GetDevicePolicy(const Profile* profile, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 66 | 66 |
| 67 // If a match was not found, check if audio capture is otherwise disallowed | 67 // If a match was not found, check if audio capture is otherwise disallowed |
| 68 // or if the user should be prompted. Setting the policy value to "true" | 68 // or if the user should be prompted. Setting the policy value to "true" |
| 69 // is equal to not setting it at all, so from hereon out, we will return | 69 // is equal to not setting it at all, so from hereon out, we will return |
| 70 // either POLICY_NOT_SET (prompt) or ALWAYS_DENY (no prompt, no access). | 70 // either POLICY_NOT_SET (prompt) or ALWAYS_DENY (no prompt, no access). |
| 71 if (!prefs->GetBoolean(policy_name)) | 71 if (!prefs->GetBoolean(policy_name)) |
| 72 return ALWAYS_DENY; | 72 return ALWAYS_DENY; |
| 73 | 73 |
| 74 return POLICY_NOT_SET; | 74 return POLICY_NOT_SET; |
| 75 } | 75 } |
| OLD | NEW |