| Index: content/browser/plugin_service.cc
 | 
| diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
 | 
| index 154d0629103c353424865c234c686c9d6053cb4a..587d79e302a21ed67fde6118276f4bd581666f01 100644
 | 
| --- a/content/browser/plugin_service.cc
 | 
| +++ b/content/browser/plugin_service.cc
 | 
| @@ -8,6 +8,7 @@
 | 
|  
 | 
|  #include "base/command_line.h"
 | 
|  #include "base/compiler_specific.h"
 | 
| +#include "base/file_path.h"
 | 
|  #include "base/path_service.h"
 | 
|  #include "base/string_util.h"
 | 
|  #include "base/synchronization/waitable_event.h"
 | 
| @@ -16,6 +17,7 @@
 | 
|  #include "base/values.h"
 | 
|  #include "content/browser/browser_thread.h"
 | 
|  #include "content/browser/content_browser_client.h"
 | 
| +#include "content/browser/plugin_filter.h"
 | 
|  #include "content/browser/ppapi_plugin_process_host.h"
 | 
|  #include "content/browser/renderer_host/render_process_host.h"
 | 
|  #include "content/browser/renderer_host/render_view_host.h"
 | 
| @@ -134,11 +136,6 @@ PluginService::PluginService()
 | 
|      file_watchers_.push_back(watcher);
 | 
|    }
 | 
|  #endif
 | 
| -  registrar_.Add(this, content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
 | 
| -                 NotificationService::AllSources());
 | 
| -  registrar_.Add(this,
 | 
| -                 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
 | 
| -                 NotificationService::AllSources());
 | 
|  }
 | 
|  
 | 
|  PluginService::~PluginService() {
 | 
| @@ -280,15 +277,21 @@ void PluginService::OpenChannelToNpapiPlugin(
 | 
|      int render_process_id,
 | 
|      int render_view_id,
 | 
|      const GURL& url,
 | 
| +    const GURL& page_url,
 | 
|      const std::string& mime_type,
 | 
|      PluginProcessHost::Client* client) {
 | 
| +  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
 | 
| +  PluginFilter* filter =
 | 
| +      content::GetContentClient()->browser()->CreatePluginFilter(
 | 
| +          render_process_id, render_view_id, *client->GetResourceContext(),
 | 
| +          url, page_url);
 | 
|    // The PluginList::GetPluginInfo may need to load the plugins.  Don't do it on
 | 
|    // the IO thread.
 | 
|    BrowserThread::PostTask(
 | 
|        BrowserThread::FILE, FROM_HERE,
 | 
|        NewRunnableMethod(
 | 
|            this, &PluginService::GetAllowedPluginForOpenChannelToPlugin,
 | 
| -          render_process_id, render_view_id, url, mime_type, client));
 | 
| +          url, mime_type, filter, client));
 | 
|  }
 | 
|  
 | 
