OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/plugin_service.h" | 5 #include "content/browser/plugin_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/browser/renderer_host/render_view_host.h" | 21 #include "content/browser/renderer_host/render_view_host.h" |
22 #include "content/browser/resource_context.h" | 22 #include "content/browser/resource_context.h" |
23 #include "content/common/content_notification_types.h" | 23 #include "content/common/content_notification_types.h" |
24 #include "content/common/content_switches.h" | 24 #include "content/common/content_switches.h" |
25 #include "content/common/notification_service.h" | 25 #include "content/common/notification_service.h" |
26 #include "content/common/pepper_plugin_registry.h" | 26 #include "content/common/pepper_plugin_registry.h" |
27 #include "content/common/plugin_messages.h" | 27 #include "content/common/plugin_messages.h" |
28 #include "content/common/view_messages.h" | 28 #include "content/common/view_messages.h" |
29 #include "webkit/plugins/npapi/plugin_constants_win.h" | 29 #include "webkit/plugins/npapi/plugin_constants_win.h" |
30 #include "webkit/plugins/npapi/plugin_list.h" | 30 #include "webkit/plugins/npapi/plugin_list.h" |
31 #include "webkit/plugins/npapi/webplugininfo.h" | 31 #include "webkit/plugins/webplugininfo.h" |
32 | 32 |
33 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 33 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
34 using ::base::files::FilePathWatcher; | 34 using ::base::files::FilePathWatcher; |
35 #endif | 35 #endif |
36 | 36 |
37 #if defined(OS_MACOSX) | 37 #if defined(OS_MACOSX) |
38 static void NotifyPluginsOfActivation() { | 38 static void NotifyPluginsOfActivation() { |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
40 | 40 |
41 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); | 41 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 PluginProcessHost* PluginService::FindOrStartNpapiPluginProcess( | 206 PluginProcessHost* PluginService::FindOrStartNpapiPluginProcess( |
207 const FilePath& plugin_path) { | 207 const FilePath& plugin_path) { |
208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
209 | 209 |
210 PluginProcessHost* plugin_host = FindNpapiPluginProcess(plugin_path); | 210 PluginProcessHost* plugin_host = FindNpapiPluginProcess(plugin_path); |
211 if (plugin_host) | 211 if (plugin_host) |
212 return plugin_host; | 212 return plugin_host; |
213 | 213 |
214 webkit::npapi::WebPluginInfo info; | 214 webkit::WebPluginInfo info; |
215 if (!webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( | 215 if (!webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( |
216 plugin_path, &info)) { | 216 plugin_path, &info)) { |
217 return NULL; | 217 return NULL; |
218 } | 218 } |
219 | 219 |
220 // This plugin isn't loaded by any plugin process, so create a new process. | 220 // This plugin isn't loaded by any plugin process, so create a new process. |
221 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); | 221 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); |
222 if (!new_host->Init(info, ui_locale_)) { | 222 if (!new_host->Init(info, ui_locale_)) { |
223 NOTREACHED(); // Init is not expected to fail. | 223 NOTREACHED(); // Init is not expected to fail. |
224 return NULL; | 224 return NULL; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle()); | 312 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle()); |
313 } | 313 } |
314 | 314 |
315 void PluginService::GetAllowedPluginForOpenChannelToPlugin( | 315 void PluginService::GetAllowedPluginForOpenChannelToPlugin( |
316 int render_process_id, | 316 int render_process_id, |
317 int render_view_id, | 317 int render_view_id, |
318 const GURL& url, | 318 const GURL& url, |
319 const std::string& mime_type, | 319 const std::string& mime_type, |
320 PluginProcessHost::Client* client) { | 320 PluginProcessHost::Client* client) { |
321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
322 webkit::npapi::WebPluginInfo info; | 322 webkit::WebPluginInfo info; |
323 bool found = GetPluginInfo( | 323 bool found = GetPluginInfo( |
324 render_process_id, render_view_id, url, mime_type, &info, NULL); | 324 render_process_id, render_view_id, url, mime_type, &info, NULL); |
325 FilePath plugin_path; | 325 FilePath plugin_path; |
326 if (found) | 326 if (found) |
327 plugin_path = FilePath(info.path); | 327 plugin_path = FilePath(info.path); |
328 | 328 |
329 // Now we jump back to the IO thread to finish opening the channel. | 329 // Now we jump back to the IO thread to finish opening the channel. |
330 BrowserThread::PostTask( | 330 BrowserThread::PostTask( |
331 BrowserThread::IO, FROM_HERE, | 331 BrowserThread::IO, FROM_HERE, |
332 NewRunnableMethod( | 332 NewRunnableMethod( |
(...skipping 10 matching lines...) Expand all Loading... |
343 if (plugin_host) | 343 if (plugin_host) |
344 plugin_host->OpenChannelToPlugin(client); | 344 plugin_host->OpenChannelToPlugin(client); |
345 else | 345 else |
346 client->OnError(); | 346 client->OnError(); |
347 } | 347 } |
348 | 348 |
349 bool PluginService::GetPluginInfo(int render_process_id, | 349 bool PluginService::GetPluginInfo(int render_process_id, |
350 int render_view_id, | 350 int render_view_id, |
351 const GURL& url, | 351 const GURL& url, |
352 const std::string& mime_type, | 352 const std::string& mime_type, |
353 webkit::npapi::WebPluginInfo* info, | 353 webkit::WebPluginInfo* info, |
354 std::string* actual_mime_type) { | 354 std::string* actual_mime_type) { |
355 // GetPluginInfoArray may need to load the plugins, so we need to be | 355 // GetPluginInfoArray may need to load the plugins, so we need to be |
356 // on the FILE thread. | 356 // on the FILE thread. |
357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
358 { | 358 { |
359 base::AutoLock auto_lock(overridden_plugins_lock_); | 359 base::AutoLock auto_lock(overridden_plugins_lock_); |
360 for (size_t i = 0; i < overridden_plugins_.size(); ++i) { | 360 for (size_t i = 0; i < overridden_plugins_.size(); ++i) { |
361 if (overridden_plugins_[i].render_process_id == render_process_id && | 361 if (overridden_plugins_[i].render_process_id == render_process_id && |
362 overridden_plugins_[i].render_view_id == render_view_id && | 362 overridden_plugins_[i].render_view_id == render_view_id && |
363 overridden_plugins_[i].url == url) { | 363 overridden_plugins_[i].url == url) { |
364 if (actual_mime_type) | 364 if (actual_mime_type) |
365 *actual_mime_type = mime_type; | 365 *actual_mime_type = mime_type; |
366 *info = overridden_plugins_[i].plugin; | 366 *info = overridden_plugins_[i].plugin; |
367 return true; | 367 return true; |
368 } | 368 } |
369 } | 369 } |
370 } | 370 } |
371 bool allow_wildcard = true; | 371 bool allow_wildcard = true; |
372 std::vector<webkit::npapi::WebPluginInfo> plugins; | 372 std::vector<webkit::WebPluginInfo> plugins; |
373 std::vector<std::string> mime_types; | 373 std::vector<std::string> mime_types; |
374 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( | 374 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( |
375 url, mime_type, allow_wildcard, NULL, &plugins, &mime_types); | 375 url, mime_type, allow_wildcard, NULL, &plugins, &mime_types); |
376 for (size_t i = 0; i < plugins.size(); ++i) { | 376 for (size_t i = 0; i < plugins.size(); ++i) { |
377 if (webkit::npapi::IsPluginEnabled(plugins[i])) { | 377 if (webkit::IsPluginEnabled(plugins[i])) { |
378 *info = plugins[i]; | 378 *info = plugins[i]; |
379 if (actual_mime_type) | 379 if (actual_mime_type) |
380 *actual_mime_type = mime_types[i]; | 380 *actual_mime_type = mime_types[i]; |
381 return true; | 381 return true; |
382 } | 382 } |
383 } | 383 } |
384 return false; | 384 return false; |
385 } | 385 } |
386 | 386 |
387 void PluginService::OnWaitableEventSignaled( | 387 void PluginService::OnWaitableEventSignaled( |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 498 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
499 // static | 499 // static |
500 void PluginService::RegisterFilePathWatcher( | 500 void PluginService::RegisterFilePathWatcher( |
501 FilePathWatcher *watcher, | 501 FilePathWatcher *watcher, |
502 const FilePath& path, | 502 const FilePath& path, |
503 FilePathWatcher::Delegate* delegate) { | 503 FilePathWatcher::Delegate* delegate) { |
504 bool result = watcher->Watch(path, delegate); | 504 bool result = watcher->Watch(path, delegate); |
505 DCHECK(result); | 505 DCHECK(result); |
506 } | 506 } |
507 #endif | 507 #endif |
OLD | NEW |