Commit 951ef0bd authored by bauerb@chromium.org's avatar bauerb@chromium.org

Add GetSitesWithData and FreeSiteList methods to PPP_Flash_BrowserOperations...

Add GetSitesWithData and FreeSiteList methods to PPP_Flash_BrowserOperations interface and hook them up in PepperFlashSettingsManager.


BUG=132409
TEST=none


Review URL: https://chromiumcodereview.appspot.com/10825018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148839 0039d316-1c4b-4281-b951-d872f2087c98
parent 19d32935
......@@ -42,6 +42,12 @@ class PepperFlashSettingsManager {
virtual void OnSetSitePermissionCompleted(uint32 request_id,
bool success) {}
virtual void OnGetSitesWithDataCompleted(
uint32 request_id,
const std::vector<std::string>& sites) {}
virtual void OnClearSiteDataCompleted(uint32 request_id, bool success) {}
};
// |client| must outlive this object. It is guaranteed that |client| won't
......@@ -84,6 +90,16 @@ class PepperFlashSettingsManager {
uint32 SetSitePermission(PP_Flash_BrowserOperations_SettingType setting_type,
const ppapi::FlashSiteSettings& sites);
// Gets a list of sites that have stored data.
// Client::OnGetSitesWithDataCompleted() will be called when the operation is
// completed.
uint32 GetSitesWithData();
// Clears data for a certain site.
// Client::OnClearSiteDataompleted() will be called when the operation is
// completed.
uint32 ClearSiteData(const std::string& site, uint64 flags, uint64 max_age);
private:
// Core does most of the work. It is ref-counted so that its lifespan can be
// independent of the containing object's:
......
......@@ -177,7 +177,7 @@ class PluginDataRemoverImpl::Context
IPC_MESSAGE_HANDLER(PluginHostMsg_ClearSiteDataResult,
OnClearSiteDataResult)
IPC_MESSAGE_HANDLER(PpapiHostMsg_ClearSiteDataResult,
OnClearSiteDataResult)
OnPpapiClearSiteDataResult)
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
......@@ -232,7 +232,7 @@ class PluginDataRemoverImpl::Context
#else
FilePath plugin_data_path = profile_path.Append(FilePath(plugin_name_));
#endif
msg = new PpapiMsg_ClearSiteData(plugin_data_path, std::string(),
msg = new PpapiMsg_ClearSiteData(0u, plugin_data_path, std::string(),
kClearAllData, max_age);
} else {
msg = new PluginMsg_ClearSiteData(std::string(), kClearAllData, max_age);
......@@ -244,7 +244,14 @@ class PluginDataRemoverImpl::Context
}
}
// Handles the *HostMsg_ClearSiteDataResult message.
// Handles the PpapiHostMsg_ClearSiteDataResult message by delegating to the
// PluginHostMsg_ClearSiteDataResult handler.
void OnPpapiClearSiteDataResult(uint32 request_id, bool success) {
DCHECK_EQ(0u, request_id);
OnClearSiteDataResult(success);
}
// Handles the PluginHostMsg_ClearSiteDataResult message.
void OnClearSiteDataResult(bool success) {
LOG_IF(ERROR, !success) << "ClearSiteData returned error";
UMA_HISTOGRAM_TIMES("ClearPluginData.time",
......
......@@ -77,6 +77,7 @@ BrokerProcessDispatcher::BrokerProcessDispatcher(
PP_ConnectInstance_Func connect_instance)
: ppapi::proxy::BrokerSideDispatcher(connect_instance),
get_plugin_interface_(get_plugin_interface),
flash_browser_operations_1_3_(NULL),
flash_browser_operations_1_2_(NULL),
flash_browser_operations_1_0_(NULL) {
ChildProcess::current()->AddRefProcess();
......@@ -89,6 +90,10 @@ BrokerProcessDispatcher::BrokerProcessDispatcher(
flash_browser_operations_1_2_ =
static_cast<const PPP_Flash_BrowserOperations_1_2*>(
get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2));
flash_browser_operations_1_3_ =
static_cast<const PPP_Flash_BrowserOperations_1_3*>(
get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3));
}
}
......@@ -108,6 +113,7 @@ BrokerProcessDispatcher::~BrokerProcessDispatcher() {
bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg)
IPC_MESSAGE_HANDLER(PpapiMsg_GetSitesWithData, OnMsgGetSitesWithData)
IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnMsgClearSiteData)
IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses,
OnMsgDeauthorizeContentLicenses)
......@@ -130,13 +136,22 @@ void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted(
request_id, success, default_permission, sites));
}
void BrokerProcessDispatcher::OnMsgGetSitesWithData(
uint32 request_id,
const FilePath& plugin_data_path) {
std::vector<std::string> sites;
GetSitesWithData(plugin_data_path, &sites);
Send(new PpapiHostMsg_GetSitesWithDataResult(request_id, sites));
}
void BrokerProcessDispatcher::OnMsgClearSiteData(
uint32 request_id,
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)));
request_id, ClearSiteData(plugin_data_path, site, flags, max_age)));
}
void BrokerProcessDispatcher::OnMsgDeauthorizeContentLicenses(
......@@ -150,19 +165,30 @@ void BrokerProcessDispatcher::OnMsgGetPermissionSettings(
uint32 request_id,
const FilePath& plugin_data_path,
PP_Flash_BrowserOperations_SettingType setting_type) {
if (!flash_browser_operations_1_2_) {
OnGetPermissionSettingsCompleted(
request_id, false, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT,
ppapi::FlashSiteSettings());
if (flash_browser_operations_1_3_) {
std::string data_str = ConvertPluginDataPath(plugin_data_path);
// The GetPermissionSettingsContext object will be deleted in
// GetPermissionSettingsCallback().
flash_browser_operations_1_3_->GetPermissionSettings(
data_str.c_str(), setting_type, &GetPermissionSettingsCallback,
new GetPermissionSettingsContext(AsWeakPtr(), request_id));
return;
}
std::string data_str = ConvertPluginDataPath(plugin_data_path);
// The GetPermissionSettingsContext object will be deleted in
// GetPermissionSettingsCallback().
flash_browser_operations_1_2_->GetPermissionSettings(
data_str.c_str(), setting_type, &GetPermissionSettingsCallback,
new GetPermissionSettingsContext(AsWeakPtr(), request_id));
if (flash_browser_operations_1_2_) {
std::string data_str = ConvertPluginDataPath(plugin_data_path);
// The GetPermissionSettingsContext object will be deleted in
// GetPermissionSettingsCallback().
flash_browser_operations_1_2_->GetPermissionSettings(
data_str.c_str(), setting_type, &GetPermissionSettingsCallback,
new GetPermissionSettingsContext(AsWeakPtr(), request_id));
return;
}
OnGetPermissionSettingsCompleted(
request_id, false, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT,
ppapi::FlashSiteSettings());
return;
}
void BrokerProcessDispatcher::OnMsgSetDefaultPermission(
......@@ -186,19 +212,42 @@ void BrokerProcessDispatcher::OnMsgSetSitePermission(
request_id, SetSitePermission(plugin_data_path, setting_type, sites)));
}
void BrokerProcessDispatcher::GetSitesWithData(
const FilePath& plugin_data_path,
std::vector<std::string>* site_vector) {
std::string data_str = ConvertPluginDataPath(plugin_data_path);
if (flash_browser_operations_1_3_) {
char** sites = NULL;
flash_browser_operations_1_3_->GetSitesWithData(data_str.c_str(), &sites);
if (!sites)
return;
for (size_t i = 0; sites[i]; ++i)
site_vector->push_back(sites[i]);
flash_browser_operations_1_3_->FreeSiteList(sites);
}
}
bool BrokerProcessDispatcher::ClearSiteData(const FilePath& plugin_data_path,
const std::string& site,
uint64 flags,
uint64 max_age) {
std::string data_str = ConvertPluginDataPath(plugin_data_path);
if (flash_browser_operations_1_2_) {
flash_browser_operations_1_2_->ClearSiteData(
if (flash_browser_operations_1_3_) {
flash_browser_operations_1_3_->ClearSiteData(
data_str.c_str(), site.empty() ? NULL : site.c_str(), flags, max_age);
return true;
}
// TODO(viettrungluu): Remove this (and the 1.0 interface) sometime after M21
// goes to Stable.
if (flash_browser_operations_1_2_) {
flash_browser_operations_1_2_->ClearSiteData(
data_str.c_str(), site.empty() ? NULL : site.c_str(), flags, max_age);
return true;
}
if (flash_browser_operations_1_0_) {
flash_browser_operations_1_0_->ClearSiteData(
data_str.c_str(), site.empty() ? NULL : site.c_str(), flags, max_age);
......@@ -210,12 +259,19 @@ bool BrokerProcessDispatcher::ClearSiteData(const FilePath& plugin_data_path,
bool BrokerProcessDispatcher::DeauthorizeContentLicenses(
const FilePath& plugin_data_path) {
if (!flash_browser_operations_1_2_)
return false;
if (flash_browser_operations_1_3_) {
std::string data_str = ConvertPluginDataPath(plugin_data_path);
return PP_ToBool(flash_browser_operations_1_3_->DeauthorizeContentLicenses(
data_str.c_str()));
}
std::string data_str = ConvertPluginDataPath(plugin_data_path);
return PP_ToBool(flash_browser_operations_1_2_->DeauthorizeContentLicenses(
data_str.c_str()));
if (flash_browser_operations_1_2_) {
std::string data_str = ConvertPluginDataPath(plugin_data_path);
return PP_ToBool(flash_browser_operations_1_2_->DeauthorizeContentLicenses(
data_str.c_str()));
}
return false;
}
bool BrokerProcessDispatcher::SetDefaultPermission(
......@@ -223,22 +279,27 @@ bool BrokerProcessDispatcher::SetDefaultPermission(
PP_Flash_BrowserOperations_SettingType setting_type,
PP_Flash_BrowserOperations_Permission permission,
bool clear_site_specific) {
if (!flash_browser_operations_1_2_)
return false;
if (flash_browser_operations_1_3_) {
std::string data_str = ConvertPluginDataPath(plugin_data_path);
return PP_ToBool(flash_browser_operations_1_3_->SetDefaultPermission(
data_str.c_str(), setting_type, permission,
PP_FromBool(clear_site_specific)));
}
std::string data_str = ConvertPluginDataPath(plugin_data_path);
return PP_ToBool(flash_browser_operations_1_2_->SetDefaultPermission(
data_str.c_str(), setting_type, permission,
PP_FromBool(clear_site_specific)));
if (flash_browser_operations_1_2_) {
std::string data_str = ConvertPluginDataPath(plugin_data_path);
return PP_ToBool(flash_browser_operations_1_2_->SetDefaultPermission(
data_str.c_str(), setting_type, permission,
PP_FromBool(clear_site_specific)));
}
return false;
}
bool BrokerProcessDispatcher::SetSitePermission(
const FilePath& plugin_data_path,
PP_Flash_BrowserOperations_SettingType setting_type,
const ppapi::FlashSiteSettings& sites) {
if (!flash_browser_operations_1_2_)
return false;
if (sites.empty())
return true;
......@@ -251,8 +312,19 @@ bool BrokerProcessDispatcher::SetSitePermission(
site_array[i].permission = sites[i].permission;
}
PP_Bool result = flash_browser_operations_1_2_->SetSitePermission(
data_str.c_str(), setting_type, sites.size(), site_array.get());
if (flash_browser_operations_1_3_) {
PP_Bool result = flash_browser_operations_1_3_->SetSitePermission(
data_str.c_str(), setting_type, sites.size(), site_array.get());
return PP_ToBool(result);
}
return PP_ToBool(result);
if (flash_browser_operations_1_2_) {
PP_Bool result = flash_browser_operations_1_2_->SetSitePermission(
data_str.c_str(), setting_type, sites.size(), site_array.get());
return PP_ToBool(result);
}
return false;
}
......@@ -32,7 +32,10 @@ class BrokerProcessDispatcher
const ppapi::FlashSiteSettings& sites);
private:
void OnMsgClearSiteData(const FilePath& plugin_data_path,
void OnMsgGetSitesWithData(uint32 request_id,
const FilePath& plugin_data_path);
void OnMsgClearSiteData(uint32 request_id,
const FilePath& plugin_data_path,
const std::string& site,
uint64 flags,
uint64 max_age);
......@@ -54,11 +57,16 @@ class BrokerProcessDispatcher
PP_Flash_BrowserOperations_SettingType setting_type,
const ppapi::FlashSiteSettings& sites);
// Returns a list of sites that have data stored.
void GetSitesWithData(const FilePath& plugin_data_path,
std::vector<std::string>* sites);
// 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);
bool DeauthorizeContentLicenses(const FilePath& plugin_data_path);
bool SetDefaultPermission(const FilePath& plugin_data_path,
PP_Flash_BrowserOperations_SettingType setting_type,
......@@ -70,6 +78,7 @@ class BrokerProcessDispatcher
PP_GetInterface_Func get_plugin_interface_;
const PPP_Flash_BrowserOperations_1_3* flash_browser_operations_1_3_;
const PPP_Flash_BrowserOperations_1_2* flash_browser_operations_1_2_;
const PPP_Flash_BrowserOperations_1_0* flash_browser_operations_1_0_;
......
......@@ -9,7 +9,8 @@
label Chrome {
M20 = 1.0,
M21 = 1.2
M21 = 1.2,
M22 = 1.3
};
[assert_size(4)]
......@@ -46,29 +47,28 @@ interface PPP_Flash_BrowserOperations {
/**
* This function allows the plugin to implement the "Clear site data" feature.
*
* @plugin_data_path String containing the directory where the plugin data is
* @param[in] plugin_data_path String containing the directory where the
* plugin data is
* stored. On UTF16 systems (Windows), this will be encoded as UTF-8. It will
* be an absolute path and will not have a directory separator (slash) at the
* end.
*
* @arg site String specifying which site to clear the data for. This will
* be null to clear data for all sites.
*
* @arg flags Currently always 0 in Chrome to clear all data. This may be
* extended in the future to clear only specific types of data.
*
* @arg max_age The maximum age in seconds to clear data for. This allows the
* plugin to implement "clear past hour" and "clear past data", etc.
* @param[in] site String specifying which site to clear the data for. This
* will be null to clear data for all sites.
* @param[in] flags Currently always 0 in Chrome to clear all data. This may
* be extended in the future to clear only specific types of data.
* @param[in] max_age The maximum age in seconds to clear data for. This
* allows the plugin to implement "clear past hour" and "clear past data",
* etc.
*
* @return PP_TRUE on success, PP_FALSE on failure.
*
* See also the NPP_ClearSiteData function in NPAPI.
* https://wiki.mozilla.org/NPAPI:ClearSiteData
*/
PP_Bool ClearSiteData(str_t plugin_data_path,
str_t site,
uint64_t flags,
uint64_t max_age);
PP_Bool ClearSiteData([in] str_t plugin_data_path,
[in] str_t site,
[in] uint64_t flags,
[in] uint64_t max_age);
/**
* Requests the plugin to deauthorize content licenses. It prevents Flash from
......@@ -141,4 +141,28 @@ interface PPP_Flash_BrowserOperations {
[in] PP_Flash_BrowserOperations_SettingType setting_type,
[in] uint32_t site_count,
[in, size_is(site_count)] PP_Flash_BrowserOperations_SiteSetting[] sites);
/**
* Returns a list of sites that have stored data, for use with the
* "Clear site data" feature.
*
* @param[in] plugin_data_path String containing the directory where the
* plugin data is stored.
* @param[out] sites A NULL-terminated array of sites that have stored data.
* Use FreeSiteList on the the array when done.
*
* See also the NPP_GetSitesWithData function in NPAPI:
* https://wiki.mozilla.org/NPAPI:ClearSiteData
*/
[version=1.3]
void GetSitesWithData([in] str_t plugin_data_path,
[out] str_t[] sites);
/**
* Frees the list of sites returned by GetSitesWithData.
*
* @param[in] sites A NULL-terminated array of strings.
*/
[version=1.3]
void FreeSiteList([inout] str_t[] sites);
};
......@@ -4,7 +4,7 @@
*/
/* From private/ppp_flash_browser_operations.idl,
* modified Fri Jun 15 17:00:18 2012.
* modified Wed Jul 25 16:53:17 2012.
*/
#ifndef PPAPI_C_PRIVATE_PPP_FLASH_BROWSER_OPERATIONS_H_
......@@ -18,8 +18,10 @@
"PPP_Flash_BrowserOperations;1.0"
#define PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2 \
"PPP_Flash_BrowserOperations;1.2"
#define PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3 \
"PPP_Flash_BrowserOperations;1.3"
#define PPP_FLASH_BROWSEROPERATIONS_INTERFACE \
PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2
PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3
/**
* @file
......@@ -82,23 +84,22 @@ typedef void (*PPB_Flash_BrowserOperations_GetSettingsCallback)(
/**
* This interface allows the browser to request the plugin do things.
*/
struct PPP_Flash_BrowserOperations_1_2 {
struct PPP_Flash_BrowserOperations_1_3 {
/**
* This function allows the plugin to implement the "Clear site data" feature.
*
* @plugin_data_path String containing the directory where the plugin data is
* @param[in] plugin_data_path String containing the directory where the
* plugin data is
* stored. On UTF16 systems (Windows), this will be encoded as UTF-8. It will
* be an absolute path and will not have a directory separator (slash) at the
* end.
*
* @arg site String specifying which site to clear the data for. This will
* be null to clear data for all sites.
*
* @arg flags Currently always 0 in Chrome to clear all data. This may be
* extended in the future to clear only specific types of data.
*
* @arg max_age The maximum age in seconds to clear data for. This allows the
* plugin to implement "clear past hour" and "clear past data", etc.
* @param[in] site String specifying which site to clear the data for. This
* will be null to clear data for all sites.
* @param[in] flags Currently always 0 in Chrome to clear all data. This may
* be extended in the future to clear only specific types of data.
* @param[in] max_age The maximum age in seconds to clear data for. This
* allows the plugin to implement "clear past hour" and "clear past data",
* etc.
*
* @return PP_TRUE on success, PP_FALSE on failure.
*
......@@ -173,9 +174,28 @@ struct PPP_Flash_BrowserOperations_1_2 {
PP_Flash_BrowserOperations_SettingType setting_type,
uint32_t site_count,
const struct PP_Flash_BrowserOperations_SiteSetting sites[]);
/**
* Returns a list of sites that have stored data, for use with the
* "Clear site data" feature.
*
* @param[in] plugin_data_path String containing the directory where the
* plugin data is stored.
* @param[out] sites A NULL-terminated array of sites that have stored data.
* Use FreeSiteList on the the array when done.
*
* See also the NPP_GetSitesWithData function in NPAPI:
* https://wiki.mozilla.org/NPAPI:ClearSiteData
*/
void (*GetSitesWithData)(const char* plugin_data_path, char** sites[]);
/**
* Frees the list of sites returned by GetSitesWithData.
*
* @param[in] sites A NULL-terminated array of strings.
*/
void (*FreeSiteList)(char* sites[]);
};
typedef struct PPP_Flash_BrowserOperations_1_2 PPP_Flash_BrowserOperations;
typedef struct PPP_Flash_BrowserOperations_1_3 PPP_Flash_BrowserOperations;
struct PPP_Flash_BrowserOperations_1_0 {
PP_Bool (*ClearSiteData)(const char* plugin_data_path,
......@@ -183,6 +203,29 @@ struct PPP_Flash_BrowserOperations_1_0 {
uint64_t flags,
uint64_t max_age);
};
struct PPP_Flash_BrowserOperations_1_2 {
PP_Bool (*ClearSiteData)(const char* plugin_data_path,
const char* site,
uint64_t flags,
uint64_t max_age);
PP_Bool (*DeauthorizeContentLicenses)(const char* plugin_data_path);
void (*GetPermissionSettings)(
const char* plugin_data_path,
PP_Flash_BrowserOperations_SettingType setting_type,
PPB_Flash_BrowserOperations_GetSettingsCallback callback,
void* user_data);
PP_Bool (*SetDefaultPermission)(
const char* plugin_data_path,
PP_Flash_BrowserOperations_SettingType setting_type,
PP_Flash_BrowserOperations_Permission permission,
PP_Bool clear_site_specific);
PP_Bool (*SetSitePermission)(
const char* plugin_data_path,
PP_Flash_BrowserOperations_SettingType setting_type,
uint32_t site_count,
const struct PP_Flash_BrowserOperations_SiteSetting sites[]);
};
/**
* @}
*/
......
......@@ -289,15 +289,27 @@ IPC_SYNC_MESSAGE_CONTROL1_1(PpapiMsg_SupportsInterface,
IPC_MESSAGE_CONTROL1(PpapiMsg_SetNetworkState,
bool /* online */)
// Requests a list of sites that have data stored from the plugin. The plugin
// process will respond with PpapiHostMsg_GetSitesWithDataResult. This is used
// for Flash.
IPC_MESSAGE_CONTROL2(PpapiMsg_GetSitesWithData,
uint32 /* request_id */,
FilePath /* plugin_data_path */)
IPC_MESSAGE_CONTROL2(PpapiHostMsg_GetSitesWithDataResult,
uint32 /* request_id */,
std::vector<std::string> /* sites */)
// Instructs the plugin to clear data for the given site & time. The plugin
// process will respond with PpapiHostMsg_ClearSiteDataResult. This is used
// for Flash.
IPC_MESSAGE_CONTROL4(PpapiMsg_ClearSiteData,
IPC_MESSAGE_CONTROL5(PpapiMsg_ClearSiteData,
uint32 /* request_id */,
FilePath /* plugin_data_path */,
std::string /* site */,
uint64 /* flags */,
uint64 /* max_age */)
IPC_MESSAGE_CONTROL1(PpapiHostMsg_ClearSiteDataResult,
IPC_MESSAGE_CONTROL2(PpapiHostMsg_ClearSiteDataResult,
uint32 /* request_id */,
bool /* success */)
IPC_MESSAGE_CONTROL2(PpapiMsg_DeauthorizeContentLicenses,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment