| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/plugins/plugin_utils.h" | 5 #include "chrome/browser/plugins/plugin_utils.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "components/content_settings/core/browser/host_content_settings_map.h" | 9 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 10 #include "content/public/common/webplugininfo.h" | 10 #include "content/public/common/webplugininfo.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 content_settings::SettingInfo specific_info; | 65 content_settings::SettingInfo specific_info; |
| 66 std::unique_ptr<base::Value> specific_setting = | 66 std::unique_ptr<base::Value> specific_setting = |
| 67 host_content_settings_map->GetWebsiteSetting( | 67 host_content_settings_map->GetWebsiteSetting( |
| 68 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, resource, | 68 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, resource, |
| 69 &specific_info); | 69 &specific_info); |
| 70 content_settings::SettingInfo general_info; | 70 content_settings::SettingInfo general_info; |
| 71 std::unique_ptr<base::Value> general_setting = | 71 std::unique_ptr<base::Value> general_setting = |
| 72 host_content_settings_map->GetWebsiteSetting( | 72 host_content_settings_map->GetWebsiteSetting( |
| 73 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, | 73 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, |
| 74 std::string(), &general_info); | 74 std::string(), &general_info); |
| 75 // If there is a plugin-specific setting, we use it, unless the general | 75 // The order of precedence is: |
| 76 // setting was set by policy, in which case it takes precedence. | 76 // -If a general setting was set by policy, use it. |
| 77 // -If there is a plugin-specific setting which is not user provided (e.g. |
| 78 // it comes from an extension or some other source), use it. We don't use |
| 79 // user-provided plugin-specific settings because there is no longer any UI |
| 80 // to set them. |
| 81 // -Otherwise use the general setting. |
| 77 uses_plugin_specific_setting = | 82 uses_plugin_specific_setting = |
| 78 specific_setting && | 83 specific_setting && |
| 84 specific_info.source != content_settings::SETTING_SOURCE_USER && |
| 79 general_info.source != content_settings::SETTING_SOURCE_POLICY; | 85 general_info.source != content_settings::SETTING_SOURCE_POLICY; |
| 80 if (uses_plugin_specific_setting) { | 86 if (uses_plugin_specific_setting) { |
| 81 value = std::move(specific_setting); | 87 value = std::move(specific_setting); |
| 82 info = specific_info; | 88 info = specific_info; |
| 83 } else { | 89 } else { |
| 84 value = std::move(general_setting); | 90 value = std::move(general_setting); |
| 85 info = general_info; | 91 info = general_info; |
| 86 } | 92 } |
| 87 } | 93 } |
| 88 *setting = content_settings::ValueToContentSetting(value.get()); | 94 *setting = content_settings::ValueToContentSetting(value.get()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 118 ContentSetting PluginUtils::GetFlashPluginContentSetting( | 124 ContentSetting PluginUtils::GetFlashPluginContentSetting( |
| 119 const HostContentSettingsMap* host_content_settings_map, | 125 const HostContentSettingsMap* host_content_settings_map, |
| 120 const GURL& policy_url, | 126 const GURL& policy_url, |
| 121 const GURL& plugin_url) { | 127 const GURL& plugin_url) { |
| 122 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; | 128 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; |
| 123 GetPluginContentSettingInternal( | 129 GetPluginContentSettingInternal( |
| 124 host_content_settings_map, false /* use_javascript_setting */, policy_url, | 130 host_content_settings_map, false /* use_javascript_setting */, policy_url, |
| 125 plugin_url, kFlashPluginID, &plugin_setting, nullptr, nullptr); | 131 plugin_url, kFlashPluginID, &plugin_setting, nullptr, nullptr); |
| 126 return plugin_setting; | 132 return plugin_setting; |
| 127 } | 133 } |
| OLD | NEW |