diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 21:44:16 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 21:44:16 +0000 |
commit | 1bf0fb266408d260d7b01e8cfabb531937d8d953 (patch) | |
tree | ce953516187873b48ff0454f653e10a662ea5a9c /content/ppapi_plugin | |
parent | 5f1d99dceda9a8d8e137635b375d9e3b46921680 (diff) | |
download | chromium_src-1bf0fb266408d260d7b01e8cfabb531937d8d953.zip chromium_src-1bf0fb266408d260d7b01e8cfabb531937d8d953.tar.gz chromium_src-1bf0fb266408d260d7b01e8cfabb531937d8d953.tar.bz2 |
Add an interface for Flash to clear its data.
This mirrors NPP_ClearSiteData. I basically just hooked into the existing infrastructure in the browser process, and create a new plugin.
I changed the NPAPI IPC message to take the max age rather than compute it from the time so I did not have to duplicate the time computation code.
Review URL: https://chromiumcodereview.appspot.com/9981015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132067 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/ppapi_plugin')
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.cc | 37 | ||||
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.h | 11 |
2 files changed, 48 insertions, 0 deletions
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index 54f9af8..30c99b1 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -10,6 +10,7 @@ #include "base/process_util.h" #include "base/rand_util.h" #include "base/stringprintf.h" +#include "base/utf_string_conversions.h" #include "content/common/child_process.h" #include "content/common/child_process_messages.h" #include "content/ppapi_plugin/broker_process_dispatcher.h" @@ -22,6 +23,7 @@ #include "ppapi/c/dev/ppp_network_state_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppp.h" +#include "ppapi/c/private/ppp_flash_browser_operations.h" #include "ppapi/proxy/plugin_globals.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/interface_list.h" @@ -83,6 +85,8 @@ bool PpapiThread::OnMessageReceived(const IPC::Message& msg) { IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnMsgLoadPlugin) IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnMsgCreateChannel) + IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnMsgClearSiteData) + IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBTCPServerSocket_ListenACK, OnPluginDispatcherMessageReceived(msg)) IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBTCPServerSocket_AcceptACK, @@ -255,6 +259,14 @@ void PpapiThread::OnMsgCreateChannel(base::ProcessHandle host_process_handle, Send(new PpapiHostMsg_ChannelCreated(channel_handle)); } +void PpapiThread::OnMsgClearSiteData(const FilePath& plugin_data_path, + const std::string& site, + uint64 flags, + uint64 max_age) { + Send(new PpapiHostMsg_ClearSiteDataResult( + ClearSiteData(plugin_data_path, site, flags, max_age))); +} + void PpapiThread::OnMsgSetNetworkState(bool online) { if (!get_plugin_interface_) return; @@ -278,6 +290,31 @@ void PpapiThread::OnPluginDispatcherMessageReceived(const IPC::Message& msg) { dispatcher->second->OnMessageReceived(msg); } +bool PpapiThread::ClearSiteData(const FilePath& plugin_data_path, + const std::string& site, + uint64 flags, + uint64 max_age) { + if (!get_plugin_interface_) + return false; + const PPP_Flash_BrowserOperations_1_0* browser_interface = + static_cast<const PPP_Flash_BrowserOperations_1_0*>( + get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0)); + if (!browser_interface) + return false; + + // The string is always 8-bit, convert on Windows. +#if defined(OS_WIN) + std::string data_str = WideToUTF8(plugin_data_path.value()); +#else + std::string data_str = plugin_data_path.value(); +#endif + + browser_interface->ClearSiteData(data_str.c_str(), + site.empty() ? NULL : site.c_str(), + flags, max_age); + return true; +} + bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle, int renderer_id, IPC::ChannelHandle* handle) { diff --git a/content/ppapi_plugin/ppapi_thread.h b/content/ppapi_plugin/ppapi_thread.h index 0784dd3..e7e046c 100644 --- a/content/ppapi_plugin/ppapi_thread.h +++ b/content/ppapi_plugin/ppapi_thread.h @@ -7,6 +7,7 @@ #pragma once #include <map> +#include <string> #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -55,9 +56,19 @@ class PpapiThread : public ChildThread, void OnMsgLoadPlugin(const FilePath& path); void OnMsgCreateChannel(base::ProcessHandle host_process_handle, int renderer_id); + void OnMsgClearSiteData(const FilePath& plugin_data_path, + const std::string& site, + uint64 flags, + uint64 max_age); void OnMsgSetNetworkState(bool online); void OnPluginDispatcherMessageReceived(const IPC::Message& msg); + // Requests that the plugin clear data, returning true on success. + bool ClearSiteData(const FilePath& plugin_data_path, + const std::string& site, + uint64 flags, + uint64 max_age); + // Sets up the channel to the given renderer. On success, returns true and // fills the given ChannelHandle with the information from the new channel. bool SetupRendererChannel(base::ProcessHandle host_process_handle, |