Chromium Code Reviews| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/plugin_service.h" | 7 #include "chrome/browser/plugin_service.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "chrome/browser/profile.h" | 21 #include "chrome/browser/profile.h" |
| 22 #include "chrome/browser/renderer_host/render_process_host.h" | 22 #include "chrome/browser/renderer_host/render_process_host.h" |
| 23 #include "chrome/common/chrome_plugin_lib.h" | 23 #include "chrome/common/chrome_plugin_lib.h" |
| 24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/gpu_plugin.h" | 27 #include "chrome/common/gpu_plugin.h" |
| 28 #include "chrome/common/logging_chrome.h" | 28 #include "chrome/common/logging_chrome.h" |
| 29 #include "chrome/common/notification_type.h" | 29 #include "chrome/common/notification_type.h" |
| 30 #include "chrome/common/notification_service.h" | 30 #include "chrome/common/notification_service.h" |
| 31 #include "chrome/common/pepper_plugin_registry.h" | |
| 31 #include "chrome/common/plugin_messages.h" | 32 #include "chrome/common/plugin_messages.h" |
| 32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/common/render_messages.h" | 34 #include "chrome/common/render_messages.h" |
| 34 #ifndef DISABLE_NACL | 35 #ifndef DISABLE_NACL |
| 35 #include "native_client/src/trusted/plugin/nacl_entry_points.h" | 36 #include "native_client/src/trusted/plugin/nacl_entry_points.h" |
| 36 #endif | 37 #endif |
| 37 #include "webkit/glue/plugins/plugin_constants_win.h" | 38 #include "webkit/glue/plugins/plugin_constants_win.h" |
| 38 #include "webkit/glue/plugins/plugin_list.h" | 39 #include "webkit/glue/plugins/plugin_list.h" |
| 39 | 40 |
| 40 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 | 142 |
| 142 // static | 143 // static |
| 143 void PluginService::EnableChromePlugins(bool enable) { | 144 void PluginService::EnableChromePlugins(bool enable) { |
| 144 enable_chrome_plugins_ = enable; | 145 enable_chrome_plugins_ = enable; |
| 145 } | 146 } |
| 146 | 147 |
| 147 PluginService::PluginService() | 148 PluginService::PluginService() |
| 148 : main_message_loop_(MessageLoop::current()), | 149 : main_message_loop_(MessageLoop::current()), |
| 149 resource_dispatcher_host_(NULL), | 150 resource_dispatcher_host_(NULL), |
| 150 ui_locale_(ASCIIToWide(g_browser_process->GetApplicationLocale())) { | 151 ui_locale_(ASCIIToWide(g_browser_process->GetApplicationLocale())) { |
| 152 RegisterPepperPlugins(); | |
| 153 | |
| 151 // Have the NPAPI plugin list search for Chrome plugins as well. | 154 // Have the NPAPI plugin list search for Chrome plugins as well. |
| 152 ChromePluginLib::RegisterPluginsWithNPAPI(); | 155 ChromePluginLib::RegisterPluginsWithNPAPI(); |
| 153 // Load the one specified on the command line as well. | 156 // Load the one specified on the command line as well. |
| 154 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 157 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 155 FilePath path = command_line->GetSwitchValuePath(switches::kLoadPlugin); | 158 FilePath path = command_line->GetSwitchValuePath(switches::kLoadPlugin); |
| 156 if (!path.empty()) | 159 if (!path.empty()) |
| 157 NPAPI::PluginList::Singleton()->AddExtraPluginPath(path); | 160 NPAPI::PluginList::Singleton()->AddExtraPluginPath(path); |
| 158 | 161 |
| 159 // Register the internal Flash and PDF, if available. | 162 // Register the internal Flash and PDF, if available. |
| 160 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 163 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); | 411 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); |
| 409 if (it == private_plugins_.end()) | 412 if (it == private_plugins_.end()) |
| 410 return true; // This plugin is not private, so it's allowed everywhere. | 413 return true; // This plugin is not private, so it's allowed everywhere. |
| 411 | 414 |
| 412 // We do a dumb compare of scheme and host, rather than using the domain | 415 // We do a dumb compare of scheme and host, rather than using the domain |
| 413 // service, since we only care about this for extensions. | 416 // service, since we only care about this for extensions. |
| 414 const GURL& required_url = it->second; | 417 const GURL& required_url = it->second; |
| 415 return (url.scheme() == required_url.scheme() && | 418 return (url.scheme() == required_url.scheme() && |
| 416 url.host() == required_url.host()); | 419 url.host() == required_url.host()); |
| 417 } | 420 } |
| 421 | |
| 422 void PluginService::RegisterPepperPlugins() { | |
| 423 std::vector<PepperPluginInfo> plugins; | |
| 424 PepperPluginRegistry::GetList(&plugins); | |
| 425 for (size_t i = 0; i < plugins.size(); ++i) { | |
| 426 NPAPI::PluginVersionInfo info; | |
| 427 info.path = plugins[i].path; | |
| 428 info.product_name = plugins[i].path.BaseName().ToWStringHack(); | |
|
jam
2010/05/27 23:36:49
what's the plan for getting a proper name in here?
| |
| 429 info.mime_types = ASCIIToWide(JoinString(plugins[i].mime_types, '|')); | |
| 430 | |
| 431 // These NPAPI entry points will never be called. TODO(darin): Come up | |
| 432 // with a cleaner way to register pepper plugins with the NPAPI PluginList, | |
| 433 // or perhaps refactor the PluginList to be less specific to NPAPI. | |
| 434 memset(&info.entry_points, 0, sizeof(info.entry_points)); | |
| 435 | |
| 436 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); | |
| 437 } | |
| 438 } | |
| OLD | NEW |