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

Unified Diff: content/browser/plugin_service.cc

Issue 8493019: Refactor PluginService to take PluginList as a dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Init() Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/plugin_service.cc
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index 5e0e910656076fa2394cec4f57f871b1f52a079b..a3054fe936dba1be00d09dc91465f416c3cf903f 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -109,13 +109,40 @@ class PluginDirWatcherDelegate : public FilePathWatcher::Delegate {
// static
PluginService* PluginService::GetInstance() {
- return Singleton<PluginService>::get();
+ PluginService* service = Singleton<PluginService>::get();
+ if (!service->did_init_)
jam 2011/11/08 23:12:57 we should know who creates this for the first time
+ service->Init();
+ return service;
}
PluginService::PluginService()
- : ui_locale_(
+ : did_init_(false),
+ plugin_list_(NULL),
+ ui_locale_(
content::GetContentClient()->browser()->GetApplicationLocale()),
filter_(NULL) {
+}
+
+PluginService::~PluginService() {
+#if defined(OS_WIN)
+ // Release the events since they're owned by RegKey, not WaitableEvent.
+ hkcu_watcher_.StopWatching();
+ hklm_watcher_.StopWatching();
+ if (hkcu_event_.get())
+ hkcu_event_->Release();
+ if (hklm_event_.get())
+ hklm_event_->Release();
+#endif
+ // Make sure no plugin channel requests have been leaked.
+ DCHECK(pending_plugin_clients_.empty());
+}
+
+void PluginService::Init() {
+ DCHECK(!did_init_);
+
+ if (!plugin_list_)
+ plugin_list_ = webkit::npapi::PluginList::Singleton();
+
plugin_list()->set_will_load_plugins_callback(
base::Bind(&WillLoadPluginsCallback));
@@ -138,20 +165,8 @@ PluginService::PluginService()
registrar_.Add(this, content::NOTIFICATION_APP_ACTIVATED,
content::NotificationService::AllSources());
#endif
-}
-PluginService::~PluginService() {
-#if defined(OS_WIN)
- // Release the events since they're owned by RegKey, not WaitableEvent.
- hkcu_watcher_.StopWatching();
- hklm_watcher_.StopWatching();
- if (hkcu_event_.get())
- hkcu_event_->Release();
- if (hklm_event_.get())
- hklm_event_->Release();
-#endif
- // Make sure no plugin channel requests have been leaked.
- DCHECK(pending_plugin_clients_.empty());
+ did_init_ = true;
}
void PluginService::StartWatchingPlugins() {
@@ -640,6 +655,11 @@ webkit::npapi::PluginList* PluginService::plugin_list() {
return webkit::npapi::PluginList::Singleton();
}
+void PluginService::SetPluginListForTesting(
+ webkit::npapi::PluginList* plugin_list) {
+ plugin_list_ = plugin_list;
+}
+
void PluginService::RegisterInternalPlugin(const webkit::WebPluginInfo& info) {
plugin_list()->RegisterInternalPlugin(info);
}

Powered by Google App Engine
This is Rietveld 408576698