| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 32 #include "content/browser/plugin_service.h" | 32 #include "content/browser/plugin_service.h" |
| 33 #include "content/browser/tab_contents/tab_contents.h" | 33 #include "content/browser/tab_contents/tab_contents.h" |
| 34 #include "content/common/notification_service.h" | 34 #include "content/common/notification_service.h" |
| 35 #include "grit/browser_resources.h" | 35 #include "grit/browser_resources.h" |
| 36 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
| 37 #include "grit/theme_resources.h" | 37 #include "grit/theme_resources.h" |
| 38 #include "grit/theme_resources_standard.h" | 38 #include "grit/theme_resources_standard.h" |
| 39 #include "ui/base/l10n/l10n_util.h" |
| 39 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
| 40 #include "webkit/plugins/npapi/plugin_group.h" | 41 #include "webkit/plugins/npapi/plugin_group.h" |
| 41 | 42 |
| 42 using webkit::npapi::PluginGroup; | 43 using webkit::npapi::PluginGroup; |
| 43 using webkit::WebPluginInfo; | 44 using webkit::WebPluginInfo; |
| 44 | 45 |
| 45 namespace { | 46 namespace { |
| 46 | 47 |
| 47 ChromeWebUIDataSource* CreatePluginsUIHTMLSource() { | 48 ChromeWebUIDataSource* CreatePluginsUIHTMLSource() { |
| 48 ChromeWebUIDataSource* source = | 49 ChromeWebUIDataSource* source = |
| 49 new ChromeWebUIDataSource(chrome::kChromeUIPluginsHost); | 50 new ChromeWebUIDataSource(chrome::kChromeUIPluginsHost); |
| 50 | 51 |
| 51 source->AddLocalizedString("pluginsTitle", IDS_PLUGINS_TITLE); | 52 source->AddLocalizedString("pluginsTitle", IDS_PLUGINS_TITLE); |
| 52 source->AddLocalizedString("pluginsDetailsModeLink", | 53 source->AddLocalizedString("pluginsDetailsModeLink", |
| 53 IDS_PLUGINS_DETAILS_MODE_LINK); | 54 IDS_PLUGINS_DETAILS_MODE_LINK); |
| 54 source->AddLocalizedString("pluginsNoneInstalled", | 55 source->AddLocalizedString("pluginsNoneInstalled", |
| 55 IDS_PLUGINS_NONE_INSTALLED); | 56 IDS_PLUGINS_NONE_INSTALLED); |
| 56 source->AddLocalizedString("pluginDisabled", IDS_PLUGINS_DISABLED_PLUGIN); | 57 source->AddLocalizedString("pluginDisabled", IDS_PLUGINS_DISABLED_PLUGIN); |
| 57 source->AddLocalizedString("pluginDisabledByPolicy", | 58 source->AddLocalizedString("pluginDisabledByPolicy", |
| 58 IDS_PLUGINS_DISABLED_BY_POLICY_PLUGIN); | 59 IDS_PLUGINS_DISABLED_BY_POLICY_PLUGIN); |
| 59 source->AddLocalizedString("pluginEnabledByPolicy", | 60 source->AddLocalizedString("pluginEnabledByPolicy", |
| 60 IDS_PLUGINS_ENABLED_BY_POLICY_PLUGIN); | 61 IDS_PLUGINS_ENABLED_BY_POLICY_PLUGIN); |
| 61 source->AddLocalizedString("pluginDownload", IDS_PLUGINS_DOWNLOAD); | 62 source->AddLocalizedString("pluginDownload", IDS_PLUGINS_DOWNLOAD); |
| 62 source->AddLocalizedString("pluginName", IDS_PLUGINS_NAME); | 63 source->AddLocalizedString("pluginName", IDS_PLUGINS_NAME); |
| 63 source->AddLocalizedString("pluginVersion", IDS_PLUGINS_VERSION); | 64 source->AddLocalizedString("pluginVersion", IDS_PLUGINS_VERSION); |
| 64 source->AddLocalizedString("pluginDescription", IDS_PLUGINS_DESCRIPTION); | 65 source->AddLocalizedString("pluginDescription", IDS_PLUGINS_DESCRIPTION); |
| 65 source->AddLocalizedString("pluginPath", IDS_PLUGINS_PATH); | 66 source->AddLocalizedString("pluginPath", IDS_PLUGINS_PATH); |
| 67 source->AddLocalizedString("pluginType", IDS_PLUGINS_TYPE); |
| 66 source->AddLocalizedString("pluginMimeTypes", IDS_PLUGINS_MIME_TYPES); | 68 source->AddLocalizedString("pluginMimeTypes", IDS_PLUGINS_MIME_TYPES); |
| 67 source->AddLocalizedString("pluginMimeTypesMimeType", | 69 source->AddLocalizedString("pluginMimeTypesMimeType", |
| 68 IDS_PLUGINS_MIME_TYPES_MIME_TYPE); | 70 IDS_PLUGINS_MIME_TYPES_MIME_TYPE); |
| 69 source->AddLocalizedString("pluginMimeTypesDescription", | 71 source->AddLocalizedString("pluginMimeTypesDescription", |
| 70 IDS_PLUGINS_MIME_TYPES_DESCRIPTION); | 72 IDS_PLUGINS_MIME_TYPES_DESCRIPTION); |
| 71 source->AddLocalizedString("pluginMimeTypesFileExtensions", | 73 source->AddLocalizedString("pluginMimeTypesFileExtensions", |
| 72 IDS_PLUGINS_MIME_TYPES_FILE_EXTENSIONS); | 74 IDS_PLUGINS_MIME_TYPES_FILE_EXTENSIONS); |
| 73 source->AddLocalizedString("disable", IDS_PLUGINS_DISABLE); | 75 source->AddLocalizedString("disable", IDS_PLUGINS_DISABLE); |
| 74 source->AddLocalizedString("enable", IDS_PLUGINS_ENABLE); | 76 source->AddLocalizedString("enable", IDS_PLUGINS_ENABLE); |
| 75 source->AddLocalizedString("noPlugins", IDS_PLUGINS_NO_PLUGINS); | 77 source->AddLocalizedString("noPlugins", IDS_PLUGINS_NO_PLUGINS); |
| 76 | 78 |
| 77 source->set_json_path("strings.js"); | 79 source->set_json_path("strings.js"); |
| 78 source->add_resource_path("plugins.js", IDR_PLUGINS_JS); | 80 source->add_resource_path("plugins.js", IDR_PLUGINS_JS); |
| 79 source->set_default_resource(IDR_PLUGINS_HTML); | 81 source->set_default_resource(IDR_PLUGINS_HTML); |
| 80 return source; | 82 return source; |
| 81 } | 83 } |
| 82 | 84 |
| 85 string16 PluginTypeToString(int type) { |
| 86 // The type is stored as an |int|, but doing the switch on the right |
| 87 // enumeration type gives us better build-time error checking (if someone adds |
| 88 // a new type). |
| 89 switch (static_cast<WebPluginInfo::PluginType>(type)) { |
| 90 case WebPluginInfo::PLUGIN_TYPE_NPAPI: |
| 91 return l10n_util::GetStringUTF16(IDS_PLUGINS_NPAPI); |
| 92 case WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS: |
| 93 return l10n_util::GetStringUTF16(IDS_PLUGINS_PPAPI_IN_PROCESS); |
| 94 case WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS: |
| 95 return l10n_util::GetStringUTF16(IDS_PLUGINS_PPAPI_OUT_OF_PROCESS); |
| 96 } |
| 97 NOTREACHED(); |
| 98 return string16(); |
| 99 } |
| 100 |
| 83 //////////////////////////////////////////////////////////////////////////////// | 101 //////////////////////////////////////////////////////////////////////////////// |
| 84 // | 102 // |
| 85 // PluginsDOMHandler | 103 // PluginsDOMHandler |
| 86 // | 104 // |
| 87 //////////////////////////////////////////////////////////////////////////////// | 105 //////////////////////////////////////////////////////////////////////////////// |
| 88 | 106 |
| 89 // The handler for Javascript messages for the chrome://plugins/ page. | 107 // The handler for Javascript messages for the chrome://plugins/ page. |
| 90 // TODO(viettrungluu): Make plugin list updates notify, and then observe | 108 // TODO(viettrungluu): Make plugin list updates notify, and then observe |
| 91 // changes; maybe replumb plugin list through plugin service? | 109 // changes; maybe replumb plugin list through plugin service? |
| 92 // <http://crbug.com/39101> | 110 // <http://crbug.com/39101> |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 bool all_plugins_disabled_by_policy = true; | 275 bool all_plugins_disabled_by_policy = true; |
| 258 const WebPluginInfo* active_plugin = NULL; | 276 const WebPluginInfo* active_plugin = NULL; |
| 259 for (size_t j = 0; j < group.web_plugin_infos().size(); ++j) { | 277 for (size_t j = 0; j < group.web_plugin_infos().size(); ++j) { |
| 260 const WebPluginInfo& group_plugin = group.web_plugin_infos()[j]; | 278 const WebPluginInfo& group_plugin = group.web_plugin_infos()[j]; |
| 261 | 279 |
| 262 DictionaryValue* plugin_file = new DictionaryValue(); | 280 DictionaryValue* plugin_file = new DictionaryValue(); |
| 263 plugin_file->SetString("name", group_plugin.name); | 281 plugin_file->SetString("name", group_plugin.name); |
| 264 plugin_file->SetString("description", group_plugin.desc); | 282 plugin_file->SetString("description", group_plugin.desc); |
| 265 plugin_file->SetString("path", group_plugin.path.value()); | 283 plugin_file->SetString("path", group_plugin.path.value()); |
| 266 plugin_file->SetString("version", group_plugin.version); | 284 plugin_file->SetString("version", group_plugin.version); |
| 285 plugin_file->SetString("type", PluginTypeToString(group_plugin.type)); |
| 267 | 286 |
| 268 ListValue* mime_types = new ListValue(); | 287 ListValue* mime_types = new ListValue(); |
| 269 const std::vector<webkit::WebPluginMimeType>& plugin_mime_types = | 288 const std::vector<webkit::WebPluginMimeType>& plugin_mime_types = |
| 270 group_plugin.mime_types; | 289 group_plugin.mime_types; |
| 271 for (size_t k = 0; k < plugin_mime_types.size(); ++k) { | 290 for (size_t k = 0; k < plugin_mime_types.size(); ++k) { |
| 272 DictionaryValue* mime_type = new DictionaryValue(); | 291 DictionaryValue* mime_type = new DictionaryValue(); |
| 273 mime_type->SetString("mimeType", plugin_mime_types[k].mime_type); | 292 mime_type->SetString("mimeType", plugin_mime_types[k].mime_type); |
| 274 mime_type->SetString("description", plugin_mime_types[k].description); | 293 mime_type->SetString("description", plugin_mime_types[k].description); |
| 275 | 294 |
| 276 ListValue* file_extensions = new ListValue(); | 295 ListValue* file_extensions = new ListValue(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 389 |
| 371 // static | 390 // static |
| 372 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { | 391 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { |
| 373 prefs->RegisterBooleanPref(prefs::kPluginsShowDetails, | 392 prefs->RegisterBooleanPref(prefs::kPluginsShowDetails, |
| 374 false, | 393 false, |
| 375 PrefService::UNSYNCABLE_PREF); | 394 PrefService::UNSYNCABLE_PREF); |
| 376 prefs->RegisterBooleanPref(prefs::kPluginsShowSetReaderDefaultInfobar, | 395 prefs->RegisterBooleanPref(prefs::kPluginsShowSetReaderDefaultInfobar, |
| 377 true, | 396 true, |
| 378 PrefService::UNSYNCABLE_PREF); | 397 PrefService::UNSYNCABLE_PREF); |
| 379 } | 398 } |
| OLD | NEW |