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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "components/content_settings/core/browser/host_content_settings_map.h" | 12 #include "components/content_settings/core/browser/host_content_settings_map.h" |
13 #include "components/content_settings/core/common/content_settings_pattern.h" | 13 #include "components/content_settings/core/common/content_settings_pattern.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/common/origin_util.h" | |
16 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
17 #include "url/gurl.h" | 16 #include "url/gurl.h" |
18 | 17 |
19 #if defined(OS_CHROMEOS) | 18 #if defined(OS_CHROMEOS) |
20 #include "components/user_manager/user_manager.h" | 19 #include "components/user_manager/user_manager.h" |
21 #endif | 20 #endif |
22 | 21 |
23 namespace { | 22 namespace { |
24 | 23 |
25 bool IsInKioskMode() { | 24 bool IsInKioskMode() { |
(...skipping 21 matching lines...) Expand all Loading... |
47 // It's safe to persist block settings all the time. | 46 // It's safe to persist block settings all the time. |
48 if (setting == CONTENT_SETTING_BLOCK) | 47 if (setting == CONTENT_SETTING_BLOCK) |
49 return true; | 48 return true; |
50 | 49 |
51 // Pepper requests should always be persisted to prevent annoying users of | 50 // Pepper requests should always be persisted to prevent annoying users of |
52 // plugins. | 51 // plugins. |
53 if (type == content::MEDIA_OPEN_DEVICE) | 52 if (type == content::MEDIA_OPEN_DEVICE) |
54 return true; | 53 return true; |
55 | 54 |
56 // We persist requests from secure origins. | 55 // We persist requests from secure origins. |
57 if (content::IsOriginSecure(origin)) | 56 if (origin.SchemeIsSecure()) |
| 57 return true; |
| 58 |
| 59 // We persist requests from extensions. |
| 60 if (origin.SchemeIs(extensions::kExtensionScheme)) |
58 return true; | 61 return true; |
59 | 62 |
60 return false; | 63 return false; |
61 } | 64 } |
62 | 65 |
63 bool CheckAllowAllMediaStreamContentForOrigin(Profile* profile, | 66 bool CheckAllowAllMediaStreamContentForOrigin(Profile* profile, |
64 const GURL& security_origin, | 67 const GURL& security_origin, |
65 ContentSettingsType type) { | 68 ContentSettingsType type) { |
66 DCHECK(type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 69 DCHECK(type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
67 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 70 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 106 |
104 // If a match was not found, check if audio capture is otherwise disallowed | 107 // If a match was not found, check if audio capture is otherwise disallowed |
105 // or if the user should be prompted. Setting the policy value to "true" | 108 // or if the user should be prompted. Setting the policy value to "true" |
106 // is equal to not setting it at all, so from hereon out, we will return | 109 // is equal to not setting it at all, so from hereon out, we will return |
107 // either POLICY_NOT_SET (prompt) or ALWAYS_DENY (no prompt, no access). | 110 // either POLICY_NOT_SET (prompt) or ALWAYS_DENY (no prompt, no access). |
108 if (!prefs->GetBoolean(policy_name)) | 111 if (!prefs->GetBoolean(policy_name)) |
109 return ALWAYS_DENY; | 112 return ALWAYS_DENY; |
110 | 113 |
111 return POLICY_NOT_SET; | 114 return POLICY_NOT_SET; |
112 } | 115 } |
OLD | NEW |