| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::npapi::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 && webkit::npapi::IsPluginEnabled(info)) | 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( |
| 333 this, &PluginService::FinishOpenChannelToPlugin, | 333 this, &PluginService::FinishOpenChannelToPlugin, |
| 334 plugin_path, client)); | 334 plugin_path, client)); |
| 335 } | 335 } |
| 336 | 336 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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::npapi::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 bool allow_wildcard = true; | |
| 359 { | 358 { |
| 360 base::AutoLock auto_lock(overridden_plugins_lock_); | 359 base::AutoLock auto_lock(overridden_plugins_lock_); |
| 361 for (size_t i = 0; i < overridden_plugins_.size(); ++i) { | 360 for (size_t i = 0; i < overridden_plugins_.size(); ++i) { |
| 362 if (overridden_plugins_[i].render_process_id == render_process_id && | 361 if (overridden_plugins_[i].render_process_id == render_process_id && |
| 363 overridden_plugins_[i].render_view_id == render_view_id && | 362 overridden_plugins_[i].render_view_id == render_view_id && |
| 364 overridden_plugins_[i].url == url) { | 363 overridden_plugins_[i].url == url) { |
| 365 if (actual_mime_type) | 364 if (actual_mime_type) |
| 366 *actual_mime_type = mime_type; | 365 *actual_mime_type = mime_type; |
| 367 *info = overridden_plugins_[i].plugin; | 366 *info = overridden_plugins_[i].plugin; |
| 368 return true; | 367 return true; |
| 369 } | 368 } |
| 370 } | 369 } |
| 371 } | 370 } |
| 372 return webkit::npapi::PluginList::Singleton()->GetPluginInfo( | 371 bool allow_wildcard = true; |
| 373 url, mime_type, allow_wildcard, info, actual_mime_type); | 372 std::vector<webkit::npapi::WebPluginInfo> plugins; |
| 373 std::vector<std::string> mime_types; |
| 374 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( |
| 375 url, mime_type, allow_wildcard, NULL, &plugins, &mime_types); |
| 376 for (size_t i = 0; i < plugins.size(); ++i) { |
| 377 if (webkit::npapi::IsPluginEnabled(plugins[i])) { |
| 378 *info = plugins[i]; |
| 379 if (actual_mime_type) |
| 380 *actual_mime_type = mime_types[i]; |
| 381 return true; |
| 382 } |
| 383 } |
| 384 return false; |
| 374 } | 385 } |
| 375 | 386 |
| 376 void PluginService::OnWaitableEventSignaled( | 387 void PluginService::OnWaitableEventSignaled( |
| 377 base::WaitableEvent* waitable_event) { | 388 base::WaitableEvent* waitable_event) { |
| 378 #if defined(OS_WIN) | 389 #if defined(OS_WIN) |
| 379 if (waitable_event == hkcu_event_.get()) { | 390 if (waitable_event == hkcu_event_.get()) { |
| 380 hkcu_key_.StartWatching(); | 391 hkcu_key_.StartWatching(); |
| 381 } else { | 392 } else { |
| 382 hklm_key_.StartWatching(); | 393 hklm_key_.StartWatching(); |
| 383 } | 394 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 498 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 488 // static | 499 // static |
| 489 void PluginService::RegisterFilePathWatcher( | 500 void PluginService::RegisterFilePathWatcher( |
| 490 FilePathWatcher *watcher, | 501 FilePathWatcher *watcher, |
| 491 const FilePath& path, | 502 const FilePath& path, |
| 492 FilePathWatcher::Delegate* delegate) { | 503 FilePathWatcher::Delegate* delegate) { |
| 493 bool result = watcher->Watch(path, delegate); | 504 bool result = watcher->Watch(path, delegate); |
| 494 DCHECK(result); | 505 DCHECK(result); |
| 495 } | 506 } |
| 496 #endif | 507 #endif |
| OLD | NEW |