Skip to content

Commit

Permalink
Change PP_Flash_BrowserOperations_SiteSetting.site from PP_Var to con…
Browse files Browse the repository at this point in the history
…st char*.

This change is needed because PP_Var cannot be used in a broker process.
This change also adds support for cstr_t in ppapi IDL files.

BUG=112190
TEST=None

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142670 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
yzshen@chromium.org committed Jun 18, 2012
1 parent 9f518d9 commit 4f932f7
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 45 deletions.
41 changes: 17 additions & 24 deletions content/ppapi_plugin/broker_process_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/private/ppp_flash_browser_operations.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/var.h"
#include "ppapi/shared_impl/var_tracker.h"

namespace {

Expand Down Expand Up @@ -58,13 +55,12 @@ void GetPermissionSettingsCallback(
if (success) {
site_vector.reserve(site_count);
for (uint32_t i = 0; i < site_count; ++i) {
ppapi::StringVar* string_var = ppapi::StringVar::FromPPVar(sites[i].site);
if (!string_var) {
if (!sites[i].site) {
success = PP_FALSE;
break;
}
site_vector.push_back(
ppapi::FlashSiteSetting(string_var->value(), sites[i].permission));
ppapi::FlashSiteSetting(sites[i].site, sites[i].permission));
}

if (!success)
Expand All @@ -81,7 +77,7 @@ BrokerProcessDispatcher::BrokerProcessDispatcher(
PP_ConnectInstance_Func connect_instance)
: ppapi::proxy::BrokerSideDispatcher(connect_instance),
get_plugin_interface_(get_plugin_interface),
flash_browser_operations_1_1_(NULL),
flash_browser_operations_1_2_(NULL),
flash_browser_operations_1_0_(NULL) {
ChildProcess::current()->AddRefProcess();

Expand All @@ -90,9 +86,9 @@ BrokerProcessDispatcher::BrokerProcessDispatcher(
static_cast<const PPP_Flash_BrowserOperations_1_0*>(
get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0));

flash_browser_operations_1_1_ =
static_cast<const PPP_Flash_BrowserOperations_1_1*>(
get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_1));
flash_browser_operations_1_2_ =
static_cast<const PPP_Flash_BrowserOperations_1_2*>(
get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2));
}
}

