summaryrefslogtreecommitdiffstats
path: root/content/ppapi_plugin
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-11 20:36:21 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-11 20:36:21 +0000
commit55bcab8cc96da2b0f8bd51d4317c5d13c4016933 (patch)
treeefae6dfd4a0d76354a7cfeb79b2dc6f0bcb25527 /content/ppapi_plugin
parent27f24edaf473cfad1e552dfdc92749c7f192d971 (diff)
downloadchromium_src-55bcab8cc96da2b0f8bd51d4317c5d13c4016933.zip
chromium_src-55bcab8cc96da2b0f8bd51d4317c5d13c4016933.tar.gz
chromium_src-55bcab8cc96da2b0f8bd51d4317c5d13c4016933.tar.bz2
Pepper Flash settings integration - camera and microphone.
BUG=112190 TEST=None Review URL: https://chromiumcodereview.appspot.com/10479015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/ppapi_plugin')
-rw-r--r--content/ppapi_plugin/broker_process_dispatcher.cc192
-rw-r--r--content/ppapi_plugin/broker_process_dispatcher.h38
2 files changed, 201 insertions, 29 deletions
diff --git a/content/ppapi_plugin/broker_process_dispatcher.cc b/content/ppapi_plugin/broker_process_dispatcher.cc
index e4b4cb3..5e717e4 100644
--- a/content/ppapi_plugin/broker_process_dispatcher.cc
+++ b/content/ppapi_plugin/broker_process_dispatcher.cc
@@ -6,11 +6,15 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/memory/scoped_ptr.h"
#include "base/utf_string_conversions.h"
#include "content/common/child_process.h"
#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 {
@@ -26,14 +30,70 @@ std::string ConvertPluginDataPath(const FilePath& plugin_data_path) {
#endif
}
+struct GetPermissionSettingsContext {
+ GetPermissionSettingsContext(
+ const base::WeakPtr<BrokerProcessDispatcher> in_dispatcher,
+ uint32 in_request_id)
+ : dispatcher(in_dispatcher),
+ request_id(in_request_id) {
+ }
+
+ base::WeakPtr<BrokerProcessDispatcher> dispatcher;
+ uint32 request_id;
+};
+
+void GetPermissionSettingsCallback(
+ void* user_data,
+ PP_Bool success,
+ PP_Flash_BrowserOperations_Permission default_permission,
+ uint32_t site_count,
+ const PP_Flash_BrowserOperations_SiteSetting sites[]) {
+ scoped_ptr<GetPermissionSettingsContext> context(
+ reinterpret_cast<GetPermissionSettingsContext*>(user_data));
+
+ if (!context->dispatcher)
+ return;
+
+ ppapi::FlashSiteSettings site_vector;
+ 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) {
+ success = PP_FALSE;
+ break;
+ }
+ site_vector.push_back(
+ ppapi::FlashSiteSetting(string_var->value(), sites[i].permission));
+ }
+
+ if (!success)
+ site_vector.clear();
+ }
+ context->dispatcher->OnGetPermissionSettingsCompleted(
+ context->request_id, PP_ToBool(success), default_permission, site_vector);
+}
+
} // namespace
BrokerProcessDispatcher::BrokerProcessDispatcher(
PP_GetInterface_Func get_plugin_interface,
PP_ConnectInstance_Func connect_instance)
: ppapi::proxy::BrokerSideDispatcher(connect_instance),
- get_plugin_interface_(get_plugin_interface) {
+ get_plugin_interface_(get_plugin_interface),
+ flash_browser_operations_1_1_(NULL),
+ flash_browser_operations_1_0_(NULL) {
ChildProcess::current()->AddRefProcess();
+
+ if (get_plugin_interface) {
+ flash_browser_operations_1_0_ =
+ 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));
+ }
}
BrokerProcessDispatcher::~BrokerProcessDispatcher() {
@@ -55,11 +115,25 @@ bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnMsgClearSiteData)
IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses,
OnMsgDeauthorizeContentLicenses)
+ IPC_MESSAGE_HANDLER(PpapiMsg_GetPermissionSettings,
+ OnMsgGetPermissionSettings)
+ IPC_MESSAGE_HANDLER(PpapiMsg_SetDefaultPermission,
+ OnMsgSetDefaultPermission)
+ IPC_MESSAGE_HANDLER(PpapiMsg_SetSitePermission, OnMsgSetSitePermission)
IPC_MESSAGE_UNHANDLED(return BrokerSideDispatcher::OnMessageReceived(msg))
IPC_END_MESSAGE_MAP()
return true;
}
+void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted(
+ uint32 request_id,
+ bool success,
+ PP_Flash_BrowserOperations_Permission default_permission,
+ const ppapi::FlashSiteSettings& sites) {
+ Send(new PpapiHostMsg_GetPermissionSettingsResult(
+ request_id, success, default_permission, sites));
+}
+
void BrokerProcessDispatcher::OnMsgClearSiteData(
const FilePath& plugin_data_path,
const std::string& site,
@@ -76,34 +150,62 @@ void BrokerProcessDispatcher::OnMsgDeauthorizeContentLicenses(
request_id, DeauthorizeContentLicenses(plugin_data_path)));
}
+void BrokerProcessDispatcher::OnMsgGetPermissionSettings(
+ uint32 request_id,
+ const FilePath& plugin_data_path,
+ PP_Flash_BrowserOperations_SettingType setting_type) {
+ if (!flash_browser_operations_1_1_) {
+ OnGetPermissionSettingsCompleted(
+ request_id, false, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT,
+ ppapi::FlashSiteSettings());
+ return;
+ }
+
+ std::string data_str = ConvertPluginDataPath(plugin_data_path);
+ // The GetPermissionSettingsContext object will be deleted in
+ // GetPermissionSettingsCallback().
+ flash_browser_operations_1_1_->GetPermissionSettings(
+ data_str.c_str(), setting_type, &GetPermissionSettingsCallback,
+ new GetPermissionSettingsContext(AsWeakPtr(), request_id));
+}
+
+void BrokerProcessDispatcher::OnMsgSetDefaultPermission(
+ uint32 request_id,
+ const FilePath& plugin_data_path,
+ PP_Flash_BrowserOperations_SettingType setting_type,
+ PP_Flash_BrowserOperations_Permission permission,
+ bool clear_site_specific) {
+ Send(new PpapiHostMsg_SetDefaultPermissionResult(
+ request_id,
+ SetDefaultPermission(plugin_data_path, setting_type, permission,
+ clear_site_specific)));
+}
+
+void BrokerProcessDispatcher::OnMsgSetSitePermission(
+ uint32 request_id,
+ const FilePath& plugin_data_path,
+ PP_Flash_BrowserOperations_SettingType setting_type,
+ const ppapi::FlashSiteSettings& sites) {
+ Send(new PpapiHostMsg_SetSitePermissionResult(
+ request_id, SetSitePermission(plugin_data_path, setting_type, sites)));
+}
+
bool BrokerProcessDispatcher::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_1* browser_interface =
- static_cast<const PPP_Flash_BrowserOperations_1_1*>(
- get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_1));
- if (browser_interface) {
- std::string data_str = ConvertPluginDataPath(plugin_data_path);
- browser_interface->ClearSiteData(data_str.c_str(),
- site.empty() ? NULL : site.c_str(),
- flags, max_age);
+ std::string data_str = ConvertPluginDataPath(plugin_data_path);
+ if (flash_browser_operations_1_1_) {
+ flash_browser_operations_1_1_->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.
- const PPP_Flash_BrowserOperations_1_0* browser_interface_1_0 =
- static_cast<const PPP_Flash_BrowserOperations_1_0*>(
- get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0));
- if (browser_interface_1_0) {
- std::string data_str = ConvertPluginDataPath(plugin_data_path);
- browser_interface_1_0->ClearSiteData(data_str.c_str(),
- site.empty() ? NULL : site.c_str(),
- flags, max_age);
+ 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);
return true;
}
@@ -112,16 +214,52 @@ bool BrokerProcessDispatcher::ClearSiteData(const FilePath& plugin_data_path,
bool BrokerProcessDispatcher::DeauthorizeContentLicenses(
const FilePath& plugin_data_path) {
- if (!get_plugin_interface_)
- return false;
- const PPP_Flash_BrowserOperations_1_1* browser_interface =
- static_cast<const PPP_Flash_BrowserOperations_1_1*>(
- get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_1));
- if (!browser_interface)
+ if (!flash_browser_operations_1_1_)
return false;
std::string data_str = ConvertPluginDataPath(plugin_data_path);
- return PP_ToBool(browser_interface->DeauthorizeContentLicenses(
+ return PP_ToBool(flash_browser_operations_1_1_->DeauthorizeContentLicenses(
data_str.c_str()));
}
+bool BrokerProcessDispatcher::SetDefaultPermission(
+ const FilePath& plugin_data_path,
+ PP_Flash_BrowserOperations_SettingType setting_type,
+ PP_Flash_BrowserOperations_Permission permission,
+ bool clear_site_specific) {
+ if (!flash_browser_operations_1_1_)
+ return false;
+
+ std::string data_str = ConvertPluginDataPath(plugin_data_path);
+ return PP_ToBool(flash_browser_operations_1_1_->SetDefaultPermission(
+ data_str.c_str(), setting_type, permission,
+ PP_FromBool(clear_site_specific)));
+}
+
+bool BrokerProcessDispatcher::SetSitePermission(
+ const FilePath& plugin_data_path,
+ PP_Flash_BrowserOperations_SettingType setting_type,
+ const ppapi::FlashSiteSettings& sites) {
+ if (!flash_browser_operations_1_1_)
+ return false;
+
+ if (sites.empty())
+ return true;
+
+ std::string data_str = ConvertPluginDataPath(plugin_data_path);
+ scoped_array<PP_Flash_BrowserOperations_SiteSetting> site_array(
+ 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].permission = sites[i].permission;
+ }
+
+ PP_Bool result = flash_browser_operations_1_1_->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);
+}
diff --git a/content/ppapi_plugin/broker_process_dispatcher.h b/content/ppapi_plugin/broker_process_dispatcher.h
index b33a4e8..7da07bf 100644
--- a/content/ppapi_plugin/broker_process_dispatcher.h
+++ b/content/ppapi_plugin/broker_process_dispatcher.h
@@ -6,13 +6,17 @@
#define CONTENT_PPAPI_PLUGIN_BROKER_PROCESS_DISPATCHER_H_
#include "base/basictypes.h"
+#include "base/memory/weak_ptr.h"
#include "ppapi/c/ppp.h"
#include "ppapi/proxy/broker_dispatcher.h"
+#include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h"
// Wrapper around a BrokerDispatcher that provides the necessary integration
// for plugin process management. This class is to avoid direct dependencies
// from the PPAPI proxy on the Chrome multiprocess infrastructure.
-class BrokerProcessDispatcher : public ppapi::proxy::BrokerSideDispatcher {
+class BrokerProcessDispatcher
+ : public ppapi::proxy::BrokerSideDispatcher,
+ public base::SupportsWeakPtr<BrokerProcessDispatcher> {
public:
BrokerProcessDispatcher(PP_GetInterface_Func get_plugin_interface,
PP_ConnectInstance_Func connect_instance);
@@ -21,14 +25,34 @@ class BrokerProcessDispatcher : public ppapi::proxy::BrokerSideDispatcher {
// IPC::Channel::Listener overrides.
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
+ void OnGetPermissionSettingsCompleted(
+ uint32 request_id,
+ bool success,
+ PP_Flash_BrowserOperations_Permission default_permission,
+ const ppapi::FlashSiteSettings& sites);
+
private:
void OnMsgClearSiteData(const FilePath& plugin_data_path,
const std::string& site,
uint64 flags,
uint64 max_age);
-
void OnMsgDeauthorizeContentLicenses(uint32 request_id,
const FilePath& plugin_data_path);
+ void OnMsgGetPermissionSettings(
+ uint32 request_id,
+ const FilePath& plugin_data_path,
+ PP_Flash_BrowserOperations_SettingType setting_type);
+ void OnMsgSetDefaultPermission(
+ uint32 request_id,
+ const FilePath& plugin_data_path,
+ PP_Flash_BrowserOperations_SettingType setting_type,
+ PP_Flash_BrowserOperations_Permission permission,
+ bool clear_site_specific);
+ void OnMsgSetSitePermission(
+ uint32 request_id,
+ const FilePath& plugin_data_path,
+ PP_Flash_BrowserOperations_SettingType setting_type,
+ const ppapi::FlashSiteSettings& sites);
// Requests that the plugin clear data, returning true on success.
bool ClearSiteData(const FilePath& plugin_data_path,
@@ -36,9 +60,19 @@ class BrokerProcessDispatcher : public ppapi::proxy::BrokerSideDispatcher {
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,
+ PP_Flash_BrowserOperations_Permission permission,
+ bool clear_site_specific);
+ bool SetSitePermission(const FilePath& plugin_data_path,
+ PP_Flash_BrowserOperations_SettingType setting_type,
+ const ppapi::FlashSiteSettings& sites);
PP_GetInterface_Func get_plugin_interface_;
+ const PPP_Flash_BrowserOperations_1_1* flash_browser_operations_1_1_;
+ const PPP_Flash_BrowserOperations_1_0* flash_browser_operations_1_0_;
+
DISALLOW_COPY_AND_ASSIGN(BrokerProcessDispatcher);
};