Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: chrome/browser/plugins/plugin_utils.cc

Issue 2408613002: Replace kPreferHtmlOverPlugins feature checks with PluginUtils::ShouldPreferHtmlOverPlugi… (Closed)
Patch Set: Replace remaining kPreferHtmlOverPlugins feature checks with PluginUtils::ShouldPreferHtmlOverPlugi… Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/plugins/plugin_utils.h ('k') | chrome/browser/plugins/plugins_field_trial.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser/ui/webui/site_settings_helper.h"
8 #include "chrome/common/chrome_features.h" 9 #include "chrome/common/chrome_features.h"
9 #include "chrome/common/plugin_utils.h" 10 #include "chrome/common/plugin_utils.h"
10 #include "components/content_settings/core/browser/host_content_settings_map.h" 11 #include "components/content_settings/core/browser/host_content_settings_map.h"
12 #include "components/content_settings/core/common/content_settings_types.h"
11 #include "content/public/common/webplugininfo.h" 13 #include "content/public/common/webplugininfo.h"
12 #include "url/gurl.h" 14 #include "url/gurl.h"
13 #include "url/origin.h" 15 #include "url/origin.h"
14 16
15 namespace { 17 namespace {
16 18
17 const char kFlashPluginID[] = "adobe-flash-player"; 19 const char kFlashPluginID[] = "adobe-flash-player";
18 20
19 void GetPluginContentSettingInternal( 21 void GetPluginContentSettingInternal(
20 const HostContentSettingsMap* host_content_settings_map, 22 const HostContentSettingsMap* host_content_settings_map,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 !uses_plugin_specific_setting && 65 !uses_plugin_specific_setting &&
64 info.primary_pattern == ContentSettingsPattern::Wildcard() && 66 info.primary_pattern == ContentSettingsPattern::Wildcard() &&
65 info.secondary_pattern == ContentSettingsPattern::Wildcard(); 67 info.secondary_pattern == ContentSettingsPattern::Wildcard();
66 } 68 }
67 if (is_managed) 69 if (is_managed)
68 *is_managed = info.source == content_settings::SETTING_SOURCE_POLICY; 70 *is_managed = info.source == content_settings::SETTING_SOURCE_POLICY;
69 71
70 // For non-JavaScript treated plugins (Flash): unless the user has explicitly 72 // For non-JavaScript treated plugins (Flash): unless the user has explicitly
71 // ALLOWed plugins, return BLOCK for any non-HTTP and non-FILE origin. 73 // ALLOWed plugins, return BLOCK for any non-HTTP and non-FILE origin.
72 if (!use_javascript_setting && *setting != CONTENT_SETTING_ALLOW && 74 if (!use_javascript_setting && *setting != CONTENT_SETTING_ALLOW &&
73 base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins) && 75 PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map) &&
74 !main_frame_url.SchemeIsHTTPOrHTTPS() && !main_frame_url.SchemeIsFile()) { 76 !main_frame_url.SchemeIsHTTPOrHTTPS() && !main_frame_url.SchemeIsFile()) {
75 *setting = CONTENT_SETTING_BLOCK; 77 *setting = CONTENT_SETTING_BLOCK;
76 } 78 }
77 } 79 }
78 80
79 } // namespace 81 } // namespace
80 82
81 // static 83 // static
82 void PluginUtils::GetPluginContentSetting( 84 void PluginUtils::GetPluginContentSetting(
83 const HostContentSettingsMap* host_content_settings_map, 85 const HostContentSettingsMap* host_content_settings_map,
(...skipping 16 matching lines...) Expand all
100 const url::Origin& main_frame_origin, 102 const url::Origin& main_frame_origin,
101 const GURL& plugin_url, 103 const GURL& plugin_url,
102 bool* is_managed) { 104 bool* is_managed) {
103 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; 105 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
104 GetPluginContentSettingInternal(host_content_settings_map, 106 GetPluginContentSettingInternal(host_content_settings_map,
105 false /* use_javascript_setting */, 107 false /* use_javascript_setting */,
106 main_frame_origin, plugin_url, kFlashPluginID, 108 main_frame_origin, plugin_url, kFlashPluginID,
107 &plugin_setting, nullptr, is_managed); 109 &plugin_setting, nullptr, is_managed);
108 return plugin_setting; 110 return plugin_setting;
109 } 111 }
112
113 // static
114 bool PluginUtils::ShouldPreferHtmlOverPlugins(
115 const HostContentSettingsMap* host_content_settings_map) {
116 std::string provider_id;
117 ContentSetting default_setting =
118 host_content_settings_map->GetDefaultContentSetting(
119 CONTENT_SETTINGS_TYPE_PLUGINS, &provider_id);
120 ALLOW_UNUSED_LOCAL(default_setting);
121
122 // Working around a policy issue - do not allow PreferHtml if there is any
123 // policy for the plugin default setting. crbug.com/654072.
124 if (provider_id == site_settings::kPolicyProviderId)
125 return false;
126
127 // Fine. No policy interferes.
128 return base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins);
129 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_utils.h ('k') | chrome/browser/plugins/plugins_field_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698