summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/plugin_service.cc45
-rw-r--r--chrome/browser/plugin_service.h20
-rw-r--r--chrome/common/render_messages_internal.h3
-rw-r--r--chrome/renderer/render_thread.cc18
-rw-r--r--chrome/renderer/render_thread.h6
-rw-r--r--chrome/renderer/renderer_glue.cc6
6 files changed, 92 insertions, 6 deletions
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index d46a1d5..eb8ec2a 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -8,15 +8,17 @@
#include "base/command_line.h"
#include "base/thread.h"
+#include "base/waitable_event.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_plugin_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/plugin_process_host.h"
#include "chrome/browser/renderer_host/render_process_host.h"
-#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/common/chrome_plugin_lib.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/logging_chrome.h"
+#include "chrome/common/render_messages.h"
+#include "webkit/glue/plugins/plugin_constants_win.h"
#include "webkit/glue/plugins/plugin_list.h"
// static
@@ -35,9 +37,32 @@ PluginService::PluginService()
std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin);
if (!path.empty())
NPAPI::PluginList::AddExtraPluginPath(FilePath::FromWStringHack(path));
+
+#if defined(OS_WIN)
+ hkcu_key_.Create(
+ HKEY_CURRENT_USER, kRegistryMozillaPlugins, KEY_NOTIFY);
+ hklm_key_.Create(
+ HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, KEY_NOTIFY);
+ if (hkcu_key_.StartWatching()) {
+ hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event()));
+ hkcu_watcher_.StartWatching(hkcu_event_.get(), this);
+ }
+
+ if (hklm_key_.StartWatching()) {
+ hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event()));
+ hklm_watcher_.StartWatching(hklm_event_.get(), this);
+ }
+#endif
}
PluginService::~PluginService() {
+#if defined(OS_WIN)
+ // Release the events since they're owned by RegKey, not WaitableEvent.
+ hkcu_watcher_.StopWatching();
+ hklm_watcher_.StopWatching();
+ hkcu_event_->Release();
+ hklm_event_->Release();
+#endif
}
void PluginService::GetPlugins(bool refresh,
@@ -171,3 +196,21 @@ bool PluginService::HavePluginFor(const std::string& mime_type,
allow_wildcard, &info,
NULL);
}
+
+void PluginService::OnWaitableEventSignaled(base::WaitableEvent* waitable_event) {
+#if defined(OS_WIN)
+ if (waitable_event == hkcu_event_.get()) {
+ hkcu_key_.StartWatching();
+ } else {
+ hklm_key_.StartWatching();
+ }
+
+ AutoLock lock(lock_);
+ NPAPI::PluginList::ResetPluginsLoaded();
+
+ for (RenderProcessHost::iterator it = RenderProcessHost::begin();
+ it != RenderProcessHost::end(); ++it) {
+ it->second->Send(new ViewMsg_PurgePluginListCache());
+ }
+#endif
+}
diff --git a/chrome/browser/plugin_service.h b/chrome/browser/plugin_service.h
index d193cda..3c8adae 100644
--- a/chrome/browser/plugin_service.h
+++ b/chrome/browser/plugin_service.h
@@ -15,9 +15,14 @@
#include "base/lock.h"
#include "base/ref_counted.h"
#include "base/singleton.h"
+#include "base/waitable_event_watcher.h"
#include "chrome/browser/browser_process.h"
#include "webkit/glue/webplugin.h"
+#if defined(OS_WIN)
+#include "base/registry.h"
+#endif
+
namespace IPC {
class Message;
}
@@ -30,7 +35,7 @@ class ResourceMessageFilter;
// This can be called on the main thread and IO thread. However it must
// be created on the main thread.
-class PluginService {
+class PluginService : base::WaitableEventWatcher::Delegate {
public:
// Returns the PluginService singleton.
static PluginService* GetInstance();
@@ -109,6 +114,9 @@ class PluginService {
PluginService();
~PluginService();
+ // base::WaitableEventWatcher::Delegate implementation.
+ void OnWaitableEventSignaled(base::WaitableEvent* waitable_event);
+
// mapping between plugin path and PluginProcessHost
typedef base::hash_map<FilePath, PluginProcessHost*> PluginMap;
PluginMap plugin_hosts_;
@@ -129,6 +137,16 @@ class PluginService {
// webkit_glue since this class is called on the main and IO thread.
Lock lock_;
+#if defined(OS_WIN)
+ // Registry keys for getting notifications when new plugins are installed.
+ RegKey hkcu_key_;
+ RegKey hklm_key_;
+ scoped_ptr<base::WaitableEvent> hkcu_event_;
+ scoped_ptr<base::WaitableEvent> hklm_event_;
+ base::WaitableEventWatcher hkcu_watcher_;
+ base::WaitableEventWatcher hklm_watcher_;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(PluginService);
};
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 6bad5b23..2fdf5a9 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -382,6 +382,9 @@ IPC_BEGIN_MESSAGES(View)
// Install the first missing pluign.
IPC_MESSAGE_ROUTED0(ViewMsg_InstallMissingPlugin)
+ // Tells the renderer to empty its plugin list cache.
+ IPC_MESSAGE_CONTROL0(ViewMsg_PurgePluginListCache)
+
IPC_MESSAGE_ROUTED1(ViewMsg_RunFileChooserResponse,
std::vector<FilePath> /* selected files */)
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 6582be7..e372c2b 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -62,13 +62,15 @@ static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
RenderThread::RenderThread()
: ChildThread(
base::Thread::Options(RenderProcess::InProcessPlugins() ?
- MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)) {
+ MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)),
+ plugin_refresh_allowed_(true) {
}
RenderThread::RenderThread(const std::wstring& channel_name)
: ChildThread(
base::Thread::Options(RenderProcess::InProcessPlugins() ?
- MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)) {
+ MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kV8StackSize)),
+ plugin_refresh_allowed_(true) {
SetChannelName(channel_name);
}
@@ -197,6 +199,8 @@ void RenderThread::OnControlMessageReceived(const IPC::Message& msg) {
OnExtensionHandleEvent)
IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames,
OnSetExtensionFunctionNames)
+ IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache,
+ OnPurgePluginListCache)
IPC_END_MESSAGE_MAP()
}
@@ -335,3 +339,13 @@ void RenderThread::OnExtensionHandleEvent(const std::string event_name,
const std::string event_data) {
RendererExtensionBindings::HandleEvent(event_name, event_data);
}
+
+void RenderThread::OnPurgePluginListCache() {
+ // The call below will cause a GetPlugins call with refresh=true, but at this
+ // point we already know that the browser has refreshed its list, so disable
+ // refresh temporarily to prevent each renderer process causing the list to be
+ // regenerated.
+ plugin_refresh_allowed_ = false;
+ WebKit::resetPluginCache();
+ plugin_refresh_allowed_ = true;
+}
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index d57026e..d50fd96 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -91,6 +91,8 @@ class RenderThread : public RenderThreadBase,
return user_script_slave_.get();
}
+ bool plugin_refresh_allowed() const { return plugin_refresh_allowed_; }
+
// Do DNS prefetch resolution of a hostname.
void Resolve(const char* name, size_t length);
@@ -129,6 +131,7 @@ class RenderThread : public RenderThreadBase,
void OnExtensionHandleMessage(const std::string& message, int channel_id);
void OnExtensionHandleEvent(const std::string event_name,
const std::string event_data);
+ void OnPurgePluginListCache();
// Gather usage statistics from the in-memory cache and inform our host.
// These functions should be call periodically so that the host can make
@@ -157,6 +160,9 @@ class RenderThread : public RenderThreadBase,
scoped_refptr<DevToolsAgentFilter> devtools_agent_filter_;
+ // If true, then a GetPlugins call is allowed to rescan the disk.
+ bool plugin_refresh_allowed_;
+
DISALLOW_COPY_AND_ASSIGN(RenderThread);
};
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 68f4fce..b649629 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -215,8 +215,10 @@ std::string GetUIResourceProtocol() {
}
bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) {
- return RenderThread::current()->Send(
- new ViewHostMsg_GetPlugins(refresh, plugins));
+ if (!RenderThread::current()->plugin_refresh_allowed())
+ refresh = false;
+ return RenderThread::current()->Send(new ViewHostMsg_GetPlugins(
+ refresh, plugins));
}
// static factory function