Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/lazy_instance.h" | 6 #include "base/lazy_instance.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/plugin_manager.h" | 10 #include "chrome/browser/extensions/plugin_manager.h" |
| 11 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 11 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 14 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 15 #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h" | 15 #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h" |
| 16 #include "content/public/browser/plugin_service.h" | 16 #include "content/public/browser/plugin_service.h" |
| 17 #include "content/public/common/pepper_plugin_info.h" | 17 #include "content/public/common/pepper_plugin_info.h" |
| 18 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
| 19 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 #if !defined(DISABLE_NACL) | 22 #if !defined(DISABLE_NACL) |
| 23 #include "components/nacl/common/nacl_constants.h" | 23 #include "components/nacl/common/nacl_constants.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 const char kPDFPluginExtension[] = "pdf"; | |
| 27 const char kPDFPluginDescription[] = "Portable Document Format"; | |
| 28 | |
| 26 using content::PluginService; | 29 using content::PluginService; |
| 27 | 30 |
| 28 namespace extensions { | 31 namespace extensions { |
| 29 | 32 |
| 30 PluginManager::PluginManager(content::BrowserContext* context) | 33 PluginManager::PluginManager(content::BrowserContext* context) |
| 31 : profile_(Profile::FromBrowserContext(context)), | 34 : profile_(Profile::FromBrowserContext(context)), |
| 32 extension_registry_observer_(this) { | 35 extension_registry_observer_(this) { |
| 33 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 36 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
| 34 } | 37 } |
| 35 | 38 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 } | 86 } |
| 84 #endif | 87 #endif |
| 85 | 88 |
| 86 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 89 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
| 87 if (handler && !handler->handler_url().empty()) { | 90 if (handler && !handler->handler_url().empty()) { |
| 88 plugins_or_nacl_changed = true; | 91 plugins_or_nacl_changed = true; |
| 89 | 92 |
| 90 content::WebPluginInfo info; | 93 content::WebPluginInfo info; |
| 91 info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN; | 94 info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN; |
| 92 info.name = base::UTF8ToUTF16(extension->name()); | 95 info.name = base::UTF8ToUTF16(extension->name()); |
| 93 info.path = base::FilePath::FromUTF8Unsafe(handler->extension_id()); | 96 info.path = extension->path(); |
|
raymes
2015/01/22 03:23:40
The path is sort of unimportant. We could display
| |
| 97 info.version = base::UTF8ToUTF16(extension->GetVersionForDisplay()); | |
|
raymes
2015/01/22 03:23:40
Since this is bundled with Chrome, let's not versi
| |
| 94 | 98 |
| 95 for (std::set<std::string>::const_iterator mime_type = | 99 for (std::set<std::string>::const_iterator mime_type = |
| 96 handler->mime_type_set().begin(); | 100 handler->mime_type_set().begin(); |
| 97 mime_type != handler->mime_type_set().end(); ++mime_type) { | 101 mime_type != handler->mime_type_set().end(); ++mime_type) { |
| 98 content::WebPluginMimeType mime_type_info; | 102 content::WebPluginMimeType mime_type_info; |
| 99 mime_type_info.mime_type = *mime_type; | 103 mime_type_info.mime_type = *mime_type; |
| 100 base::FilePath::StringType file_extension; | 104 base::FilePath::StringType file_extension; |
| 101 if (net::GetPreferredExtensionForMimeType(*mime_type, &file_extension)) { | 105 if (net::GetPreferredExtensionForMimeType(*mime_type, &file_extension)) { |
| 102 mime_type_info.file_extensions.push_back( | 106 std::string mime_file_extension = |
| 103 base::FilePath(file_extension).AsUTF8Unsafe()); | 107 base::FilePath(file_extension).AsUTF8Unsafe(); |
| 108 mime_type_info.file_extensions.push_back(mime_file_extension); | |
| 109 if (!mime_file_extension.compare(std::string(kPDFPluginExtension))) { | |
| 110 mime_type_info.description = | |
| 111 base::UTF8ToUTF16(std::string(kPDFPluginDescription)); | |
| 112 } | |
|
raymes
2015/01/22 03:23:40
We don't need to have a description (there current
| |
| 104 } | 113 } |
| 105 info.mime_types.push_back(mime_type_info); | 114 info.mime_types.push_back(mime_type_info); |
| 106 } | 115 } |
| 107 | 116 |
| 108 PluginService::GetInstance()->RefreshPlugins(); | 117 PluginService::GetInstance()->RefreshPlugins(); |
| 109 PluginService::GetInstance()->RegisterInternalPlugin(info, true); | 118 PluginService::GetInstance()->RegisterInternalPlugin(info, true); |
| 110 } | 119 } |
| 111 | 120 |
| 112 if (plugins_or_nacl_changed) | 121 if (plugins_or_nacl_changed) |
| 113 PluginService::GetInstance()->PurgePluginListCache(profile_, false); | 122 PluginService::GetInstance()->PurgePluginListCache(profile_, false); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 iter != nacl_module_list_.end(); ++iter) { | 234 iter != nacl_module_list_.end(); ++iter) { |
| 226 if (iter->url == url) | 235 if (iter->url == url) |
| 227 return iter; | 236 return iter; |
| 228 } | 237 } |
| 229 return nacl_module_list_.end(); | 238 return nacl_module_list_.end(); |
| 230 } | 239 } |
| 231 | 240 |
| 232 #endif // !defined(DISABLE_NACL) | 241 #endif // !defined(DISABLE_NACL) |
| 233 | 242 |
| 234 } // namespace extensions | 243 } // namespace extensions |
| OLD | NEW |