| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/thread.h" | 11 #include "base/thread.h" |
| 12 #include "base/waitable_event.h" | 12 #include "base/waitable_event.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_plugin_host.h" | 14 #include "chrome/browser/chrome_plugin_host.h" |
| 15 #include "chrome/browser/chrome_thread.h" | 15 #include "chrome/browser/chrome_thread.h" |
| 16 #include "chrome/browser/extensions/extensions_service.h" | 16 #include "chrome/browser/extensions/extensions_service.h" |
| 17 #include "chrome/browser/plugin_process_host.h" | 17 #include "chrome/browser/plugin_process_host.h" |
| 18 #include "chrome/browser/renderer_host/render_process_host.h" | 18 #include "chrome/browser/renderer_host/render_process_host.h" |
| 19 #include "chrome/common/chrome_plugin_lib.h" | 19 #include "chrome/common/chrome_plugin_lib.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
| 22 #include "chrome/common/logging_chrome.h" | 22 #include "chrome/common/logging_chrome.h" |
| 23 #include "chrome/common/notification_type.h" | 23 #include "chrome/common/notification_type.h" |
| 24 #include "chrome/common/notification_service.h" | 24 #include "chrome/common/notification_service.h" |
| 25 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
| 26 #include "native_client/src/trusted/plugin/nacl_entry_points.h" | |
| 27 #include "webkit/glue/plugins/plugin_constants_win.h" | 26 #include "webkit/glue/plugins/plugin_constants_win.h" |
| 28 #include "webkit/glue/plugins/plugin_list.h" | 27 #include "webkit/glue/plugins/plugin_list.h" |
| 29 | 28 |
| 30 // static | 29 // static |
| 31 PluginService* PluginService::GetInstance() { | 30 PluginService* PluginService::GetInstance() { |
| 32 return Singleton<PluginService>::get(); | 31 return Singleton<PluginService>::get(); |
| 33 } | 32 } |
| 34 | 33 |
| 35 PluginService::PluginService() | 34 PluginService::PluginService() |
| 36 : main_message_loop_(MessageLoop::current()), | 35 : main_message_loop_(MessageLoop::current()), |
| 37 resource_dispatcher_host_(NULL), | 36 resource_dispatcher_host_(NULL), |
| 38 ui_locale_(ASCIIToWide(g_browser_process->GetApplicationLocale())) { | 37 ui_locale_(ASCIIToWide(g_browser_process->GetApplicationLocale())) { |
| 39 // Have the NPAPI plugin list search for Chrome plugins as well. | 38 // Have the NPAPI plugin list search for Chrome plugins as well. |
| 40 ChromePluginLib::RegisterPluginsWithNPAPI(); | 39 ChromePluginLib::RegisterPluginsWithNPAPI(); |
| 41 // Load the one specified on the command line as well. | 40 // Load the one specified on the command line as well. |
| 42 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 41 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 43 std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin); | 42 std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin); |
| 44 if (!path.empty()) { | 43 if (!path.empty()) { |
| 45 NPAPI::PluginList::Singleton()->AddExtraPluginPath( | 44 NPAPI::PluginList::Singleton()->AddExtraPluginPath( |
| 46 FilePath::FromWStringHack(path)); | 45 FilePath::FromWStringHack(path)); |
| 47 } | 46 } |
| 48 if (command_line->HasSwitch(switches::kInternalNaCl)) { | |
| 49 NPAPI::PluginEntryPoints entry_points = { | |
| 50 #if !defined(OS_LINUX) | |
| 51 NaCl_NP_GetEntryPoints, | |
| 52 #endif | |
| 53 NaCl_NP_Initialize, | |
| 54 NaCl_NP_Shutdown}; | |
| 55 NPAPI::PluginList::UseInternalNaCl(&entry_points); | |
| 56 } | |
| 57 | 47 |
| 58 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
| 59 hkcu_key_.Create( | 49 hkcu_key_.Create( |
| 60 HKEY_CURRENT_USER, kRegistryMozillaPlugins, KEY_NOTIFY); | 50 HKEY_CURRENT_USER, kRegistryMozillaPlugins, KEY_NOTIFY); |
| 61 hklm_key_.Create( | 51 hklm_key_.Create( |
| 62 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, KEY_NOTIFY); | 52 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, KEY_NOTIFY); |
| 63 if (hkcu_key_.StartWatching()) { | 53 if (hkcu_key_.StartWatching()) { |
| 64 hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event())); | 54 hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event())); |
| 65 hkcu_watcher_.StartWatching(hkcu_event_.get(), this); | 55 hkcu_watcher_.StartWatching(hkcu_event_.get(), this); |
| 66 } | 56 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); | 236 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); |
| 247 if (it == private_plugins_.end()) | 237 if (it == private_plugins_.end()) |
| 248 return true; // This plugin is not private, so it's allowed everywhere. | 238 return true; // This plugin is not private, so it's allowed everywhere. |
| 249 | 239 |
| 250 // We do a dumb compare of scheme and host, rather than using the domain | 240 // We do a dumb compare of scheme and host, rather than using the domain |
| 251 // service, since we only care about this for extensions. | 241 // service, since we only care about this for extensions. |
| 252 const GURL& required_url = it->second; | 242 const GURL& required_url = it->second; |
| 253 return (url.scheme() == required_url.scheme() && | 243 return (url.scheme() == required_url.scheme() && |
| 254 url.host() == required_url.host()); | 244 url.host() == required_url.host()); |
| 255 } | 245 } |
| OLD | NEW |