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

Unified Diff: content/browser/plugin_data_remover_impl.cc

Issue 9981015: Add an interface for Flash to clear its data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/plugin_data_remover_impl.cc
diff --git a/content/browser/plugin_data_remover_impl.cc b/content/browser/plugin_data_remover_impl.cc
index e4d9bb480b37d10733ca147f8d5158adbcd2212e..7ede463d8d5096e49acd37dff734911c1a5abeed 100644
--- a/content/browser/plugin_data_remover_impl.cc
+++ b/content/browser/plugin_data_remover_impl.cc
@@ -13,6 +13,8 @@
#include "content/common/child_process_host_impl.h"
#include "content/common/plugin_messages.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/common/pepper_plugin_info.h"
+#include "ppapi/proxy/ppapi_messages.h"
#include "webkit/plugins/npapi/plugin_group.h"
using content::BrowserThread;
@@ -55,10 +57,11 @@ bool PluginDataRemover::IsSupported(webkit::WebPluginInfo* plugin) {
return rv;
}
-}
+} // namespace content
class PluginDataRemoverImpl::Context
: public PluginProcessHost::Client,
+ public PpapiPluginProcessHost::BrokerClient,
public IPC::Channel::Listener,
public base::RefCountedThreadSafe<Context,
BrowserThread::DeleteOnIOThread> {
@@ -87,16 +90,35 @@ class PluginDataRemoverImpl::Context
base::TimeDelta::FromMilliseconds(kRemovalTimeoutMs));
}
- // Initialize on the IO thread.
void InitOnIOThread(const std::string& mime_type) {
+ PluginServiceImpl* plugin_service = PluginServiceImpl::GetInstance();
+
+ // Get the plugin file path.
+ std::vector<webkit::WebPluginInfo> plugins;
+ plugin_service->GetPluginInfoArray(
+ GURL(), mime_type, false, &plugins, NULL);
+ if (plugins.empty()) {
+ NOTREACHED();
+ return;
+ }
+ FilePath plugin_path = plugins[0].path;
+
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
remove_start_time_ = base::Time::Now();
is_removing_ = true;
// Balanced in OnChannelOpened or OnError. Exactly one them will eventually
// be called, so we need to keep this object around until then.
AddRef();
- PluginServiceImpl::GetInstance()->OpenChannelToNpapiPlugin(
- 0, 0, GURL(), GURL(), mime_type, this);
+
+ content::PepperPluginInfo* pepper_info =
+ plugin_service->GetRegisteredPpapiPluginInfo(plugin_path);
+ if (pepper_info) {
+ // Use the broker since we run this function outside the sandbox.
+ plugin_service->OpenChannelToPpapiBroker(plugin_path, this);
+ } else {
+ plugin_service->OpenChannelToNpapiPlugin(
+ 0, 0, GURL(), GURL(), mime_type, this);
+ }
}
// Called when a timeout happens in order not to block the client
@@ -130,7 +152,7 @@ class PluginDataRemoverImpl::Context
}
virtual void OnChannelOpened(const IPC::ChannelHandle& handle) OVERRIDE {
- ConnectToChannel(handle);
+ ConnectToChannel(handle, false);
// Balancing the AddRef call.
Release();
}
@@ -142,11 +164,26 @@ class PluginDataRemoverImpl::Context
Release();
}
+ // PpapiPluginProcessHost::BrokerClient implementation.
+ virtual void GetChannelInfo(base::ProcessHandle* renderer_handle,
+ int* renderer_id) OVERRIDE {
+ }
+
+ virtual void OnChannelOpened(
+ base::ProcessHandle plugin_process_handle,
+ const IPC::ChannelHandle& channel_handle) OVERRIDE {
+ ConnectToChannel(channel_handle, true);
+ // Balancing the AddRef call.
+ Release();
+ }
+
// IPC::Channel::Listener methods.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
IPC_BEGIN_MESSAGE_MAP(Context, message)
IPC_MESSAGE_HANDLER(PluginHostMsg_ClearSiteDataResult,
OnClearSiteDataResult)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_ClearSiteDataResult,
+ OnClearSiteDataResult)
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
@@ -164,7 +201,7 @@ class PluginDataRemoverImpl::Context
private:
// Connects the client side of a newly opened plug-in channel.
- void ConnectToChannel(const IPC::ChannelHandle& handle) {
+ void ConnectToChannel(const IPC::ChannelHandle& handle, bool is_ppapi) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// If we timed out, don't bother connecting.
@@ -179,16 +216,23 @@ class PluginDataRemoverImpl::Context
return;
}
- if (!channel_->Send(new PluginMsg_ClearSiteData(std::string(),
- kClearAllData,
- begin_time_))) {
+ uint64 max_age = begin_time_.is_null() ?
+ std::numeric_limits<uint64>::max() :
+ (base::Time::Now() - begin_time_).InSeconds();
+
+ IPC::Message* msg;
+ if (is_ppapi)
+ msg = new PpapiMsg_ClearSiteData(std::string(), kClearAllData, max_age);
+ else
+ msg = new PluginMsg_ClearSiteData(std::string(), kClearAllData, max_age);
+ if (!channel_->Send(msg)) {
NOTREACHED() << "Couldn't send ClearSiteData message";
SignalDone();
return;
}
}
- // Handles the PluginHostMsg_ClearSiteDataResult message.
+ // Handles the *HostMsg_ClearSiteDataResult message.
void OnClearSiteDataResult(bool success) {
LOG_IF(ERROR, !success) << "ClearSiteData returned error";
UMA_HISTOGRAM_TIMES("ClearPluginData.time",

Powered by Google App Engine
This is Rietveld 408576698