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/dom_ui/plugins_ui.h" | 5 #include "chrome/browser/dom_ui/plugins_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 NewCallback(this, &PluginsDOMHandler::HandleShowTermsOfServiceMessage)); | 198 NewCallback(this, &PluginsDOMHandler::HandleShowTermsOfServiceMessage)); |
199 } | 199 } |
200 | 200 |
201 void PluginsDOMHandler::HandleRequestPluginsData(const ListValue* args) { | 201 void PluginsDOMHandler::HandleRequestPluginsData(const ListValue* args) { |
202 LoadPlugins(); | 202 LoadPlugins(); |
203 } | 203 } |
204 | 204 |
205 void PluginsDOMHandler::HandleEnablePluginMessage(const ListValue* args) { | 205 void PluginsDOMHandler::HandleEnablePluginMessage(const ListValue* args) { |
206 // Be robust in accepting badness since plug-ins display HTML (hence | 206 // Be robust in accepting badness since plug-ins display HTML (hence |
207 // JavaScript). | 207 // JavaScript). |
208 if (args->GetSize() != 3) | 208 if (args->GetSize() != 4) |
209 return; | 209 return; |
210 | 210 |
211 std::string enable_str; | 211 std::string enable_str; |
212 std::string is_group_str; | 212 std::string is_group_str; |
213 if (!args->GetString(1, &enable_str) || !args->GetString(2, &is_group_str)) | 213 if (!args->GetString(2, &enable_str) || !args->GetString(3, &is_group_str)) |
214 return; | 214 return; |
215 bool enable = enable_str == "true"; | 215 bool enable = enable_str == "true"; |
216 | 216 |
217 PluginUpdater* plugin_updater = PluginUpdater::GetInstance(); | 217 PluginUpdater* plugin_updater = PluginUpdater::GetInstance(); |
218 if (is_group_str == "true") { | 218 if (is_group_str == "true") { |
219 string16 group_name; | 219 string16 group_name; |
220 if (!args->GetString(0, &group_name)) | 220 if (!args->GetString(0, &group_name)) |
221 return; | 221 return; |
222 | 222 |
223 plugin_updater->EnablePluginGroup(enable, group_name); | 223 plugin_updater->EnablePluginGroup(enable, group_name); |
224 if (enable) { | 224 if (enable) { |
225 // See http://crbug.com/50105 for background. | 225 // See http://crbug.com/50105 for background. |
226 string16 adobereader = ASCIIToUTF16( | 226 string16 adobereader = ASCIIToUTF16( |
227 webkit::npapi::PluginGroup::kAdobeReaderGroupName); | 227 webkit::npapi::PluginGroup::kAdobeReaderGroupName); |
228 string16 internalpdf = ASCIIToUTF16(PepperPluginRegistry::kPDFPluginName); | 228 string16 internalpdf = ASCIIToUTF16(PepperPluginRegistry::kPDFPluginName); |
229 if (group_name == adobereader) { | 229 if (group_name == adobereader) { |
230 plugin_updater->EnablePluginGroup(false, internalpdf); | 230 plugin_updater->EnablePluginGroup(false, internalpdf); |
231 } else if (group_name == internalpdf) { | 231 } else if (group_name == internalpdf) { |
232 plugin_updater->EnablePluginGroup(false, adobereader); | 232 plugin_updater->EnablePluginGroup(false, adobereader); |
233 } | 233 } |
234 } | 234 } |
235 } else { | 235 } else { |
| 236 string16 name; |
236 FilePath::StringType file_path; | 237 FilePath::StringType file_path; |
237 if (!args->GetString(0, &file_path)) | 238 if (!args->GetString(0, &file_path) || !args->GetString(1, &name)) |
238 return; | 239 return; |
239 | 240 |
240 plugin_updater->EnablePluginFile(enable, file_path); | 241 plugin_updater->EnablePlugin(enable, file_path, name); |
241 } | 242 } |
242 | 243 |
243 // TODO(viettrungluu): We might also want to ensure that the plugins | 244 // TODO(viettrungluu): We might also want to ensure that the plugins |
244 // list is always written to prefs even when the user hasn't disabled a | 245 // list is always written to prefs even when the user hasn't disabled a |
245 // plugin. <http://crbug.com/39101> | 246 // plugin. <http://crbug.com/39101> |
246 plugin_updater->UpdatePreferences(dom_ui_->GetProfile(), 0); | 247 plugin_updater->UpdatePreferences(dom_ui_->GetProfile(), 0); |
247 } | 248 } |
248 | 249 |
249 void PluginsDOMHandler::HandleShowTermsOfServiceMessage(const ListValue* args) { | 250 void PluginsDOMHandler::HandleShowTermsOfServiceMessage(const ListValue* args) { |
250 // Show it in a new browser window.... | 251 // Show it in a new browser window.... |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { | 332 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { |
332 FilePath internal_dir; | 333 FilePath internal_dir; |
333 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); | 334 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); |
334 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, | 335 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, |
335 internal_dir); | 336 internal_dir); |
336 | 337 |
337 prefs->RegisterListPref(prefs::kPluginsPluginsBlacklist); | 338 prefs->RegisterListPref(prefs::kPluginsPluginsBlacklist); |
338 prefs->RegisterListPref(prefs::kPluginsPluginsList); | 339 prefs->RegisterListPref(prefs::kPluginsPluginsList); |
339 prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, false); | 340 prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, false); |
340 } | 341 } |
OLD | NEW |