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

Side by Side Diff: chrome/browser/plugin_updater.cc

Issue 3238015: Fix two bugs for setting the pdf plugin on by default:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/plugin_updater.h" 5 #include "chrome/browser/plugin_updater.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 85
86 void EnablePluginFile(bool enable, const FilePath::StringType& path) { 86 void EnablePluginFile(bool enable, const FilePath::StringType& path) {
87 FilePath file_path(path); 87 FilePath file_path(path);
88 if (enable && !PluginGroup::IsPluginPathDisabledByPolicy(file_path)) 88 if (enable && !PluginGroup::IsPluginPathDisabledByPolicy(file_path))
89 NPAPI::PluginList::Singleton()->EnablePlugin(file_path); 89 NPAPI::PluginList::Singleton()->EnablePlugin(file_path);
90 else 90 else
91 NPAPI::PluginList::Singleton()->DisablePlugin(file_path); 91 NPAPI::PluginList::Singleton()->DisablePlugin(file_path);
92 } 92 }
93 93
94 // Note: if you change this to false from true, you must update
95 // kPluginsEnabledInternalPDF to be a new name (i.e. add 2, 3, 4...) at end.
94 static bool enable_internal_pdf_ = true; 96 static bool enable_internal_pdf_ = true;
95 97
96 void DisablePluginGroupsFromPrefs(Profile* profile) { 98 void DisablePluginGroupsFromPrefs(Profile* profile) {
97 bool update_internal_dir = false; 99 bool update_internal_dir = false;
100 bool update_preferences = false;
98 FilePath last_internal_dir = 101 FilePath last_internal_dir =
99 profile->GetPrefs()->GetFilePath(prefs::kPluginsLastInternalDirectory); 102 profile->GetPrefs()->GetFilePath(prefs::kPluginsLastInternalDirectory);
100 FilePath cur_internal_dir; 103 FilePath cur_internal_dir;
101 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &cur_internal_dir) && 104 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &cur_internal_dir) &&
102 cur_internal_dir != last_internal_dir) { 105 cur_internal_dir != last_internal_dir) {
103 update_internal_dir = true; 106 update_internal_dir = true;
104 profile->GetPrefs()->SetFilePath( 107 profile->GetPrefs()->SetFilePath(
105 prefs::kPluginsLastInternalDirectory, cur_internal_dir); 108 prefs::kPluginsLastInternalDirectory, cur_internal_dir);
106 } 109 }
107 110
111 if (!enable_internal_pdf_) {
112 // This DCHECK guards against us disabling/enabling the pdf plugin more than
113 // once without renaming the flag that tells us whether we can enable it
114 // automatically. Each time we disable the plugin by default after it was
115 // enabled by default, we need to rename that flag.
116 DCHECK(!profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF));
117 }
118
108 bool found_internal_pdf = false; 119 bool found_internal_pdf = false;
109 bool force_enable_internal_pdf = false; 120 bool force_enable_internal_pdf = false;
121 string16 pdf_group_name;
110 FilePath pdf_path; 122 FilePath pdf_path;
111 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); 123 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path);
112 FilePath::StringType pdf_path_str = pdf_path.value(); 124 FilePath::StringType pdf_path_str = pdf_path.value();
113 if (enable_internal_pdf_ && 125 if (enable_internal_pdf_ &&
114 !profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF)) { 126 !profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF)) {
115 // We switched to the internal pdf plugin being on by default, and so we 127 // We switched to the internal pdf plugin being on by default, and so we
116 // need to force it to be enabled. We only want to do it this once though, 128 // need to force it to be enabled. We only want to do it this once though,
117 // i.e. we don't want to enable it again if the user disables it afterwards. 129 // i.e. we don't want to enable it again if the user disables it afterwards.
118 profile->GetPrefs()->SetBoolean(prefs::kPluginsEnabledInternalPDF, true); 130 profile->GetPrefs()->SetBoolean(prefs::kPluginsEnabledInternalPDF, true);
119 force_enable_internal_pdf = true; 131 force_enable_internal_pdf = true;
(...skipping 25 matching lines...) Expand all
145 last_internal_dir.value()) == 0) { 157 last_internal_dir.value()) == 0) {
146 // If the internal plugin directory has changed and if the plugin 158 // If the internal plugin directory has changed and if the plugin
147 // looks internal, update its path in the prefs. 159 // looks internal, update its path in the prefs.
148 plugin_path = cur_internal_dir.Append(plugin_path.BaseName()); 160 plugin_path = cur_internal_dir.Append(plugin_path.BaseName());
149 path = plugin_path.value(); 161 path = plugin_path.value();
150 plugin->SetString("path", path); 162 plugin->SetString("path", path);
151 } 163 }
152 164
153 if (FilePath::CompareIgnoreCase(path, pdf_path_str) == 0) { 165 if (FilePath::CompareIgnoreCase(path, pdf_path_str) == 0) {
154 found_internal_pdf = true; 166 found_internal_pdf = true;
167 plugin->GetString("name", &pdf_group_name);
155 if (!enabled && force_enable_internal_pdf) { 168 if (!enabled && force_enable_internal_pdf) {
156 enabled = true; 169 enabled = true;
157 plugin->SetBoolean("enabled", true); 170 plugin->SetBoolean("enabled", true);
171 update_preferences = true; // Can't modify the list during looping.
158 } 172 }
159 } 173 }
160 if (!enabled) 174 if (!enabled)
161 NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path); 175 NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path);
162 } else if (!enabled && plugin->GetString("name", &group_name)) { 176 } else if (!enabled && plugin->GetString("name", &group_name)) {
177 // Don't disable this group if it's for the pdf plugin and we just
178 // forced it on.
179 if (force_enable_internal_pdf && pdf_group_name == group_name)
180 continue;
181
163 // Otherwise this is a list of groups. 182 // Otherwise this is a list of groups.
164 EnablePluginGroup(false, group_name); 183 EnablePluginGroup(false, group_name);
165 } 184 }
166 } 185 }
167 } 186 }
168 187
169 // Build the set of policy-disabled plugins once and cache it. 188 // Build the set of policy-disabled plugins once and cache it.
170 // Don't do this in the constructor, there's no profile available there. 189 // Don't do this in the constructor, there's no profile available there.
171 std::set<string16> policy_disabled_plugins; 190 std::set<string16> policy_disabled_plugins;
172 const ListValue* plugin_blacklist = 191 const ListValue* plugin_blacklist =
(...skipping 27 matching lines...) Expand all
200 string16 current_group_name = (*it)->GetGroupName(); 219 string16 current_group_name = (*it)->GetGroupName();
201 if (PluginGroup::IsPluginNameDisabledByPolicy(current_group_name)) 220 if (PluginGroup::IsPluginNameDisabledByPolicy(current_group_name))
202 EnablePluginGroup(false, current_group_name); 221 EnablePluginGroup(false, current_group_name);
203 } 222 }
204 223
205 if (!enable_internal_pdf_ && !found_internal_pdf) { 224 if (!enable_internal_pdf_ && !found_internal_pdf) {
206 // The internal PDF plugin is disabled by default, and the user hasn't 225 // The internal PDF plugin is disabled by default, and the user hasn't
207 // overridden the default. 226 // overridden the default.
208 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path); 227 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path);
209 } 228 }
229
230 if (update_preferences)
231 UpdatePreferences(profile);
210 } 232 }
211 233
212 void DisableOutdatedPluginGroups() { 234 void DisableOutdatedPluginGroups() {
213 std::vector<linked_ptr<PluginGroup> > groups; 235 std::vector<linked_ptr<PluginGroup> > groups;
214 GetPluginGroups(&groups); 236 GetPluginGroups(&groups);
215 for (std::vector<linked_ptr<PluginGroup> >::iterator it = 237 for (std::vector<linked_ptr<PluginGroup> >::iterator it =
216 groups.begin(); 238 groups.begin();
217 it != groups.end(); 239 it != groups.end();
218 ++it) { 240 ++it) {
219 (*it)->DisableOutdatedPlugins(); 241 (*it)->DisableOutdatedPlugins();
(...skipping 29 matching lines...) Expand all
249 // Don't save preferences for vulnerable pugins. 271 // Don't save preferences for vulnerable pugins.
250 if (!CommandLine::ForCurrentProcess()->HasSwitch( 272 if (!CommandLine::ForCurrentProcess()->HasSwitch(
251 switches::kDisableOutdatedPlugins) || 273 switches::kDisableOutdatedPlugins) ||
252 !(*it)->IsVulnerable()) { 274 !(*it)->IsVulnerable()) {
253 plugins_list->Append((*it)->GetSummary()); 275 plugins_list->Append((*it)->GetSummary());
254 } 276 }
255 } 277 }
256 } 278 }
257 279
258 } // namespace plugin_updater 280 } // namespace plugin_updater
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698