OLD | NEW |
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // This DCHECK guards against us disabling/enabling the pdf plugin more than | 125 // This DCHECK guards against us disabling/enabling the pdf plugin more than |
126 // once without renaming the flag that tells us whether we can enable it | 126 // once without renaming the flag that tells us whether we can enable it |
127 // automatically. Each time we disable the plugin by default after it was | 127 // automatically. Each time we disable the plugin by default after it was |
128 // enabled by default, we need to rename that flag. | 128 // enabled by default, we need to rename that flag. |
129 DCHECK(!profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF)); | 129 DCHECK(!profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF)); |
130 } | 130 } |
131 | 131 |
132 bool found_internal_pdf = false; | 132 bool found_internal_pdf = false; |
133 bool force_enable_internal_pdf = false; | 133 bool force_enable_internal_pdf = false; |
134 string16 pdf_group_name = ASCIIToUTF16(PepperPluginRegistry::kPDFPluginName); | 134 string16 pdf_group_name = ASCIIToUTF16(PepperPluginRegistry::kPDFPluginName); |
| 135 bool force_internal_pdf_for_this_run = CommandLine::ForCurrentProcess()-> |
| 136 HasSwitch(switches::kForceInternalPDFPlugin); |
135 FilePath pdf_path; | 137 FilePath pdf_path; |
136 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); | 138 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); |
137 FilePath::StringType pdf_path_str = pdf_path.value(); | 139 FilePath::StringType pdf_path_str = pdf_path.value(); |
138 if (enable_internal_pdf_ && | 140 if (enable_internal_pdf_ && |
139 !profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF)) { | 141 !profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF)) { |
140 // We switched to the internal pdf plugin being on by default, and so we | 142 // We switched to the internal pdf plugin being on by default, and so we |
141 // need to force it to be enabled. We only want to do it this once though, | 143 // need to force it to be enabled. We only want to do it this once though, |
142 // i.e. we don't want to enable it again if the user disables it afterwards. | 144 // i.e. we don't want to enable it again if the user disables it afterwards. |
143 profile->GetPrefs()->SetBoolean(prefs::kPluginsEnabledInternalPDF, true); | 145 profile->GetPrefs()->SetBoolean(prefs::kPluginsEnabledInternalPDF, true); |
144 force_enable_internal_pdf = true; | 146 force_enable_internal_pdf = true; |
(...skipping 25 matching lines...) Expand all Loading... |
170 last_internal_dir.value()) == 0) { | 172 last_internal_dir.value()) == 0) { |
171 // If the internal plugin directory has changed and if the plugin | 173 // If the internal plugin directory has changed and if the plugin |
172 // looks internal, update its path in the prefs. | 174 // looks internal, update its path in the prefs. |
173 plugin_path = cur_internal_dir.Append(plugin_path.BaseName()); | 175 plugin_path = cur_internal_dir.Append(plugin_path.BaseName()); |
174 path = plugin_path.value(); | 176 path = plugin_path.value(); |
175 plugin->SetString("path", path); | 177 plugin->SetString("path", path); |
176 } | 178 } |
177 | 179 |
178 if (FilePath::CompareIgnoreCase(path, pdf_path_str) == 0) { | 180 if (FilePath::CompareIgnoreCase(path, pdf_path_str) == 0) { |
179 found_internal_pdf = true; | 181 found_internal_pdf = true; |
180 if (!enabled && force_enable_internal_pdf) { | 182 if (!enabled) { |
181 enabled = true; | 183 if (force_enable_internal_pdf) { |
182 plugin->SetBoolean("enabled", true); | 184 enabled = true; |
| 185 plugin->SetBoolean("enabled", true); |
| 186 } else if (force_internal_pdf_for_this_run) { |
| 187 enabled = true; |
| 188 } |
183 } | 189 } |
184 } | 190 } |
185 if (!enabled) | 191 if (!enabled) |
186 NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path); | 192 NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path); |
187 } else if (!enabled && plugin->GetString("name", &group_name)) { | 193 } else if (!enabled && plugin->GetString("name", &group_name)) { |
188 // Don't disable this group if it's for the pdf plugin and we just | 194 // Don't disable this group if it's for the pdf plugin and we just |
189 // forced it on. | 195 // forced it on. |
190 if (force_enable_internal_pdf && pdf_group_name == group_name) | 196 if (force_enable_internal_pdf && pdf_group_name == group_name) |
191 continue; | 197 continue; |
192 | 198 |
193 // Otherwise this is a list of groups. | 199 // Otherwise this is a list of groups. |
194 EnablePluginGroup(false, group_name); | 200 EnablePluginGroup(false, group_name); |
195 } | 201 } |
196 } | 202 } |
197 } | 203 } |
198 | 204 |
199 // Build the set of policy-disabled plugin patterns once and cache it. | 205 // Build the set of policy-disabled plugin patterns once and cache it. |
200 // Don't do this in the constructor, there's no profile available there. | 206 // Don't do this in the constructor, there's no profile available there. |
201 const ListValue* plugin_blacklist = | 207 const ListValue* plugin_blacklist = |
202 profile->GetPrefs()->GetList(prefs::kPluginsPluginsBlacklist); | 208 profile->GetPrefs()->GetList(prefs::kPluginsPluginsBlacklist); |
203 DisablePluginsFromPolicy(plugin_blacklist); | 209 DisablePluginsFromPolicy(plugin_blacklist); |
204 | 210 |
205 if (!enable_internal_pdf_ && !found_internal_pdf) { | 211 if ((!enable_internal_pdf_ && !found_internal_pdf) && |
| 212 !force_internal_pdf_for_this_run) { |
206 // The internal PDF plugin is disabled by default, and the user hasn't | 213 // The internal PDF plugin is disabled by default, and the user hasn't |
207 // overridden the default. | 214 // overridden the default. |
208 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path); | 215 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path); |
209 EnablePluginGroup(false, pdf_group_name); | 216 EnablePluginGroup(false, pdf_group_name); |
210 } | 217 } |
211 | 218 |
212 if (force_enable_internal_pdf) { | 219 if (force_enable_internal_pdf) { |
213 // See http://crbug.com/50105 for background. | 220 // See http://crbug.com/50105 for background. |
214 EnablePluginGroup(false, ASCIIToUTF16(PluginGroup::kAdobeReader8GroupName)); | 221 EnablePluginGroup(false, ASCIIToUTF16(PluginGroup::kAdobeReader8GroupName)); |
215 EnablePluginGroup(false, ASCIIToUTF16(PluginGroup::kAdobeReader9GroupName)); | 222 EnablePluginGroup(false, ASCIIToUTF16(PluginGroup::kAdobeReader9GroupName)); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 NotificationService::current()->Notify( | 293 NotificationService::current()->Notify( |
287 NotificationType::PLUGIN_ENABLE_STATUS_CHANGED, | 294 NotificationType::PLUGIN_ENABLE_STATUS_CHANGED, |
288 Source<PluginUpdater>(GetPluginUpdater()), | 295 Source<PluginUpdater>(GetPluginUpdater()), |
289 NotificationService::NoDetails()); | 296 NotificationService::NoDetails()); |
290 } | 297 } |
291 | 298 |
292 /*static*/ | 299 /*static*/ |
293 PluginUpdater* PluginUpdater::GetPluginUpdater() { | 300 PluginUpdater* PluginUpdater::GetPluginUpdater() { |
294 return Singleton<PluginUpdater>::get(); | 301 return Singleton<PluginUpdater>::get(); |
295 } | 302 } |
OLD | NEW |