Expand Down Expand Up @@ -154,7 +150,7 @@ void BrokerProcessDispatcher::OnMsgGetPermissionSettings(
uint32 request_id,
const FilePath& plugin_data_path,
PP_Flash_BrowserOperations_SettingType setting_type) {
if (!flash_browser_operations_1_1_) {
if (!flash_browser_operations_1_2_) {
OnGetPermissionSettingsCompleted(
request_id, false, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT,
ppapi::FlashSiteSettings());
Expand All @@ -164,7 +160,7 @@ void BrokerProcessDispatcher::OnMsgGetPermissionSettings(
std::string data_str = ConvertPluginDataPath(plugin_data_path);
// The GetPermissionSettingsContext object will be deleted in
// GetPermissionSettingsCallback().
flash_browser_operations_1_1_->GetPermissionSettings(
flash_browser_operations_1_2_->GetPermissionSettings(
data_str.c_str(), setting_type, &GetPermissionSettingsCallback,
new GetPermissionSettingsContext(AsWeakPtr(), request_id));
}
Expand Down Expand Up @@ -195,8 +191,8 @@ bool BrokerProcessDispatcher::ClearSiteData(const FilePath& plugin_data_path,
uint64 flags,
uint64 max_age) {
std::string data_str = ConvertPluginDataPath(plugin_data_path);
if (flash_browser_operations_1_1_) {
flash_browser_operations_1_1_->ClearSiteData(
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;
}
Expand All @@ -214,11 +210,11 @@ bool BrokerProcessDispatcher::ClearSiteData(const FilePath& plugin_data_path,

bool BrokerProcessDispatcher::DeauthorizeContentLicenses(
const FilePath& plugin_data_path) {
if (!flash_browser_operations_1_1_)
if (!flash_browser_operations_1_2_)
return false;

std::string data_str = ConvertPluginDataPath(plugin_data_path);
return PP_ToBool(flash_browser_operations_1_1_->DeauthorizeContentLicenses(
return PP_ToBool(flash_browser_operations_1_2_->DeauthorizeContentLicenses(
data_str.c_str()));
}

Expand All @@ -227,11 +223,11 @@ bool BrokerProcessDispatcher::SetDefaultPermission(
PP_Flash_BrowserOperations_SettingType setting_type,
PP_Flash_BrowserOperations_Permission permission,
bool clear_site_specific) {
if (!flash_browser_operations_1_1_)
if (!flash_browser_operations_1_2_)
return false;

std::string data_str = ConvertPluginDataPath(plugin_data_path);
return PP_ToBool(flash_browser_operations_1_1_->SetDefaultPermission(
return PP_ToBool(flash_browser_operations_1_2_->SetDefaultPermission(
data_str.c_str(), setting_type, permission,
PP_FromBool(clear_site_specific)));
}
Expand All @@ -240,7 +236,7 @@ bool BrokerProcessDispatcher::SetSitePermission(
const FilePath& plugin_data_path,
PP_Flash_BrowserOperations_SettingType setting_type,
const ppapi::FlashSiteSettings& sites) {
if (!flash_browser_operations_1_1_)
if (!flash_browser_operations_1_2_)
return false;

if (sites.empty())
Expand All @@ -251,15 +247,12 @@ bool BrokerProcessDispatcher::SetSitePermission(
new PP_Flash_BrowserOperations_SiteSetting[sites.size()]);

for (size_t i = 0; i < sites.size(); ++i) {
site_array[i].site = ppapi::StringVar::StringToPPVar(sites[i].site);
site_array[i].site = sites[i].site.c_str();
site_array[i].permission = sites[i].permission;
}

PP_Bool result = flash_browser_operations_1_1_->SetSitePermission(
PP_Bool result = flash_browser_operations_1_2_->SetSitePermission(
data_str.c_str(), setting_type, sites.size(), site_array.get());

for (size_t i = 0; i < sites.size(); ++i)
ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(site_array[i].site);

return PP_ToBool(result);
}
2 changes: 1 addition & 1 deletion content/ppapi_plugin/broker_process_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class BrokerProcessDispatcher

PP_GetInterface_Func get_plugin_interface_;

const PPP_Flash_BrowserOperations_1_1* flash_browser_operations_1_1_;
const PPP_Flash_BrowserOperations_1_2* flash_browser_operations_1_2_;
const PPP_Flash_BrowserOperations_1_0* flash_browser_operations_1_0_;

DISALLOW_COPY_AND_ASSIGN(BrokerProcessDispatcher);
Expand Down
3 changes: 3 additions & 0 deletions ppapi/api/pp_stdint.idl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ describe {
/** Pointer to null terminated string (char *). */
str_t;

/** Pointer to constant null terminated string (const char *). */
cstr_t;

/** No return value. */
void;
};
Expand Down
15 changes: 6 additions & 9 deletions ppapi/api/private/ppp_flash_browser_operations.idl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

label Chrome {
M20 = 1.0,
M21 = 1.1
M21 = 1.2
};

[assert_size(4)]
Expand All @@ -27,12 +27,9 @@ enum PP_Flash_BrowserOperations_Permission {
PP_FLASH_BROWSEROPERATIONS_PERMISSION_ASK = 3
};

[assert_size(24)]
struct PP_Flash_BrowserOperations_SiteSetting {
PP_Var site;
cstr_t site;
PP_Flash_BrowserOperations_Permission permission;
// Makes the size consistent across compilers.
int32_t padding;
};

typedef void PPB_Flash_BrowserOperations_GetSettingsCallback(
Expand Down Expand Up @@ -83,7 +80,7 @@ interface PPP_Flash_BrowserOperations {
*
* @return <code>PP_TRUE</code> on success, <code>PP_FALSE</code> on failure.
*/
[version=1.1]
[version=1.2]
PP_Bool DeauthorizeContentLicenses([in] str_t plugin_data_path);

/**
Expand All @@ -97,7 +94,7 @@ interface PPP_Flash_BrowserOperations {
* @param[inout] user_data An opaque pointer that will be passed to
* <code>callback</code>.
*/
[version=1.1]
[version=1.2]
void GetPermissionSettings(
[in] str_t plugin_data_path,
[in] PP_Flash_BrowserOperations_SettingType setting_type,
Expand All @@ -117,7 +114,7 @@ interface PPP_Flash_BrowserOperations {
*
* @return <code>PP_TRUE</code> on success, <code>PP_FALSE</code> on failure.
*/
[version=1.1]
[version=1.2]
PP_Bool SetDefaultPermission(
[in] str_t plugin_data_path,
[in] PP_Flash_BrowserOperations_SettingType setting_type,
Expand All @@ -138,7 +135,7 @@ interface PPP_Flash_BrowserOperations {
*
* @return <code>PP_TRUE</code> on success, <code>PP_FALSE</code> on failure.
*/
[version=1.1]
[version=1.2]
PP_Bool SetSitePermission(
[in] str_t plugin_data_path,
[in] PP_Flash_BrowserOperations_SettingType setting_type,
Expand Down
18 changes: 7 additions & 11 deletions ppapi/c/private/ppp_flash_browser_operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/* From private/ppp_flash_browser_operations.idl,
* modified Thu Jun 7 10:43:20 2012.
* modified Fri Jun 15 17:00:18 2012.
*/

#ifndef PPAPI_C_PRIVATE_PPP_FLASH_BROWSER_OPERATIONS_H_
Expand All @@ -13,14 +13,13 @@
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_macros.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"

#define PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0 \
"PPP_Flash_BrowserOperations;1.0"
#define PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_1 \
"PPP_Flash_BrowserOperations;1.1"
#define PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2 \
"PPP_Flash_BrowserOperations;1.2"
#define PPP_FLASH_BROWSEROPERATIONS_INTERFACE \
PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_1
PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2

/**
* @file
Expand Down Expand Up @@ -55,12 +54,9 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Flash_BrowserOperations_Permission, 4);
* @{
*/
struct PP_Flash_BrowserOperations_SiteSetting {
struct PP_Var site;
const char* site;
PP_Flash_BrowserOperations_Permission permission;
/* Makes the size consistent across compilers. */
int32_t padding;
};
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Flash_BrowserOperations_SiteSetting, 24);
/**
* @}
*/
Expand All @@ -86,7 +82,7 @@ typedef void (*PPB_Flash_BrowserOperations_GetSettingsCallback)(
/**
* This interface allows the browser to request the plugin do things.
*/
struct PPP_Flash_BrowserOperations_1_1 {
struct PPP_Flash_BrowserOperations_1_2 {
/**
* This function allows the plugin to implement the "Clear site data" feature.
*
Expand Down Expand Up @@ -179,7 +175,7 @@ struct PPP_Flash_BrowserOperations_1_1 {
const struct PP_Flash_BrowserOperations_SiteSetting sites[]);
};

typedef struct PPP_Flash_BrowserOperations_1_1 PPP_Flash_BrowserOperations;
typedef struct PPP_Flash_BrowserOperations_1_2 PPP_Flash_BrowserOperations;

struct PPP_Flash_BrowserOperations_1_0 {
PP_Bool (*ClearSiteData)(const char* plugin_data_path,
Expand Down
8 changes: 8 additions & 0 deletions ppapi/generators/idl_c_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ class CGen(object):
'return': 'const %s',
'store': '%s'
},
'cstr_t': {
'in': '%s',
'inout': '%s*',
'out': '%s*',
'return': '%s',
'store': '%s'
},
'TypeValue': {
'in': '%s',
'inout': '%s*',
Expand All @@ -146,6 +153,7 @@ class CGen(object):
'handle_t': 'int',
'mem_t': 'void*',
'str_t': 'char*',
'cstr_t': 'const char*',
'interface_t' : 'const void*'
}

Expand Down

0 comments on commit 4f932f7

Please sign in to comment.