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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 return plugin; | 219 return plugin; |
220 } | 220 } |
221 | 221 |
222 return NULL; | 222 return NULL; |
223 } | 223 } |
224 | 224 |
225 PluginProcessHost* PluginService::FindOrStartPluginProcess( | 225 PluginProcessHost* PluginService::FindOrStartPluginProcess( |
226 const FilePath& plugin_path) { | 226 const FilePath& plugin_path) { |
227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
228 | 228 |
229 PluginProcessHost *plugin_host = FindPluginProcess(plugin_path); | 229 if (plugin_path.value().empty()) |
jam
2010/11/12 20:44:58
curious, any reason to change this logic? it seem
| |
230 return NULL; | |
231 | |
232 PluginProcessHost* plugin_host = FindPluginProcess(plugin_path); | |
230 if (plugin_host) | 233 if (plugin_host) |
231 return plugin_host; | 234 return plugin_host; |
232 | 235 |
233 WebPluginInfo info; | 236 WebPluginInfo info; |
234 if (!NPAPI::PluginList::Singleton()->GetPluginInfoByPath( | 237 if (!NPAPI::PluginList::Singleton()->GetPluginInfoByPath( |
235 plugin_path, &info)) { | 238 plugin_path, &info)) { |
236 DCHECK(false); | 239 NOTREACHED(); |
237 return NULL; | 240 return NULL; |
238 } | 241 } |
239 | 242 |
240 // This plugin isn't loaded by any plugin process, so create a new process. | 243 // This plugin isn't loaded by any plugin process, so create a new process. |
241 plugin_host = new PluginProcessHost(); | 244 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); |
242 if (!plugin_host->Init(info, ui_locale_)) { | 245 if (!new_host->Init(info, ui_locale_)) { |
243 DCHECK(false); // Init is not expected to fail | 246 NOTREACHED(); // Init is not expected to fail |
244 delete plugin_host; | |
245 return NULL; | 247 return NULL; |
246 } | 248 } |
247 | 249 |
248 return plugin_host; | 250 return new_host.release(); |
249 } | 251 } |
250 | 252 |
251 void PluginService::OpenChannelToPlugin( | 253 void PluginService::OpenChannelToPlugin( |
252 const GURL& url, | 254 const GURL& url, |
253 const std::string& mime_type, | 255 const std::string& mime_type, |
254 PluginProcessHost::Client* client) { | 256 PluginProcessHost::Client* client) { |
255 // The PluginList::GetFirstAllowedPluginInfo may need to load the | 257 // The PluginList::GetFirstAllowedPluginInfo may need to load the |
256 // plugins. Don't do it on the IO thread. | 258 // plugins. Don't do it on the IO thread. |
257 BrowserThread::PostTask( | 259 BrowserThread::PostTask( |
258 BrowserThread::FILE, FROM_HERE, | 260 BrowserThread::FILE, FROM_HERE, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 info.mime_types = ASCIIToWide(JoinString(plugins[i].mime_types, '|')); | 440 info.mime_types = ASCIIToWide(JoinString(plugins[i].mime_types, '|')); |
439 | 441 |
440 // These NPAPI entry points will never be called. TODO(darin): Come up | 442 // These NPAPI entry points will never be called. TODO(darin): Come up |
441 // with a cleaner way to register pepper plugins with the NPAPI PluginList, | 443 // with a cleaner way to register pepper plugins with the NPAPI PluginList, |
442 // or perhaps refactor the PluginList to be less specific to NPAPI. | 444 // or perhaps refactor the PluginList to be less specific to NPAPI. |
443 memset(&info.entry_points, 0, sizeof(info.entry_points)); | 445 memset(&info.entry_points, 0, sizeof(info.entry_points)); |
444 | 446 |
445 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); | 447 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); |
446 } | 448 } |
447 } | 449 } |
OLD | NEW |