[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | a042173 | 2011-02-23 03:55:40 | [diff] [blame] | 5 | #include "content/browser/plugin_service.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 6 | |
[email protected] | ceac997 | 2011-01-13 01:51:14 | [diff] [blame] | 7 | #include <vector> |
| 8 | |
[email protected] | d48f1e0c | 2009-02-12 20:57:54 | [diff] [blame] | 9 | #include "base/command_line.h" |
[email protected] | 9c49ff0 | 2010-01-27 01:20:55 | [diff] [blame] | 10 | #include "base/path_service.h" |
[email protected] | d70539de | 2009-06-24 22:17:06 | [diff] [blame] | 11 | #include "base/string_util.h" |
[email protected] | 34b9963 | 2011-01-01 01:01:06 | [diff] [blame] | 12 | #include "base/threading/thread.h" |
[email protected] | be1ce6a7 | 2010-08-03 14:35:22 | [diff] [blame] | 13 | #include "base/utf_string_conversions.h" |
[email protected] | cec1b8d | 2010-03-24 00:21:34 | [diff] [blame] | 14 | #include "base/values.h" |
[email protected] | 44f9c95 | 2011-01-02 06:05:39 | [diff] [blame] | 15 | #include "base/synchronization/waitable_event.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | #include "chrome/browser/browser_process.h" |
| 17 | #include "chrome/browser/chrome_plugin_host.h" |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 18 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | 0a8b1e2 | 2010-07-02 09:31:11 | [diff] [blame] | 19 | #include "chrome/browser/plugin_updater.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 20 | #include "chrome/browser/profiles/profile.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 21 | #include "chrome/common/chrome_plugin_lib.h" |
[email protected] | 9c49ff0 | 2010-01-27 01:20:55 | [diff] [blame] | 22 | #include "chrome/common/chrome_paths.h" |
[email protected] | d48f1e0c | 2009-02-12 20:57:54 | [diff] [blame] | 23 | #include "chrome/common/chrome_switches.h" |
[email protected] | 2290cb86 | 2010-06-02 16:50:58 | [diff] [blame] | 24 | #include "chrome/common/default_plugin.h" |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 25 | #include "chrome/common/extensions/extension.h" |
[email protected] | 0b537a44 | 2011-03-04 00:43:15 | [diff] [blame] | 26 | #include "chrome/common/gpu_plugin.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 27 | #include "chrome/common/logging_chrome.h" |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 28 | #include "chrome/common/notification_type.h" |
| 29 | #include "chrome/common/notification_service.h" |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 30 | #include "chrome/common/pepper_plugin_registry.h" |
[email protected] | 4e59e81 | 2010-04-06 20:51:16 | [diff] [blame] | 31 | #include "chrome/common/plugin_messages.h" |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 32 | #include "chrome/common/render_messages.h" |
[email protected] | a042173 | 2011-02-23 03:55:40 | [diff] [blame] | 33 | #include "content/browser/browser_thread.h" |
[email protected] | a01efd2 | 2011-03-01 00:38:32 | [diff] [blame] | 34 | #include "content/browser/ppapi_plugin_process_host.h" |
[email protected] | a042173 | 2011-02-23 03:55:40 | [diff] [blame] | 35 | #include "content/browser/renderer_host/render_process_host.h" |
| 36 | #include "content/browser/renderer_host/render_view_host.h" |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 37 | #include "webkit/plugins/npapi/plugin_constants_win.h" |
| 38 | #include "webkit/plugins/npapi/plugin_list.h" |
| 39 | #include "webkit/plugins/npapi/webplugininfo.h" |
| 40 | |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 41 | #if defined(OS_CHROMEOS) |
| 42 | #include "chrome/browser/chromeos/plugin_selection_policy.h" |
| 43 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 44 | |
[email protected] | a96ec6a | 2009-11-04 17:27:08 | [diff] [blame] | 45 | #if defined(OS_MACOSX) |
| 46 | static void NotifyPluginsOfActivation() { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 47 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | a96ec6a | 2009-11-04 17:27:08 | [diff] [blame] | 48 | |
[email protected] | d27893f6 | 2010-07-03 05:47:42 | [diff] [blame] | 49 | for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); |
[email protected] | a96ec6a | 2009-11-04 17:27:08 | [diff] [blame] | 50 | !iter.Done(); ++iter) { |
| 51 | PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); |
| 52 | plugin->OnAppActivation(); |
| 53 | } |
| 54 | } |
| 55 | #endif |
| 56 | |
[email protected] | 634d23d | 2011-01-19 10:38:19 | [diff] [blame] | 57 | static void PurgePluginListCache(bool reload_pages) { |
| 58 | for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); |
| 59 | !it.IsAtEnd(); it.Advance()) { |
| 60 | it.GetCurrentValue()->Send(new ViewMsg_PurgePluginListCache(reload_pages)); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | #if defined(OS_LINUX) |
| 65 | // Delegate class for monitoring directories. |
| 66 | class PluginDirWatcherDelegate : public FilePathWatcher::Delegate { |
| 67 | virtual void OnFilePathChanged(const FilePath& path) { |
| 68 | VLOG(1) << "Watched path changed: " << path.value(); |
| 69 | // Make the plugin list update itself |
| 70 | webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
| 71 | } |
| 72 | virtual void OnError() { |
| 73 | // TODO(pastarmovj): Add some sensible error handling. Maybe silently |
| 74 | // stopping the watcher would be enough. Or possibly restart it. |
| 75 | NOTREACHED(); |
| 76 | } |
| 77 | }; |
| 78 | #endif |
| 79 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 80 | // static |
[email protected] | 51549da | 2009-11-21 08:43:39 | [diff] [blame] | 81 | bool PluginService::enable_chrome_plugins_ = true; |
| 82 | |
| 83 | // static |
[email protected] | cec1b8d | 2010-03-24 00:21:34 | [diff] [blame] | 84 | void PluginService::InitGlobalInstance(Profile* profile) { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 85 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
[email protected] | cec1b8d | 2010-03-24 00:21:34 | [diff] [blame] | 86 | |
[email protected] | 24ff43d7 | 2011-03-01 13:28:58 | [diff] [blame] | 87 | // We first group the plugins and then figure out which groups to |
| 88 | // enable or disable. |
| 89 | PluginUpdater::GetInstance()->UpdatePluginGroupsStateFromPrefs(profile); |
[email protected] | 7bf795d9 | 2010-05-22 00:14:28 | [diff] [blame] | 90 | |
[email protected] | cec1b8d | 2010-03-24 00:21:34 | [diff] [blame] | 91 | // Have Chrome plugins write their data to the profile directory. |
| 92 | GetInstance()->SetChromePluginDataDir(profile->GetPath()); |
| 93 | } |
| 94 | |
| 95 | // static |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 96 | PluginService* PluginService::GetInstance() { |
| 97 | return Singleton<PluginService>::get(); |
| 98 | } |
| 99 | |
[email protected] | 51549da | 2009-11-21 08:43:39 | [diff] [blame] | 100 | // static |
| 101 | void PluginService::EnableChromePlugins(bool enable) { |
| 102 | enable_chrome_plugins_ = enable; |
| 103 | } |
| 104 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 105 | PluginService::PluginService() |
| 106 | : main_message_loop_(MessageLoop::current()), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 107 | resource_dispatcher_host_(NULL), |
[email protected] | f77d8762 | 2010-07-30 17:43:17 | [diff] [blame] | 108 | ui_locale_(g_browser_process->GetApplicationLocale()) { |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 109 | RegisterPepperPlugins(); |
| 110 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 111 | // Have the NPAPI plugin list search for Chrome plugins as well. |
| 112 | ChromePluginLib::RegisterPluginsWithNPAPI(); |
[email protected] | 9a1c426 | 2010-06-29 21:50:27 | [diff] [blame] | 113 | |
| 114 | // Load any specified on the command line as well. |
[email protected] | d48f1e0c | 2009-02-12 20:57:54 | [diff] [blame] | 115 | const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
[email protected] | c4e52f0d | 2009-11-06 19:55:16 | [diff] [blame] | 116 | FilePath path = command_line->GetSwitchValuePath(switches::kLoadPlugin); |
[email protected] | 7bf795d9 | 2010-05-22 00:14:28 | [diff] [blame] | 117 | if (!path.empty()) |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 118 | webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path); |
[email protected] | 9a1c426 | 2010-06-29 21:50:27 | [diff] [blame] | 119 | path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); |
| 120 | if (!path.empty()) |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 121 | webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(path); |
[email protected] | 7bf795d9 | 2010-05-22 00:14:28 | [diff] [blame] | 122 | |
[email protected] | 2290cb86 | 2010-06-02 16:50:58 | [diff] [blame] | 123 | chrome::RegisterInternalDefaultPlugin(); |
| 124 | |
[email protected] | 7bf795d9 | 2010-05-22 00:14:28 | [diff] [blame] | 125 | // Register the internal Flash and PDF, if available. |
| 126 | if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 127 | switches::kDisableInternalFlash) && |
| 128 | PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 129 | webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path); |
[email protected] | 35fa6a2 | 2009-08-15 00:04:01 | [diff] [blame] | 130 | } |
[email protected] | d7ce427 | 2010-03-27 01:06:01 | [diff] [blame] | 131 | |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 132 | #if defined(OS_CHROMEOS) |
| 133 | plugin_selection_policy_ = new chromeos::PluginSelectionPolicy; |
| 134 | plugin_selection_policy_->StartInit(); |
| 135 | #endif |
| 136 | |
[email protected] | 0b537a44 | 2011-03-04 00:43:15 | [diff] [blame] | 137 | chrome::RegisterInternalGPUPlugin(); |
| 138 | |
[email protected] | 634d23d | 2011-01-19 10:38:19 | [diff] [blame] | 139 | // Start watching for changes in the plugin list. This means watching |
| 140 | // for changes in the Windows registry keys and on both Windows and POSIX |
| 141 | // watch for changes in the paths that are expected to contain plugins. |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 142 | #if defined(OS_WIN) |
| 143 | hkcu_key_.Create( |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 144 | HKEY_CURRENT_USER, webkit::npapi::kRegistryMozillaPlugins, KEY_NOTIFY); |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 145 | hklm_key_.Create( |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 146 | HKEY_LOCAL_MACHINE, webkit::npapi::kRegistryMozillaPlugins, KEY_NOTIFY); |
[email protected] | e06f4d5 | 2011-01-19 07:28:46 | [diff] [blame] | 147 | if (hkcu_key_.StartWatching() == ERROR_SUCCESS) { |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 148 | hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event())); |
| 149 | hkcu_watcher_.StartWatching(hkcu_event_.get(), this); |
| 150 | } |
| 151 | |
[email protected] | e06f4d5 | 2011-01-19 07:28:46 | [diff] [blame] | 152 | if (hklm_key_.StartWatching() == ERROR_SUCCESS) { |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 153 | hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); |
| 154 | hklm_watcher_.StartWatching(hklm_event_.get(), this); |
| 155 | } |
[email protected] | 9c49ff0 | 2010-01-27 01:20:55 | [diff] [blame] | 156 | #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
| 157 | // Also find plugins in a user-specific plugins dir, |
| 158 | // e.g. ~/.config/chromium/Plugins. |
| 159 | FilePath user_data_dir; |
| 160 | if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 161 | webkit::npapi::PluginList::Singleton()->AddExtraPluginDir( |
[email protected] | 9c49ff0 | 2010-01-27 01:20:55 | [diff] [blame] | 162 | user_data_dir.Append("Plugins")); |
| 163 | } |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 164 | #endif |
[email protected] | 634d23d | 2011-01-19 10:38:19 | [diff] [blame] | 165 | // The FilePathWatcher produces too many false positives on MacOS (access time |
| 166 | // updates?) which will lead to enforcing updates of the plugins way too often. |
| 167 | // On ChromeOS the user can't install plugins anyway and on Windows all |
| 168 | // important plugins register themselves in the registry so no need to do that. |
| 169 | #if defined(OS_LINUX) |
| 170 | file_watcher_delegate_ = new PluginDirWatcherDelegate(); |
| 171 | // Get the list of all paths for registering the FilePathWatchers |
| 172 | // that will track and if needed reload the list of plugins on runtime. |
| 173 | std::vector<FilePath> plugin_dirs; |
| 174 | webkit::npapi::PluginList::Singleton()->GetPluginDirectories( |
| 175 | &plugin_dirs); |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 176 | |
[email protected] | 634d23d | 2011-01-19 10:38:19 | [diff] [blame] | 177 | for (size_t i = 0; i < plugin_dirs.size(); ++i) { |
| 178 | FilePathWatcher* watcher = new FilePathWatcher(); |
| 179 | // FilePathWatcher can not handle non-absolute paths under windows. |
| 180 | // We don't watch for file changes in windows now but if this should ever |
| 181 | // be extended to Windows these lines might save some time of debugging. |
| 182 | #if defined(OS_WIN) |
| 183 | if (!plugin_dirs[i].IsAbsolute()) |
| 184 | continue; |
| 185 | #endif |
| 186 | VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value(); |
| 187 | BrowserThread::PostTask( |
| 188 | BrowserThread::FILE, FROM_HERE, |
| 189 | NewRunnableFunction( |
| 190 | &PluginService::RegisterFilePathWatcher, |
| 191 | watcher, plugin_dirs[i], file_watcher_delegate_)); |
| 192 | file_watchers_.push_back(watcher); |
| 193 | } |
| 194 | #endif |
[email protected] | ae09ca6 | 2009-08-21 19:46:46 | [diff] [blame] | 195 | registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 196 | NotificationService::AllSources()); |
| 197 | registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
| 198 | NotificationService::AllSources()); |
[email protected] | a96ec6a | 2009-11-04 17:27:08 | [diff] [blame] | 199 | #if defined(OS_MACOSX) |
| 200 | // We need to know when the browser comes forward so we can bring modal plugin |
| 201 | // windows forward too. |
| 202 | registrar_.Add(this, NotificationType::APP_ACTIVATED, |
| 203 | NotificationService::AllSources()); |
| 204 | #endif |
[email protected] | 5f101bbe | 2010-10-08 08:01:16 | [diff] [blame] | 205 | registrar_.Add(this, NotificationType::PLUGIN_ENABLE_STATUS_CHANGED, |
| 206 | NotificationService::AllSources()); |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 207 | registrar_.Add(this, |
| 208 | NotificationType::RENDERER_PROCESS_CLOSED, |
| 209 | NotificationService::AllSources()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | PluginService::~PluginService() { |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 213 | #if defined(OS_WIN) |
| 214 | // Release the events since they're owned by RegKey, not WaitableEvent. |
| 215 | hkcu_watcher_.StopWatching(); |
| 216 | hklm_watcher_.StopWatching(); |
[email protected] | c247cab | 2011-01-21 01:58:42 | [diff] [blame] | 217 | if (hkcu_event_.get()) |
| 218 | hkcu_event_->Release(); |
| 219 | if (hklm_event_.get()) |
| 220 | hklm_event_->Release(); |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 221 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 222 | } |
| 223 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 224 | void PluginService::LoadChromePlugins( |
| 225 | ResourceDispatcherHost* resource_dispatcher_host) { |
[email protected] | 51549da | 2009-11-21 08:43:39 | [diff] [blame] | 226 | if (!enable_chrome_plugins_) |
| 227 | return; |
| 228 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 229 | resource_dispatcher_host_ = resource_dispatcher_host; |
| 230 | ChromePluginLib::LoadChromePlugins(GetCPBrowserFuncsForBrowser()); |
| 231 | } |
| 232 | |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 233 | void PluginService::SetChromePluginDataDir(const FilePath& data_dir) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 234 | chrome_plugin_data_dir_ = data_dir; |
| 235 | } |
| 236 | |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 237 | const FilePath& PluginService::GetChromePluginDataDir() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 238 | return chrome_plugin_data_dir_; |
| 239 | } |
| 240 | |
[email protected] | f77d8762 | 2010-07-30 17:43:17 | [diff] [blame] | 241 | const std::string& PluginService::GetUILocale() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 242 | return ui_locale_; |
| 243 | } |
| 244 | |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 245 | PluginProcessHost* PluginService::FindNpapiPluginProcess( |
[email protected] | 28ab7f9 | 2009-01-06 21:39:04 | [diff] [blame] | 246 | const FilePath& plugin_path) { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 247 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 248 | |
[email protected] | d27893f6 | 2010-07-03 05:47:42 | [diff] [blame] | 249 | for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); |
[email protected] | a436d92 | 2009-02-13 23:16:42 | [diff] [blame] | 250 | !iter.Done(); ++iter) { |
| 251 | PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); |
| 252 | if (plugin->info().path == plugin_path) |
| 253 | return plugin; |
| 254 | } |
| 255 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 256 | return NULL; |
| 257 | } |
| 258 | |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 259 | PpapiPluginProcessHost* PluginService::FindPpapiPluginProcess( |
[email protected] | 610c089 | 2009-09-08 19:46:18 | [diff] [blame] | 260 | const FilePath& plugin_path) { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 261 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 262 | |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 263 | for (BrowserChildProcessHost::Iterator iter( |
| 264 | ChildProcessInfo::PPAPI_PLUGIN_PROCESS); |
| 265 | !iter.Done(); ++iter) { |
| 266 | PpapiPluginProcessHost* plugin = |
| 267 | static_cast<PpapiPluginProcessHost*>(*iter); |
| 268 | if (plugin->plugin_path() == plugin_path) |
| 269 | return plugin; |
| 270 | } |
| 271 | |
| 272 | return NULL; |
| 273 | } |
| 274 | |
| 275 | PluginProcessHost* PluginService::FindOrStartNpapiPluginProcess( |
| 276 | const FilePath& plugin_path) { |
| 277 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 278 | |
| 279 | PluginProcessHost* plugin_host = FindNpapiPluginProcess(plugin_path); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 280 | if (plugin_host) |
| 281 | return plugin_host; |
| 282 | |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 283 | webkit::npapi::WebPluginInfo info; |
| 284 | if (!webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( |
| 285 | plugin_path, &info)) { |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 286 | return NULL; |
| 287 | } |
| 288 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 289 | // This plugin isn't loaded by any plugin process, so create a new process. |
[email protected] | 8b8a554d | 2010-11-18 13:26:40 | [diff] [blame] | 290 | scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); |
| 291 | if (!new_host->Init(info, ui_locale_)) { |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 292 | NOTREACHED(); // Init is not expected to fail. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 293 | return NULL; |
| 294 | } |
[email protected] | 8b8a554d | 2010-11-18 13:26:40 | [diff] [blame] | 295 | return new_host.release(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 296 | } |
| 297 | |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 298 | PpapiPluginProcessHost* PluginService::FindOrStartPpapiPluginProcess( |
| 299 | const FilePath& plugin_path) { |
| 300 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 301 | |
| 302 | PpapiPluginProcessHost* plugin_host = FindPpapiPluginProcess(plugin_path); |
| 303 | if (plugin_host) |
| 304 | return plugin_host; |
| 305 | |
| 306 | // Validate that the plugin is actually registered. There should generally |
| 307 | // be very few plugins so a brute-force search is fine. |
| 308 | PepperPluginInfo* info = NULL; |
| 309 | for (size_t i = 0; i < ppapi_plugins_.size(); i++) { |
| 310 | if (ppapi_plugins_[i].path == plugin_path) { |
| 311 | info = &ppapi_plugins_[i]; |
| 312 | break; |
| 313 | } |
| 314 | } |
| 315 | if (!info) |
| 316 | return NULL; |
| 317 | |
| 318 | // This plugin isn't loaded by any plugin process, so create a new process. |
| 319 | scoped_ptr<PpapiPluginProcessHost> new_host(new PpapiPluginProcessHost); |
| 320 | if (!new_host->Init(plugin_path)) { |
| 321 | NOTREACHED(); // Init is not expected to fail. |
| 322 | return NULL; |
| 323 | } |
| 324 | return new_host.release(); |
| 325 | } |
| 326 | |
| 327 | void PluginService::OpenChannelToNpapiPlugin( |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 328 | int render_process_id, |
| 329 | int render_view_id, |
[email protected] | 610c089 | 2009-09-08 19:46:18 | [diff] [blame] | 330 | const GURL& url, |
| 331 | const std::string& mime_type, |
[email protected] | 46b69e4 | 2010-11-02 12:26:39 | [diff] [blame] | 332 | PluginProcessHost::Client* client) { |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 333 | // The PluginList::GetFirstAllowedPluginInfo may need to load the |
| 334 | // plugins. Don't do it on the IO thread. |
| 335 | BrowserThread::PostTask( |
| 336 | BrowserThread::FILE, FROM_HERE, |
| 337 | NewRunnableMethod( |
| 338 | this, &PluginService::GetAllowedPluginForOpenChannelToPlugin, |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 339 | render_process_id, render_view_id, url, mime_type, client)); |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 340 | } |
| 341 | |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 342 | void PluginService::OpenChannelToPpapiPlugin( |
| 343 | const FilePath& path, |
| 344 | PpapiPluginProcessHost::Client* client) { |
| 345 | PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess(path); |
| 346 | if (plugin_host) |
| 347 | plugin_host->OpenChannelToPlugin(client); |
| 348 | else // Send error. |
| 349 | client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle()); |
| 350 | } |
| 351 | |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 352 | void PluginService::GetAllowedPluginForOpenChannelToPlugin( |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 353 | int render_process_id, |
| 354 | int render_view_id, |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 355 | const GURL& url, |
| 356 | const std::string& mime_type, |
[email protected] | 46b69e4 | 2010-11-02 12:26:39 | [diff] [blame] | 357 | PluginProcessHost::Client* client) { |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 358 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 359 | webkit::npapi::WebPluginInfo info; |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 360 | bool found = GetFirstAllowedPluginInfo( |
| 361 | render_process_id, render_view_id, url, mime_type, &info, NULL); |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 362 | FilePath plugin_path; |
[email protected] | b83ff22 | 2011-01-24 17:37:12 | [diff] [blame] | 363 | if (found && webkit::npapi::IsPluginEnabled(info)) |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 364 | plugin_path = FilePath(info.path); |
| 365 | |
| 366 | // Now we jump back to the IO thread to finish opening the channel. |
| 367 | BrowserThread::PostTask( |
| 368 | BrowserThread::IO, FROM_HERE, |
| 369 | NewRunnableMethod( |
| 370 | this, &PluginService::FinishOpenChannelToPlugin, |
[email protected] | 46b69e4 | 2010-11-02 12:26:39 | [diff] [blame] | 371 | plugin_path, client)); |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | void PluginService::FinishOpenChannelToPlugin( |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 375 | const FilePath& plugin_path, |
[email protected] | 46b69e4 | 2010-11-02 12:26:39 | [diff] [blame] | 376 | PluginProcessHost::Client* client) { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 377 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 20a793e | 2010-10-12 06:50:08 | [diff] [blame] | 378 | |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 379 | PluginProcessHost* plugin_host = FindOrStartNpapiPluginProcess(plugin_path); |
[email protected] | 46b69e4 | 2010-11-02 12:26:39 | [diff] [blame] | 380 | if (plugin_host) |
| 381 | plugin_host->OpenChannelToPlugin(client); |
| 382 | else |
| 383 | client->OnError(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 384 | } |
| 385 | |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 386 | bool PluginService::GetFirstAllowedPluginInfo( |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 387 | int render_process_id, |
| 388 | int render_view_id, |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 389 | const GURL& url, |
| 390 | const std::string& mime_type, |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 391 | webkit::npapi::WebPluginInfo* info, |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 392 | std::string* actual_mime_type) { |
| 393 | // GetPluginInfoArray may need to load the plugins, so we need to be |
| 394 | // on the FILE thread. |
| 395 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 396 | bool allow_wildcard = true; |
| 397 | #if defined(OS_CHROMEOS) |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 398 | std::vector<webkit::npapi::WebPluginInfo> info_array; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 399 | std::vector<std::string> actual_mime_types; |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 400 | webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 401 | url, mime_type, allow_wildcard, &info_array, &actual_mime_types); |
| 402 | |
| 403 | // Now we filter by the plugin selection policy. |
| 404 | int allowed_index = plugin_selection_policy_->FindFirstAllowed(url, |
| 405 | info_array); |
| 406 | if (!info_array.empty() && allowed_index >= 0) { |
| 407 | *info = info_array[allowed_index]; |
| 408 | if (actual_mime_type) |
| 409 | *actual_mime_type = actual_mime_types[allowed_index]; |
| 410 | return true; |
| 411 | } |
| 412 | return false; |
| 413 | #else |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 414 | { |
[email protected] | 5c19e8b | 2011-01-22 00:18:47 | [diff] [blame] | 415 | base::AutoLock auto_lock(overridden_plugins_lock_); |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 416 | for (size_t i = 0; i < overridden_plugins_.size(); ++i) { |
| 417 | if (overridden_plugins_[i].render_process_id == render_process_id && |
| 418 | overridden_plugins_[i].render_view_id == render_view_id && |
| 419 | overridden_plugins_[i].url == url) { |
[email protected] | 79f0fa75 | 2011-01-27 20:01:47 | [diff] [blame] | 420 | if (actual_mime_type) |
| 421 | *actual_mime_type = mime_type; |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 422 | *info = overridden_plugins_[i].plugin; |
| 423 | return true; |
| 424 | } |
| 425 | } |
| 426 | } |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 427 | return webkit::npapi::PluginList::Singleton()->GetPluginInfo( |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 428 | url, mime_type, allow_wildcard, info, actual_mime_type); |
| 429 | #endif |
| 430 | } |
| 431 | |
[email protected] | 58052263 | 2009-08-17 21:55:55 | [diff] [blame] | 432 | void PluginService::OnWaitableEventSignaled( |
| 433 | base::WaitableEvent* waitable_event) { |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 434 | #if defined(OS_WIN) |
| 435 | if (waitable_event == hkcu_event_.get()) { |
| 436 | hkcu_key_.StartWatching(); |
| 437 | } else { |
| 438 | hklm_key_.StartWatching(); |
| 439 | } |
| 440 | |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 441 | webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
[email protected] | b78e168b | 2009-09-21 22:05:45 | [diff] [blame] | 442 | PurgePluginListCache(true); |
[email protected] | 634d23d | 2011-01-19 10:38:19 | [diff] [blame] | 443 | #else |
| 444 | // This event should only get signaled on a Windows machine. |
| 445 | NOTREACHED(); |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 446 | #endif // defined(OS_WIN) |
[email protected] | b547fd4 | 2009-04-23 23:16:27 | [diff] [blame] | 447 | } |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 448 | |
[email protected] | 4e59e81 | 2010-04-06 20:51:16 | [diff] [blame] | 449 | static void ForceShutdownPlugin(const FilePath& plugin_path) { |
| 450 | PluginProcessHost* plugin = |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 451 | PluginService::GetInstance()->FindNpapiPluginProcess(plugin_path); |
[email protected] | 4e59e81 | 2010-04-06 20:51:16 | [diff] [blame] | 452 | if (plugin) |
| 453 | plugin->ForceShutdown(); |
| 454 | } |
| 455 | |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 456 | void PluginService::Observe(NotificationType type, |
| 457 | const NotificationSource& source, |
| 458 | const NotificationDetails& details) { |
| 459 | switch (type.value) { |
[email protected] | ae09ca6 | 2009-08-21 19:46:46 | [diff] [blame] | 460 | case NotificationType::EXTENSION_LOADED: { |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 461 | const Extension* extension = Details<const Extension>(details).ptr(); |
[email protected] | b78e168b | 2009-09-21 22:05:45 | [diff] [blame] | 462 | bool plugins_changed = false; |
[email protected] | ee5e379 | 2009-10-13 23:23:47 | [diff] [blame] | 463 | for (size_t i = 0; i < extension->plugins().size(); ++i) { |
[email protected] | ae09ca6 | 2009-08-21 19:46:46 | [diff] [blame] | 464 | const Extension::PluginInfo& plugin = extension->plugins()[i]; |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 465 | webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
| 466 | webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(plugin.path); |
[email protected] | b78e168b | 2009-09-21 22:05:45 | [diff] [blame] | 467 | plugins_changed = true; |
[email protected] | ae09ca6 | 2009-08-21 19:46:46 | [diff] [blame] | 468 | if (!plugin.is_public) |
| 469 | private_plugins_[plugin.path] = extension->url(); |
[email protected] | c533bb2 | 2009-06-03 19:06:11 | [diff] [blame] | 470 | } |
[email protected] | b78e168b | 2009-09-21 22:05:45 | [diff] [blame] | 471 | if (plugins_changed) |
| 472 | PurgePluginListCache(false); |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 473 | break; |
| 474 | } |
| 475 | |
| 476 | case NotificationType::EXTENSION_UNLOADED: { |
[email protected] | a9f39a31 | 2010-12-23 22:14:27 | [diff] [blame] | 477 | const Extension* extension = |
| 478 | Details<UnloadedExtensionInfo>(details)->extension; |
[email protected] | b78e168b | 2009-09-21 22:05:45 | [diff] [blame] | 479 | bool plugins_changed = false; |
[email protected] | ee5e379 | 2009-10-13 23:23:47 | [diff] [blame] | 480 | for (size_t i = 0; i < extension->plugins().size(); ++i) { |
[email protected] | b78e168b | 2009-09-21 22:05:45 | [diff] [blame] | 481 | const Extension::PluginInfo& plugin = extension->plugins()[i]; |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 482 | BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 483 | NewRunnableFunction(&ForceShutdownPlugin, |
| 484 | plugin.path)); |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 485 | webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
| 486 | webkit::npapi::PluginList::Singleton()->RemoveExtraPluginPath( |
| 487 | plugin.path); |
[email protected] | b78e168b | 2009-09-21 22:05:45 | [diff] [blame] | 488 | plugins_changed = true; |
| 489 | if (!plugin.is_public) |
| 490 | private_plugins_.erase(plugin.path); |
| 491 | } |
| 492 | if (plugins_changed) |
| 493 | PurgePluginListCache(false); |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 494 | break; |
| 495 | } |
| 496 | |
[email protected] | a96ec6a | 2009-11-04 17:27:08 | [diff] [blame] | 497 | #if defined(OS_MACOSX) |
| 498 | case NotificationType::APP_ACTIVATED: { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 499 | BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 500 | NewRunnableFunction(&NotifyPluginsOfActivation)); |
[email protected] | a96ec6a | 2009-11-04 17:27:08 | [diff] [blame] | 501 | break; |
| 502 | } |
| 503 | #endif |
| 504 | |
[email protected] | 5f101bbe | 2010-10-08 08:01:16 | [diff] [blame] | 505 | case NotificationType::PLUGIN_ENABLE_STATUS_CHANGED: { |
[email protected] | b83ff22 | 2011-01-24 17:37:12 | [diff] [blame] | 506 | webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
[email protected] | 5f101bbe | 2010-10-08 08:01:16 | [diff] [blame] | 507 | PurgePluginListCache(false); |
| 508 | break; |
| 509 | } |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 510 | case NotificationType::RENDERER_PROCESS_CLOSED: { |
| 511 | int render_process_id = Source<RenderProcessHost>(source).ptr()->id(); |
| 512 | |
[email protected] | 5c19e8b | 2011-01-22 00:18:47 | [diff] [blame] | 513 | base::AutoLock auto_lock(overridden_plugins_lock_); |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 514 | for (size_t i = 0; i < overridden_plugins_.size(); ++i) { |
| 515 | if (overridden_plugins_[i].render_process_id == render_process_id) { |
| 516 | overridden_plugins_.erase(overridden_plugins_.begin() + i); |
| 517 | break; |
| 518 | } |
| 519 | } |
| 520 | break; |
| 521 | } |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 522 | default: |
[email protected] | 634d23d | 2011-01-19 10:38:19 | [diff] [blame] | 523 | NOTREACHED(); |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 524 | } |
| 525 | } |
[email protected] | 9dd9e838 | 2009-06-05 18:23:21 | [diff] [blame] | 526 | |
[email protected] | 7a13e79 | 2010-08-03 08:18:24 | [diff] [blame] | 527 | bool PluginService::PrivatePluginAllowedForURL(const FilePath& plugin_path, |
| 528 | const GURL& url) { |
[email protected] | 9dd9e838 | 2009-06-05 18:23:21 | [diff] [blame] | 529 | if (url.is_empty()) |
| 530 | return true; // Caller wants all plugins. |
| 531 | |
| 532 | PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); |
| 533 | if (it == private_plugins_.end()) |
| 534 | return true; // This plugin is not private, so it's allowed everywhere. |
| 535 | |
| 536 | // We do a dumb compare of scheme and host, rather than using the domain |
| 537 | // service, since we only care about this for extensions. |
| 538 | const GURL& required_url = it->second; |
| 539 | return (url.scheme() == required_url.scheme() && |
| 540 | url.host() == required_url.host()); |
| 541 | } |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 542 | |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 543 | void PluginService::OverridePluginForTab(OverriddenPlugin plugin) { |
[email protected] | 5c19e8b | 2011-01-22 00:18:47 | [diff] [blame] | 544 | base::AutoLock auto_lock(overridden_plugins_lock_); |
[email protected] | c8f73ab | 2011-01-22 00:05:17 | [diff] [blame] | 545 | overridden_plugins_.push_back(plugin); |
| 546 | } |
| 547 | |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 548 | void PluginService::RegisterPepperPlugins() { |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 549 | PepperPluginRegistry::ComputeList(&ppapi_plugins_); |
[email protected] | fa28c100 | 2011-03-03 19:57:36 | [diff] [blame] | 550 | |
| 551 | // Get the file path of the Native Client Plugin. |
| 552 | FilePath naclPath; |
| 553 | PathService::Get(chrome::FILE_NACL_PLUGIN, &naclPath); |
| 554 | |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 555 | for (size_t i = 0; i < ppapi_plugins_.size(); ++i) { |
[email protected] | b1420b19 | 2011-01-19 21:32:36 | [diff] [blame] | 556 | webkit::npapi::WebPluginInfo info; |
[email protected] | a08ebea | 2011-02-13 17:50:20 | [diff] [blame] | 557 | info.name = ppapi_plugins_[i].name.empty() ? |
| 558 | ppapi_plugins_[i].path.BaseName().LossyDisplayName() : |
| 559 | ASCIIToUTF16(ppapi_plugins_[i].name); |
[email protected] | f85d311a | 2011-03-08 00:42:07 | [diff] [blame^] | 560 | info.path = ppapi_plugins_[i].path; |
[email protected] | a505dfb | 2011-02-16 20:04:45 | [diff] [blame] | 561 | info.version = ASCIIToUTF16(ppapi_plugins_[i].version); |
[email protected] | f85d311a | 2011-03-08 00:42:07 | [diff] [blame^] | 562 | info.desc = ASCIIToUTF16(ppapi_plugins_[i].description); |
| 563 | info.mime_types = ppapi_plugins_[i].mime_types; |
[email protected] | fa28c100 | 2011-03-03 19:57:36 | [diff] [blame] | 564 | |
| 565 | webkit::npapi::WebPluginInfo::EnabledStates enabled_state = |
| 566 | webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; |
| 567 | |
| 568 | // Enable the Native Client Plugin based on the command line. |
| 569 | if (ppapi_plugins_[i].path == naclPath) { |
| 570 | bool nacl_enabled = |
| 571 | CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableNaCl); |
| 572 | enabled_state = nacl_enabled ? |
| 573 | webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED : |
| 574 | webkit::npapi::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED; |
| 575 | } |
| 576 | info.enabled = enabled_state; |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 577 | |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 578 | webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 579 | } |
| 580 | } |
[email protected] | 634d23d | 2011-01-19 10:38:19 | [diff] [blame] | 581 | |
| 582 | #if defined(OS_LINUX) |
| 583 | // static |
| 584 | void PluginService::RegisterFilePathWatcher( |
| 585 | FilePathWatcher *watcher, |
| 586 | const FilePath& path, |
| 587 | FilePathWatcher::Delegate* delegate) { |
| 588 | bool result = watcher->Watch(path, delegate); |
| 589 | DCHECK(result); |
| 590 | } |
| 591 | #endif |