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" |
26 #include "webkit/glue/plugins/plugin_constants_win.h" | 27 #include "webkit/glue/plugins/plugin_constants_win.h" |
27 #include "webkit/glue/plugins/plugin_list.h" | 28 #include "webkit/glue/plugins/plugin_list.h" |
28 | 29 |
29 // static | 30 // static |
30 PluginService* PluginService::GetInstance() { | 31 PluginService* PluginService::GetInstance() { |
31 return Singleton<PluginService>::get(); | 32 return Singleton<PluginService>::get(); |
32 } | 33 } |
33 | 34 |
34 PluginService::PluginService() | 35 PluginService::PluginService() |
35 : main_message_loop_(MessageLoop::current()), | 36 : main_message_loop_(MessageLoop::current()), |
36 resource_dispatcher_host_(NULL), | 37 resource_dispatcher_host_(NULL), |
37 ui_locale_(ASCIIToWide(g_browser_process->GetApplicationLocale())) { | 38 ui_locale_(ASCIIToWide(g_browser_process->GetApplicationLocale())) { |
38 // Have the NPAPI plugin list search for Chrome plugins as well. | 39 // Have the NPAPI plugin list search for Chrome plugins as well. |
39 ChromePluginLib::RegisterPluginsWithNPAPI(); | 40 ChromePluginLib::RegisterPluginsWithNPAPI(); |
40 // Load the one specified on the command line as well. | 41 // Load the one specified on the command line as well. |
41 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 42 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
42 std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin); | 43 std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin); |
43 if (!path.empty()) { | 44 if (!path.empty()) { |
44 NPAPI::PluginList::Singleton()->AddExtraPluginPath( | 45 NPAPI::PluginList::Singleton()->AddExtraPluginPath( |
45 FilePath::FromWStringHack(path)); | 46 FilePath::FromWStringHack(path)); |
46 } | 47 } |
| 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 } |
47 | 57 |
48 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
49 hkcu_key_.Create( | 59 hkcu_key_.Create( |
50 HKEY_CURRENT_USER, kRegistryMozillaPlugins, KEY_NOTIFY); | 60 HKEY_CURRENT_USER, kRegistryMozillaPlugins, KEY_NOTIFY); |
51 hklm_key_.Create( | 61 hklm_key_.Create( |
52 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, KEY_NOTIFY); | 62 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, KEY_NOTIFY); |
53 if (hkcu_key_.StartWatching()) { | 63 if (hkcu_key_.StartWatching()) { |
54 hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event())); | 64 hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event())); |
55 hkcu_watcher_.StartWatching(hkcu_event_.get(), this); | 65 hkcu_watcher_.StartWatching(hkcu_event_.get(), this); |
56 } | 66 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); | 246 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); |
237 if (it == private_plugins_.end()) | 247 if (it == private_plugins_.end()) |
238 return true; // This plugin is not private, so it's allowed everywhere. | 248 return true; // This plugin is not private, so it's allowed everywhere. |
239 | 249 |
240 // We do a dumb compare of scheme and host, rather than using the domain | 250 // We do a dumb compare of scheme and host, rather than using the domain |
241 // service, since we only care about this for extensions. | 251 // service, since we only care about this for extensions. |
242 const GURL& required_url = it->second; | 252 const GURL& required_url = it->second; |
243 return (url.scheme() == required_url.scheme() && | 253 return (url.scheme() == required_url.scheme() && |
244 url.host() == required_url.host()); | 254 url.host() == required_url.host()); |
245 } | 255 } |
OLD | NEW |