Chromium Code Reviews| 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/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/common/chrome_features.h" | |
| 8 #include "chrome/common/plugin_utils.h" | 9 #include "chrome/common/plugin_utils.h" |
| 9 #include "components/content_settings/core/browser/host_content_settings_map.h" | 10 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 10 #include "content/public/common/webplugininfo.h" | 11 #include "content/public/common/webplugininfo.h" |
| 11 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 #include "url/origin.h" | |
| 12 | 14 |
| 13 namespace { | 15 namespace { |
| 14 | 16 |
| 15 const char kFlashPluginID[] = "adobe-flash-player"; | 17 const char kFlashPluginID[] = "adobe-flash-player"; |
| 16 | 18 |
| 17 void GetPluginContentSettingInternal( | 19 void GetPluginContentSettingInternal( |
| 18 const HostContentSettingsMap* host_content_settings_map, | 20 const HostContentSettingsMap* host_content_settings_map, |
| 19 bool use_javascript_setting, | 21 bool use_javascript_setting, |
| 20 const GURL& policy_url, | 22 const url::Origin& policy_origin, |
| 21 const GURL& plugin_url, | 23 const GURL& plugin_url, |
| 22 const std::string& resource, | 24 const std::string& resource, |
| 23 ContentSetting* setting, | 25 ContentSetting* setting, |
| 24 bool* uses_default_content_setting, | 26 bool* uses_default_content_setting, |
| 25 bool* is_managed) { | 27 bool* is_managed) { |
| 28 GURL policy_url = | |
| 29 policy_origin.unique() ? GURL() : GURL(policy_origin.Serialize()); | |
| 30 | |
| 26 std::unique_ptr<base::Value> value; | 31 std::unique_ptr<base::Value> value; |
| 27 content_settings::SettingInfo info; | 32 content_settings::SettingInfo info; |
| 28 bool uses_plugin_specific_setting = false; | 33 bool uses_plugin_specific_setting = false; |
| 29 if (use_javascript_setting) { | 34 if (use_javascript_setting) { |
| 30 value = host_content_settings_map->GetWebsiteSetting( | 35 value = host_content_settings_map->GetWebsiteSetting( |
| 31 policy_url, policy_url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string(), | 36 policy_url, policy_url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string(), |
| 32 &info); | 37 &info); |
| 33 } else { | 38 } else { |
| 39 // For non-JavaScript treated plugins (Flash), always return BLOCK if the | |
| 40 // top level origin is any scheme other HTTP, HTTPS, or FILE. | |
| 41 if (base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins) && | |
| 42 !policy_url.SchemeIsHTTPOrHTTPS() && !policy_url.SchemeIsFile()) { | |
|
jochen (gone - plz use gerrit)
2016/09/30 10:50:34
aren't file urls unique as well?
tommycli
2016/09/30 17:44:43
Surprisingly... no. I tested this, And I got:
Web
tommycli
2016/09/30 17:46:21
+cc dcheng/alexmos - I thought file:// urls were u
| |
| 43 *setting = CONTENT_SETTING_BLOCK; | |
| 44 if (uses_default_content_setting) | |
| 45 *uses_default_content_setting = true; | |
| 46 if (is_managed) | |
| 47 *is_managed = true; | |
| 48 return; | |
| 49 } | |
| 50 | |
| 34 content_settings::SettingInfo specific_info; | 51 content_settings::SettingInfo specific_info; |
| 35 std::unique_ptr<base::Value> specific_setting = | 52 std::unique_ptr<base::Value> specific_setting = |
| 36 host_content_settings_map->GetWebsiteSetting( | 53 host_content_settings_map->GetWebsiteSetting( |
| 37 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, resource, | 54 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, resource, |
| 38 &specific_info); | 55 &specific_info); |
| 39 content_settings::SettingInfo general_info; | 56 content_settings::SettingInfo general_info; |
| 40 std::unique_ptr<base::Value> general_setting = | 57 std::unique_ptr<base::Value> general_setting = |
| 41 host_content_settings_map->GetWebsiteSetting( | 58 host_content_settings_map->GetWebsiteSetting( |
| 42 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, | 59 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, |
| 43 std::string(), &general_info); | 60 std::string(), &general_info); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 64 if (is_managed) | 81 if (is_managed) |
| 65 *is_managed = info.source == content_settings::SETTING_SOURCE_POLICY; | 82 *is_managed = info.source == content_settings::SETTING_SOURCE_POLICY; |
| 66 } | 83 } |
| 67 | 84 |
| 68 } // namespace | 85 } // namespace |
| 69 | 86 |
| 70 // static | 87 // static |
| 71 void PluginUtils::GetPluginContentSetting( | 88 void PluginUtils::GetPluginContentSetting( |
| 72 const HostContentSettingsMap* host_content_settings_map, | 89 const HostContentSettingsMap* host_content_settings_map, |
| 73 const content::WebPluginInfo& plugin, | 90 const content::WebPluginInfo& plugin, |
| 74 const GURL& policy_url, | 91 const url::Origin& policy_url, |
| 75 const GURL& plugin_url, | 92 const GURL& plugin_url, |
| 76 const std::string& resource, | 93 const std::string& resource, |
| 77 ContentSetting* setting, | 94 ContentSetting* setting, |
| 78 bool* uses_default_content_setting, | 95 bool* uses_default_content_setting, |
| 79 bool* is_managed) { | 96 bool* is_managed) { |
| 80 GetPluginContentSettingInternal(host_content_settings_map, | 97 GetPluginContentSettingInternal(host_content_settings_map, |
| 81 ShouldUseJavaScriptSettingForPlugin(plugin), | 98 ShouldUseJavaScriptSettingForPlugin(plugin), |
| 82 policy_url, plugin_url, resource, setting, | 99 policy_url, plugin_url, resource, setting, |
| 83 uses_default_content_setting, is_managed); | 100 uses_default_content_setting, is_managed); |
| 84 } | 101 } |
| 85 | 102 |
| 86 // static | 103 // static |
| 87 ContentSetting PluginUtils::GetFlashPluginContentSetting( | 104 ContentSetting PluginUtils::GetFlashPluginContentSetting( |
| 88 const HostContentSettingsMap* host_content_settings_map, | 105 const HostContentSettingsMap* host_content_settings_map, |
| 89 const GURL& policy_url, | 106 const url::Origin& policy_url, |
| 90 const GURL& plugin_url, | 107 const GURL& plugin_url, |
| 91 bool* is_managed) { | 108 bool* is_managed) { |
| 92 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; | 109 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; |
| 93 GetPluginContentSettingInternal( | 110 GetPluginContentSettingInternal( |
| 94 host_content_settings_map, false /* use_javascript_setting */, policy_url, | 111 host_content_settings_map, false /* use_javascript_setting */, policy_url, |
| 95 plugin_url, kFlashPluginID, &plugin_setting, nullptr, is_managed); | 112 plugin_url, kFlashPluginID, &plugin_setting, nullptr, is_managed); |
| 96 return plugin_setting; | 113 return plugin_setting; |
| 97 } | 114 } |
| OLD | NEW |