| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/plugins_ui.h" | 5 #include "chrome/browser/ui/webui/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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 using content::PluginService; | 61 using content::PluginService; |
| 62 using content::WebContents; | 62 using content::WebContents; |
| 63 using content::WebUIMessageHandler; | 63 using content::WebUIMessageHandler; |
| 64 using webkit::npapi::PluginGroup; | 64 using webkit::npapi::PluginGroup; |
| 65 using webkit::WebPluginInfo; | 65 using webkit::WebPluginInfo; |
| 66 | 66 |
| 67 namespace { | 67 namespace { |
| 68 | 68 |
| 69 // Helper callback method to process result of CanEnablePlugin method. |
| 70 void EnablePluginOrDieCallback(bool enable, |
| 71 const FilePath& file_path, |
| 72 scoped_refptr<PluginPrefs> plugin_prefs, |
| 73 bool can_enable) { |
| 74 DCHECK(can_enable); |
| 75 plugin_prefs->EnablePlugin(enable, file_path, base::Bind(&base::DoNothing)); |
| 76 } |
| 77 |
| 69 ChromeWebUIDataSource* CreatePluginsUIHTMLSource() { | 78 ChromeWebUIDataSource* CreatePluginsUIHTMLSource() { |
| 70 ChromeWebUIDataSource* source = | 79 ChromeWebUIDataSource* source = |
| 71 new ChromeWebUIDataSource(chrome::kChromeUIPluginsHost); | 80 new ChromeWebUIDataSource(chrome::kChromeUIPluginsHost); |
| 72 source->set_use_json_js_format_v2(); | 81 source->set_use_json_js_format_v2(); |
| 73 | 82 |
| 74 source->AddLocalizedString("pluginsTitle", IDS_PLUGINS_TITLE); | 83 source->AddLocalizedString("pluginsTitle", IDS_PLUGINS_TITLE); |
| 75 source->AddLocalizedString("pluginsDetailsModeLink", | 84 source->AddLocalizedString("pluginsDetailsModeLink", |
| 76 IDS_PLUGINS_DETAILS_MODE_LINK); | 85 IDS_PLUGINS_DETAILS_MODE_LINK); |
| 77 source->AddLocalizedString("pluginsNoneInstalled", | 86 source->AddLocalizedString("pluginsNoneInstalled", |
| 78 IDS_PLUGINS_NONE_INSTALLED); | 87 IDS_PLUGINS_NONE_INSTALLED); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 242 } |
| 234 | 243 |
| 235 std::string enable_str; | 244 std::string enable_str; |
| 236 std::string is_group_str; | 245 std::string is_group_str; |
| 237 if (!args->GetString(1, &enable_str) || !args->GetString(2, &is_group_str)) { | 246 if (!args->GetString(1, &enable_str) || !args->GetString(2, &is_group_str)) { |
| 238 NOTREACHED(); | 247 NOTREACHED(); |
| 239 return; | 248 return; |
| 240 } | 249 } |
| 241 bool enable = enable_str == "true"; | 250 bool enable = enable_str == "true"; |
| 242 | 251 |
| 243 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); | 252 scoped_refptr<PluginPrefs> plugin_prefs(PluginPrefs::GetForProfile(profile)); |
| 244 if (is_group_str == "true") { | 253 if (is_group_str == "true") { |
| 245 string16 group_name; | 254 string16 group_name; |
| 246 if (!args->GetString(0, &group_name)) { | 255 if (!args->GetString(0, &group_name)) { |
| 247 NOTREACHED(); | 256 NOTREACHED(); |
| 248 return; | 257 return; |
| 249 } | 258 } |
| 250 | 259 |
| 251 plugin_prefs->EnablePluginGroup(enable, group_name); | 260 plugin_prefs->EnablePluginGroup(enable, group_name); |
| 252 if (enable) { | 261 if (enable) { |
| 253 // See http://crbug.com/50105 for background. | 262 // See http://crbug.com/50105 for background. |
| 254 string16 adobereader = ASCIIToUTF16( | 263 string16 adobereader = ASCIIToUTF16( |
| 255 PluginGroup::kAdobeReaderGroupName); | 264 PluginGroup::kAdobeReaderGroupName); |
| 256 string16 internalpdf = | 265 string16 internalpdf = |
| 257 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName); | 266 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName); |
| 258 if (group_name == adobereader) | 267 if (group_name == adobereader) |
| 259 plugin_prefs->EnablePluginGroup(false, internalpdf); | 268 plugin_prefs->EnablePluginGroup(false, internalpdf); |
| 260 else if (group_name == internalpdf) | 269 else if (group_name == internalpdf) |
| 261 plugin_prefs->EnablePluginGroup(false, adobereader); | 270 plugin_prefs->EnablePluginGroup(false, adobereader); |
| 262 } | 271 } |
| 263 } else { | 272 } else { |
| 264 FilePath::StringType file_path; | 273 FilePath::StringType file_path; |
| 265 if (!args->GetString(0, &file_path)) { | 274 if (!args->GetString(0, &file_path)) { |
| 266 NOTREACHED(); | 275 NOTREACHED(); |
| 267 return; | 276 return; |
| 268 } | 277 } |
| 269 DCHECK(plugin_prefs->CanEnablePlugin(enable, FilePath(file_path))); | 278 |
| 270 plugin_prefs->EnablePlugin(enable, FilePath(file_path), | 279 plugin_prefs->CanEnablePlugin(enable, FilePath(file_path), |
| 271 base::Bind(&base::DoNothing)); | 280 base::Bind(&EnablePluginOrDieCallback, enable, FilePath(file_path), |
| 281 plugin_prefs)); |
| 272 } | 282 } |
| 273 } | 283 } |
| 274 | 284 |
| 275 void PluginsDOMHandler::HandleSaveShowDetailsToPrefs(const ListValue* args) { | 285 void PluginsDOMHandler::HandleSaveShowDetailsToPrefs(const ListValue* args) { |
| 276 std::string details_mode; | 286 std::string details_mode; |
| 277 if (!args->GetString(0, &details_mode)) { | 287 if (!args->GetString(0, &details_mode)) { |
| 278 NOTREACHED(); | 288 NOTREACHED(); |
| 279 return; | 289 return; |
| 280 } | 290 } |
| 281 show_details_.SetValue(details_mode == "true"); | 291 show_details_.SetValue(details_mode == "true"); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { | 501 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { |
| 492 prefs->RegisterBooleanPref(prefs::kPluginsShowDetails, | 502 prefs->RegisterBooleanPref(prefs::kPluginsShowDetails, |
| 493 false, | 503 false, |
| 494 PrefService::UNSYNCABLE_PREF); | 504 PrefService::UNSYNCABLE_PREF); |
| 495 prefs->RegisterBooleanPref(prefs::kPluginsShowSetReaderDefaultInfobar, | 505 prefs->RegisterBooleanPref(prefs::kPluginsShowSetReaderDefaultInfobar, |
| 496 true, | 506 true, |
| 497 PrefService::UNSYNCABLE_PREF); | 507 PrefService::UNSYNCABLE_PREF); |
| 498 prefs->RegisterDictionaryPref(prefs::kContentSettingsPluginWhitelist, | 508 prefs->RegisterDictionaryPref(prefs::kContentSettingsPluginWhitelist, |
| 499 PrefService::SYNCABLE_PREF); | 509 PrefService::SYNCABLE_PREF); |
| 500 } | 510 } |
| OLD | NEW |