Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Side by Side Diff: content/browser/plugin_service.cc

Issue 7990005: Use a placeholder instead of the default plugin for missing plug-ins on Mac and Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 bool PluginService::GetPluginInfo(int render_process_id, 403 bool PluginService::GetPluginInfo(int render_process_id,
404 int render_view_id, 404 int render_view_id,
405 const content::ResourceContext& context, 405 const content::ResourceContext& context,
406 const GURL& url, 406 const GURL& url,
407 const GURL& page_url, 407 const GURL& page_url,
408 const std::string& mime_type, 408 const std::string& mime_type,
409 bool allow_wildcard, 409 bool allow_wildcard,
410 bool* use_stale, 410 bool* use_stale,
411 webkit::WebPluginInfo* info, 411 webkit::WebPluginInfo* info,
412 std::string* actual_mime_type) { 412 std::string* actual_mime_type) {
413 webkit::npapi::PluginList* plugin_list =
414 webkit::npapi::PluginList::Singleton();
415 // GetPluginInfoArray may need to load the plugins, so we need to be
416 // on the FILE thread.
417 DCHECK(use_stale || BrowserThread::CurrentlyOn(BrowserThread::FILE));
418 std::vector<webkit::WebPluginInfo> plugins; 413 std::vector<webkit::WebPluginInfo> plugins;
419 std::vector<std::string> mime_types; 414 std::vector<std::string> mime_types;
420 plugin_list->GetPluginInfoArray( 415 std::vector<bool> allowed;
421 url, mime_type, allow_wildcard, use_stale, &plugins, &mime_types); 416 GetMatchingPlugins(
422 if (plugins.size() > 1 && 417 render_process_id, render_view_id, context, url, page_url, mime_type,
423 plugins.back().path == 418 allow_wildcard, use_stale, &plugins, &mime_types, &allowed);
424 FilePath(webkit::npapi::kDefaultPluginLibraryName)) {
425 // If there is at least one plug-in handling the required MIME type (apart
426 // from the default plug-in), we don't need the default plug-in.
427 plugins.pop_back();
428 }
429
430 for (size_t i = 0; i < plugins.size(); ++i) { 419 for (size_t i = 0; i < plugins.size(); ++i) {
431 if (!filter_ || filter_->ShouldUsePlugin(render_process_id, 420 if (allowed[i]) {
432 render_view_id,
433 &context,
434 url,
435 page_url,
436 &plugins[i])) {
437 *info = plugins[i]; 421 *info = plugins[i];
438 if (actual_mime_type) 422 if (actual_mime_type)
439 *actual_mime_type = mime_types[i]; 423 *actual_mime_type = mime_types[i];
440 return true; 424 return true;
441 } 425 }
442 } 426 }
443 return false; 427 return false;
444 } 428 }
445 429
430 void PluginService::GetMatchingPlugins(
431 int render_process_id,
432 int render_view_id,
433 const content::ResourceContext& context,
434 const GURL& url,
435 const GURL& page_url,
436 const std::string& mime_type,
437 bool allow_wildcard,
438 bool* use_stale,
439 std::vector<webkit::WebPluginInfo>* plugins,
440 std::vector<std::string>* mime_types,
441 std::vector<bool>* allowed) {
442 webkit::npapi::PluginList* plugin_list =
443 webkit::npapi::PluginList::Singleton();
444 // GetPluginInfoArray may need to load the plugins, so we need to be
445 // on the FILE thread.
446 DCHECK(use_stale || BrowserThread::CurrentlyOn(BrowserThread::FILE));
447 plugin_list->GetPluginInfoArray(
448 url, mime_type, allow_wildcard, use_stale, plugins, mime_types);
449 if (plugins->size() > 1 &&
450 plugins->back().path ==
451 FilePath(webkit::npapi::kDefaultPluginLibraryName)) {
452 // If there is at least one plug-in handling the required MIME type (apart
453 // from the default plug-in), we don't need the default plug-in.
454 plugins->pop_back();
455 }
456
457 for (size_t i = 0; i < plugins->size(); ++i) {
458 bool plugin_allowed = true;
459 if (filter_) {
460 plugin_allowed = filter_->ShouldUsePlugin(render_process_id,
461 render_view_id,
462 &context,
463 url,
464 page_url,
465 &(*plugins)[i]);
466 }
467 allowed->push_back(plugin_allowed);
468 }
469 }
470
446 void PluginService::RefreshPluginList() { 471 void PluginService::RefreshPluginList() {
447 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); 472 webkit::npapi::PluginList::Singleton()->RefreshPlugins();
448 } 473 }
449 474
450 void PluginService::GetPlugins(const GetPluginsCallback& callback) { 475 void PluginService::GetPlugins(const GetPluginsCallback& callback) {
451 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 476 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
452 base::Bind(&PluginService::GetPluginsInternal, base::Unretained(this), 477 base::Bind(&PluginService::GetPluginsInternal, base::Unretained(this),
453 MessageLoop::current()->message_loop_proxy(), 478 MessageLoop::current()->message_loop_proxy(),
454 callback)); 479 callback));
455 } 480 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 #if defined(OS_POSIX) && !defined(OS_MACOSX) 572 #if defined(OS_POSIX) && !defined(OS_MACOSX)
548 // static 573 // static
549 void PluginService::RegisterFilePathWatcher( 574 void PluginService::RegisterFilePathWatcher(
550 FilePathWatcher *watcher, 575 FilePathWatcher *watcher,
551 const FilePath& path, 576 const FilePath& path,
552 FilePathWatcher::Delegate* delegate) { 577 FilePathWatcher::Delegate* delegate) {
553 bool result = watcher->Watch(path, delegate); 578 bool result = watcher->Watch(path, delegate);
554 DCHECK(result); 579 DCHECK(result);
555 } 580 }
556 #endif 581 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698