Index: content/browser/plugin_service.cc |
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc |
index b59c64e2287a3d0c5518d7a5de35c613f835fb65..a184e51a2ec7a6c4f50fbc36f71acbe7f6b5277a 100644 |
--- a/content/browser/plugin_service.cc |
+++ b/content/browser/plugin_service.cc |
@@ -112,11 +112,15 @@ PluginService* PluginService::GetInstance() { |
return Singleton<PluginService>::get(); |
} |
-PluginService::PluginService() |
- : ui_locale_( |
+PluginService::PluginService(webkit::npapi::PluginList* plugin_list) |
+ : plugin_list_(plugin_list), |
+ ui_locale_( |
content::GetContentClient()->browser()->GetApplicationLocale()), |
filter_(NULL) { |
- webkit::npapi::PluginList::Singleton()->set_will_load_plugins_callback( |
+ if (!plugin_list_) |
+ plugin_list_ = webkit::npapi::PluginList::Singleton(); |
+ |
+ plugin_list_->set_will_load_plugins_callback( |
base::Bind(&WillLoadPluginsCallback)); |
RegisterPepperPlugins(); |
@@ -125,10 +129,10 @@ PluginService::PluginService() |
const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
FilePath path = command_line->GetSwitchValuePath(switches::kLoadPlugin); |
if (!path.empty()) |
- webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path); |
+ plugin_list_->AddExtraPluginPath(path); |
path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); |
if (!path.empty()) |
- webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(path); |
+ plugin_list_->AddExtraPluginDir(path); |
#if defined(OS_MACOSX) |
// We need to know when the browser comes forward so we can bring modal plugin |
@@ -182,8 +186,7 @@ void PluginService::StartWatchingPlugins() { |
// Get the list of all paths for registering the FilePathWatchers |
// that will track and if needed reload the list of plugins on runtime. |
std::vector<FilePath> plugin_dirs; |
- webkit::npapi::PluginList::Singleton()->GetPluginDirectories( |
- &plugin_dirs); |
+ plugin_list_->GetPluginDirectories(&plugin_dirs); |
for (size_t i = 0; i < plugin_dirs.size(); ++i) { |
// FilePathWatcher can not handle non-absolute paths under windows. |
@@ -428,7 +431,7 @@ bool PluginService::GetPluginInfoArray( |
std::vector<webkit::WebPluginInfo>* plugins, |
std::vector<std::string>* actual_mime_types) { |
bool use_stale = false; |
- webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( |
+ plugin_list_->GetPluginInfoArray( |
url, mime_type, allow_wildcard, &use_stale, plugins, actual_mime_types); |
return use_stale; |
} |
@@ -476,8 +479,7 @@ bool PluginService::GetPluginInfo(int render_process_id, |
bool PluginService::GetPluginInfoByPath(const FilePath& plugin_path, |
webkit::WebPluginInfo* info) { |
std::vector<webkit::WebPluginInfo> plugins; |
- webkit::npapi::PluginList::Singleton()->GetPluginsIfNoRefreshNeeded( |
- &plugins); |
+ plugin_list_->GetPluginsIfNoRefreshNeeded(&plugins); |
for (std::vector<webkit::WebPluginInfo>::iterator it = plugins.begin(); |
it != plugins.end(); |
@@ -492,7 +494,7 @@ bool PluginService::GetPluginInfoByPath(const FilePath& plugin_path, |
} |
void PluginService::RefreshPluginList() { |
- webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
+ plugin_list_->RefreshPlugins(); |
} |
void PluginService::GetPlugins(const GetPluginsCallback& callback) { |
@@ -505,8 +507,7 @@ void PluginService::GetPlugins(const GetPluginsCallback& callback) { |
target_loop, callback)); |
#else |
std::vector<webkit::WebPluginInfo> cached_plugins; |
- if (webkit::npapi::PluginList::Singleton()->GetPluginsIfNoRefreshNeeded( |
- &cached_plugins)) { |
+ if (plugin_list_->GetPluginsIfNoRefreshNeeded(&cached_plugins)) { |
// Can't assume the caller is reentrant. |
target_loop->PostTask(FROM_HERE, |
base::Bind(&RunGetPluginsCallback, callback, cached_plugins)); |
@@ -532,7 +533,7 @@ void PluginService::GetPluginsInternal( |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
std::vector<webkit::WebPluginInfo> plugins; |
- webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); |
+ plugin_list_->GetPlugins(&plugins); |
target_loop->PostTask(FROM_HERE, |
base::Bind(&RunGetPluginsCallback, callback, plugins)); |
@@ -547,7 +548,7 @@ void PluginService::OnWaitableEventSignaled( |
hklm_key_.StartWatching(); |
} |
- webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
+ plugin_list_->RefreshPlugins(); |
PurgePluginListCache(NULL, false); |
#else |
// This event should only get signaled on a Windows machine. |
@@ -583,8 +584,7 @@ void PluginService::RegisterPepperPlugins() { |
// TODO(abarth): It seems like the PepperPluginRegistry should do this work. |
PepperPluginRegistry::ComputeList(&ppapi_plugins_); |
for (size_t i = 0; i < ppapi_plugins_.size(); ++i) { |
- webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( |
- ppapi_plugins_[i].ToWebPluginInfo()); |
+ plugin_list_->RegisterInternalPlugin(ppapi_plugins_[i].ToWebPluginInfo()); |
} |
} |