| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/content_settings/core/browser/content_settings_info.h" | 5 #include "components/content_settings/core/browser/content_settings_info.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "components/content_settings/core/browser/website_settings_info.h" |
| 8 | 9 |
| 9 namespace content_settings { | 10 namespace content_settings { |
| 10 | 11 |
| 11 ContentSettingsInfo::ContentSettingsInfo( | 12 ContentSettingsInfo::ContentSettingsInfo( |
| 12 const WebsiteSettingsInfo* website_settings_info, | 13 const WebsiteSettingsInfo* website_settings_info, |
| 13 const std::vector<std::string>& whitelisted_schemes, | 14 const std::vector<std::string>& whitelisted_schemes, |
| 14 const std::set<ContentSetting>& valid_settings, | 15 const std::set<ContentSetting>& valid_settings, |
| 15 IncognitoBehavior incognito_behavior) | 16 IncognitoBehavior incognito_behavior) |
| 16 : website_settings_info_(website_settings_info), | 17 : website_settings_info_(website_settings_info), |
| 17 whitelisted_schemes_(whitelisted_schemes), | 18 whitelisted_schemes_(whitelisted_schemes), |
| 18 valid_settings_(valid_settings), | 19 valid_settings_(valid_settings), |
| 19 incognito_behavior_(incognito_behavior) {} | 20 incognito_behavior_(incognito_behavior) {} |
| 20 | 21 |
| 21 ContentSettingsInfo::~ContentSettingsInfo() {} | 22 ContentSettingsInfo::~ContentSettingsInfo() {} |
| 22 | 23 |
| 23 bool ContentSettingsInfo::IsSettingValid(ContentSetting setting) const { | 24 bool ContentSettingsInfo::IsSettingValid(ContentSetting setting) const { |
| 24 return base::ContainsKey(valid_settings_, setting); | 25 return base::ContainsKey(valid_settings_, setting); |
| 25 } | 26 } |
| 26 | 27 |
| 28 // TODO(raymes): Find a better way to deal with the special-casing in |
| 29 // IsDefaultSettingValid. |
| 30 bool ContentSettingsInfo::IsDefaultSettingValid(ContentSetting setting) const { |
| 31 ContentSettingsType type = website_settings_info_->type(); |
| 32 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 33 // Don't support ALLOW for protected media default setting until migration. |
| 34 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER && |
| 35 setting == CONTENT_SETTING_ALLOW) { |
| 36 return false; |
| 37 } |
| 38 #endif |
| 39 |
| 40 // Don't support ALLOW for the default media settings. |
| 41 if ((type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA || |
| 42 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) && |
| 43 setting == CONTENT_SETTING_ALLOW) { |
| 44 return false; |
| 45 } |
| 46 |
| 47 return base::ContainsKey(valid_settings_, setting); |
| 48 } |
| 49 |
| 27 } // namespace content_settings | 50 } // namespace content_settings |
| OLD | NEW |