|  void PluginService::OpenChannelToPpapiPlugin(
 | 
| @@ -313,18 +316,18 @@ void PluginService::OpenChannelToPpapiBroker(
 | 
|  }
 | 
|  
 | 
|  void PluginService::GetAllowedPluginForOpenChannelToPlugin(
 | 
| -    int render_process_id,
 | 
| -    int render_view_id,
 | 
|      const GURL& url,
 | 
|      const std::string& mime_type,
 | 
| +    PluginFilter* filter,
 | 
|      PluginProcessHost::Client* client) {
 | 
|    DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
 | 
|    webkit::npapi::WebPluginInfo info;
 | 
| -  bool found = GetPluginInfo(
 | 
| -      render_process_id, render_view_id, url, mime_type, &info, NULL);
 | 
| +  bool allow_wildcard = true;
 | 
| +  bool found = GetPluginInfo(url, mime_type, allow_wildcard, filter,
 | 
| +                             NULL, &info, NULL);
 | 
|    FilePath plugin_path;
 | 
|    if (found)
 | 
| -    plugin_path = FilePath(info.path);
 | 
| +    plugin_path = info.path;
 | 
|  
 | 
|    // Now we jump back to the IO thread to finish opening the channel.
 | 
|    BrowserThread::PostTask(
 | 
| @@ -346,35 +349,26 @@ void PluginService::FinishOpenChannelToPlugin(
 | 
|      client->OnError();
 | 
|  }
 | 
|  
 | 
| -bool PluginService::GetPluginInfo(int render_process_id,
 | 
| -                                  int render_view_id,
 | 
| -                                  const GURL& url,
 | 
| -                                  const std::string& mime_type,
 | 
| -                                  webkit::npapi::WebPluginInfo* info,
 | 
| -                                  std::string* actual_mime_type) {
 | 
| +bool PluginService::GetPluginInfo(
 | 
| +    const GURL& url,
 | 
| +    const std::string& mime_type,
 | 
| +    bool allow_wildcard,
 | 
| +    PluginFilter* filter,
 | 
| +    bool* use_stale,
 | 
| +    webkit::npapi::WebPluginInfo* info,
 | 
| +    std::string* actual_mime_type) {
 | 
| +  scoped_ptr<PluginFilter> owned_filter(filter);
 | 
| +  webkit::npapi::PluginList* plugin_list =
 | 
| +      webkit::npapi::PluginList::Singleton();
 | 
|    // GetPluginInfoArray may need to load the plugins, so we need to be
 | 
|    // on the FILE thread.
 | 
| -  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
 | 
| -  {
 | 
| -    base::AutoLock auto_lock(overridden_plugins_lock_);
 | 
| -    for (size_t i = 0; i < overridden_plugins_.size(); ++i) {
 | 
| -      if (overridden_plugins_[i].render_process_id == render_process_id &&
 | 
| -          overridden_plugins_[i].render_view_id == render_view_id &&
 | 
| -          overridden_plugins_[i].url == url) {
 | 
| -        if (actual_mime_type)
 | 
| -          *actual_mime_type = mime_type;
 | 
| -        *info = overridden_plugins_[i].plugin;
 | 
| -        return true;
 | 
| -      }
 | 
| -    }
 | 
| -  }
 | 
| -  bool allow_wildcard = true;
 | 
| +  DCHECK(use_stale || BrowserThread::CurrentlyOn(BrowserThread::FILE));
 | 
|    std::vector<webkit::npapi::WebPluginInfo> plugins;
 | 
|    std::vector<std::string> mime_types;
 | 
| -  webkit::npapi::PluginList::Singleton()->GetPluginInfoArray(
 | 
| -      url, mime_type, allow_wildcard, NULL, &plugins, &mime_types);
 | 
| +  plugin_list->GetPluginInfoArray(
 | 
| +      url, mime_type, allow_wildcard, use_stale, &plugins, &mime_types);
 | 
|    for (size_t i = 0; i < plugins.size(); ++i) {
 | 
| -    if (webkit::npapi::IsPluginEnabled(plugins[i])) {
 | 
| +    if (filter->ShouldUsePlugin(&plugins[i])) {
 | 
|        *info = plugins[i];
 | 
|        if (actual_mime_type)
 | 
|          *actual_mime_type = mime_types[i];
 | 
| @@ -384,6 +378,23 @@ bool PluginService::GetPluginInfo(int render_process_id,
 | 
|    return false;
 | 
|  }
 | 
|  
 | 
| +void PluginService::GetPlugins(
 | 
| +    PluginFilter* filter,
 | 
| +    std::vector<webkit::npapi::WebPluginInfo>* plugins) {
 | 
| +  scoped_ptr<PluginFilter> owned_filter(filter);
 | 
| +  webkit::npapi::PluginList* plugin_list =
 | 
| +      webkit::npapi::PluginList::Singleton();
 | 
| +  // GetPluginInfoArray may need to load the plugins, so we need to be
 | 
| +  // on the FILE thread.
 | 
| +  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
 | 
| +  std::vector<webkit::npapi::WebPluginInfo> all_plugins;
 | 
| +  plugin_list->GetPlugins(&all_plugins);
 | 
| +  for (size_t i = 0; i < all_plugins.size(); ++i) {
 | 
| +    if (filter->ShouldUsePlugin(&all_plugins[i]))
 | 
| +      plugins->push_back(all_plugins[i]);
 | 
| +  }
 | 
| +}
 | 
| +
 | 
|  void PluginService::OnWaitableEventSignaled(
 | 
|      base::WaitableEvent* waitable_event) {
 | 
|  #if defined(OS_WIN)
 | 
| @@ -404,40 +415,14 @@ void PluginService::OnWaitableEventSignaled(
 | 
|  void PluginService::Observe(int type,
 | 
|                              const NotificationSource& source,
 | 
|                              const NotificationDetails& details) {
 | 
| -  switch (type) {
 | 
|  #if defined(OS_MACOSX)
 | 
| -    case content::NOTIFICATION_APP_ACTIVATED: {
 | 
| -      BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
 | 
| -                              NewRunnableFunction(&NotifyPluginsOfActivation));
 | 
| -      break;
 | 
| -    }
 | 
| -#endif
 | 
| -
 | 
| -    case content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED: {
 | 
| -      webkit::npapi::PluginList::Singleton()->RefreshPlugins();
 | 
| -      PurgePluginListCache(false);
 | 
| -      break;
 | 
| -    }
 | 
| -    case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
 | 
| -      int render_process_id = Source<RenderProcessHost>(source).ptr()->id();
 | 
| -
 | 
| -      base::AutoLock auto_lock(overridden_plugins_lock_);
 | 
| -      for (size_t i = 0; i < overridden_plugins_.size(); ++i) {
 | 
| -        if (overridden_plugins_[i].render_process_id == render_process_id) {
 | 
| -          overridden_plugins_.erase(overridden_plugins_.begin() + i);
 | 
| -          break;
 | 
| -        }
 | 
| -      }
 | 
| -      break;
 | 
| -    }
 | 
| -    default:
 | 
| -      NOTREACHED();
 | 
| +  if (type == content::NOTIFICATION_APP_ACTIVATED) {
 | 
| +    BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
 | 
| +                            NewRunnableFunction(&NotifyPluginsOfActivation));
 | 
| +    return;
 | 
|    }
 | 
| -}
 | 
| -
 | 
| -void PluginService::OverridePluginForTab(const OverriddenPlugin& plugin) {
 | 
| -  base::AutoLock auto_lock(overridden_plugins_lock_);
 | 
| -  overridden_plugins_.push_back(plugin);
 | 
| +#endif
 | 
| +  NOTREACHED();
 | 
|  }
 | 
|  
 | 
|  void PluginService::PurgePluginListCache(bool reload_pages) {
 | 
| @@ -447,32 +432,6 @@ void PluginService::PurgePluginListCache(bool reload_pages) {
 | 
|    }
 | 
|  }
 | 
|  
 | 
| -void PluginService::RestrictPluginToUrl(const FilePath& plugin_path,
 | 
| -                                        const GURL& url) {
 | 
| -  base::AutoLock auto_lock(restricted_plugin_lock_);
 | 
| -  if (url.is_empty()) {
 | 
| -    restricted_plugin_.erase(plugin_path);
 | 
| -  } else {
 | 
| -    restricted_plugin_[plugin_path] = url;
 | 
| -  }
 | 
| -}
 | 
| -
 | 
| -bool PluginService::PluginAllowedForURL(const FilePath& plugin_path,
 | 
| -                                        const GURL& url) {
 | 
| -  if (url.is_empty())
 | 
| -    return true;  // Caller wants all plugins.
 | 
| -
 | 
| -  base::AutoLock auto_lock(restricted_plugin_lock_);
 | 
| -
 | 
| -  RestrictedPluginMap::iterator it = restricted_plugin_.find(plugin_path);
 | 
| -  if (it == restricted_plugin_.end())
 | 
| -    return true;  // This plugin is not restricted, so it's allowed everywhere.
 | 
| -
 | 
| -  const GURL& required_url = it->second;
 | 
| -  return (url.scheme() == required_url.scheme() &&
 | 
| -          url.host() == required_url.host());
 | 
| -}
 | 
| -
 | 
|  void PluginService::RegisterPepperPlugins() {
 | 
|    // TODO(abarth): It seems like the PepperPluginRegistry should do this work.
 | 
|    PepperPluginRegistry::ComputeList(&ppapi_plugins_);
 | 
| 
 |