Commit ea628e38 authored by bauerb@chromium.org's avatar bauerb@chromium.org

Add PP_FlashLSORestrictions to the list of settings supported by the Flash_GetSetting Pepper API.


BUG=132410

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149711 0039d316-1c4b-4281-b951-d872f2087c98
parent ecf5a6df
......@@ -957,6 +957,24 @@ bool ChromeContentBrowserClient::AllowSetCookie(
return allow;
}
bool ChromeContentBrowserClient::AllowPluginLocalDataAccess(
const GURL& document_url,
const GURL& plugin_url,
content::ResourceContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
return io_data->GetCookieSettings()->IsReadingCookieAllowed(document_url,
plugin_url);
}
bool ChromeContentBrowserClient::AllowPluginLocalDataSessionOnly(
const GURL& url,
content::ResourceContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
return io_data->GetCookieSettings()->IsCookieSessionOnly(url);
}
bool ChromeContentBrowserClient::AllowSaveLocalState(
content::ResourceContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
......
......@@ -89,6 +89,13 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
int render_process_id,
int render_view_id,
net::CookieOptions* options) OVERRIDE;
virtual bool AllowPluginLocalDataAccess(
const GURL& document_url,
const GURL& plugin_url,
content::ResourceContext* context) OVERRIDE;
virtual bool AllowPluginLocalDataSessionOnly(
const GURL& url,
content::ResourceContext* context) OVERRIDE;
virtual bool AllowSaveLocalState(content::ResourceContext* context) OVERRIDE;
virtual bool AllowWorkerDatabase(
const GURL& url,
......
......@@ -182,6 +182,8 @@ if (process_type_ == PLUGIN) {
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_UpdateActivity, OnUpdateActivity)
IPC_MESSAGE_HANDLER(PepperMsg_GetDeviceID, OnGetDeviceID)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashDeviceID_Get, OnGetDeviceIDAsync)
IPC_MESSAGE_HANDLER(PepperMsg_GetLocalDataRestrictions,
OnGetLocalDataRestrictions)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
......@@ -714,6 +716,26 @@ void PepperMessageFilter::OnGetDeviceIDAsync(int32_t routing_id,
result));
}
void PepperMessageFilter::OnGetLocalDataRestrictions(
const GURL& document_url,
const GURL& plugin_url,
PP_FlashLSORestrictions* restrictions) {
content::ContentBrowserClient* client =
content::GetContentClient()->browser();
if (!client->AllowPluginLocalDataAccess(document_url, plugin_url,
resource_context_)) {
*restrictions = PP_FLASHLSORESTRICTIONS_BLOCK;
return;
}
if (client->AllowPluginLocalDataSessionOnly(plugin_url, resource_context_)) {
*restrictions = PP_FLASHLSORESTRICTIONS_IN_MEMORY;
return;
}
*restrictions = PP_FLASHLSORESTRICTIONS_NONE;
}
void PepperMessageFilter::GetFontFamiliesComplete(
IPC::Message* reply_msg,
scoped_ptr<base::ListValue> result) {
......
......@@ -23,6 +23,7 @@
#include "net/socket/stream_socket.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/private/ppb_flash.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
......@@ -219,6 +220,9 @@ class PepperMessageFilter
void OnUpdateActivity();
void OnGetDeviceID(std::string* id);
void OnGetDeviceIDAsync(int32_t routing_id, PP_Resource resource);
void OnGetLocalDataRestrictions(const GURL& document_url,
const GURL& plugin_url,
PP_FlashLSORestrictions* restrictions);
// Callback when the font list has been retrieved on a background thread.
void GetFontFamiliesComplete(IPC::Message* reply_msg,
......
......@@ -6,12 +6,15 @@
#include "content/common/content_export.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h"
#include "ppapi/c/private/ppb_flash.h"
#include "ppapi/proxy/ppapi_param_traits.h"
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
#define IPC_MESSAGE_START PepperMsgStart
IPC_ENUM_TRAITS(PP_FlashLSORestrictions)
// Pepper (non-file-system) messages sent from the renderer to the browser.
IPC_SYNC_MESSAGE_CONTROL1_1(PepperMsg_GetLocalTimeZoneOffset,
......@@ -20,3 +23,8 @@ IPC_SYNC_MESSAGE_CONTROL1_1(PepperMsg_GetLocalTimeZoneOffset,
IPC_SYNC_MESSAGE_CONTROL0_1(PepperMsg_GetDeviceID,
std::string /* id */)
IPC_SYNC_MESSAGE_CONTROL2_1(PepperMsg_GetLocalDataRestrictions,
GURL /* document_url */,
GURL /* plugin_url */,
PP_FlashLSORestrictions /* restrictions */)
......@@ -109,6 +109,19 @@ bool ContentBrowserClient::AllowSetCookie(const GURL& url,
return true;
}
bool ContentBrowserClient::AllowPluginLocalDataAccess(
const GURL& document_url,
const GURL& plugin_url,
content::ResourceContext* context) {
return true;
}
bool ContentBrowserClient::AllowPluginLocalDataSessionOnly(
const GURL& url,
content::ResourceContext* context) {
return false;
}
bool ContentBrowserClient::AllowSaveLocalState(ResourceContext* context) {
return true;
}
......
......@@ -207,6 +207,21 @@ class CONTENT_EXPORT ContentBrowserClient {
int render_view_id,
net::CookieOptions* options);
// Returns whether plug-ins should access locally stored data or whether all
// access should be blocked. The default is to allow local data access.
// This is called on the IO thread.
virtual bool AllowPluginLocalDataAccess(
const GURL& document_url,
const GURL& plugin_url,
content::ResourceContext* context);
// Returns whether plug-ins should keep locally stored data for the session
// only. The default is to store local data permanently.
// This is called on the IO thread.
virtual bool AllowPluginLocalDataSessionOnly(
const GURL& url,
content::ResourceContext* context);
// This is called on the IO thread.
virtual bool AllowSaveLocalState(ResourceContext* context);
......
......@@ -1402,6 +1402,16 @@ std::string PepperPluginDelegateImpl::GetDeviceID() {
return result;
}
PP_FlashLSORestrictions PepperPluginDelegateImpl::GetLocalDataRestrictions(
const GURL& document_url,
const GURL& plugin_url) {
PP_FlashLSORestrictions restrictions = PP_FLASHLSORESTRICTIONS_NONE;
render_view_->Send(
new PepperMsg_GetLocalDataRestrictions(document_url, plugin_url,
&restrictions));
return restrictions;
}
base::SharedMemory* PepperPluginDelegateImpl::CreateAnonymousSharedMemory(
uint32_t size) {
if (size == 0)
......
......@@ -379,6 +379,9 @@ class PepperPluginDelegateImpl
const EnumerateDevicesCallback& callback) OVERRIDE;
virtual webkit_glue::ClipboardClient* CreateClipboardClient() const OVERRIDE;
virtual std::string GetDeviceID() OVERRIDE;
virtual PP_FlashLSORestrictions GetLocalDataRestrictions(
const GURL& document_url,
const GURL& plugin_url) OVERRIDE;
// RenderViewObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
......
......@@ -16,6 +16,24 @@ label Chrome {
M22 = 12.5
};
[assert_size(4)]
enum PP_FlashLSORestrictions {
/**
* No restrictions on Flash LSOs.
*/
PP_FLASHLSORESTRICTIONS_NONE = 1,
/**
* Don't allow access to Flash LSOs.
*/
PP_FLASHLSORESTRICTIONS_BLOCK = 2,
/**
* Store Flash LSOs in memory only.
*/
PP_FLASHLSORESTRICTIONS_IN_MEMORY = 3
};
[assert_size(4)]
enum PP_FlashSetting {
/**
......@@ -62,7 +80,13 @@ enum PP_FlashSetting {
/**
* Specifies the number of CPU cores that are present on the system.
*/
PP_FLASHSETTING_NUMCORES = 5
PP_FLASHSETTING_NUMCORES = 5,
/**
* Specifies restrictions on how flash should handle LSOs. The result is an
* int from <code>PP_FlashLSORestrictions</code>.
*/
PP_FLASHSETTING_LSORESTRICTIONS = 6
};
/**
......
......@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
/* From private/ppb_flash.idl modified Mon Jun 25 12:46:59 2012. */
/* From private/ppb_flash.idl modified Mon Jul 30 22:15:54 2012. */
#ifndef PPAPI_C_PRIVATE_PPB_FLASH_H_
#define PPAPI_C_PRIVATE_PPB_FLASH_H_
......@@ -39,6 +39,22 @@
* @addtogroup Enums
* @{
*/
typedef enum {
/**
* No restrictions on Flash LSOs.
*/
PP_FLASHLSORESTRICTIONS_NONE = 1,
/**
* Don't allow access to Flash LSOs.
*/
PP_FLASHLSORESTRICTIONS_BLOCK = 2,
/**
* Store Flash LSOs in memory only.
*/
PP_FLASHLSORESTRICTIONS_IN_MEMORY = 3
} PP_FlashLSORestrictions;
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FlashLSORestrictions, 4);
typedef enum {
/**
* Specifies if the system likely supports 3D hardware acceleration.
......@@ -80,7 +96,12 @@ typedef enum {
/**
* Specifies the number of CPU cores that are present on the system.
*/
PP_FLASHSETTING_NUMCORES = 5
PP_FLASHSETTING_NUMCORES = 5,
/**
* Specifies restrictions on how flash should handle LSOs. The result is an
* int from <code>PP_FlashLSORestrictions</code>.
*/
PP_FLASHSETTING_LSORESTRICTIONS = 6
} PP_FlashSetting;
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FlashSetting, 4);
......
......@@ -31,6 +31,7 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_size.h"
#include "ppapi/c/pp_time.h"
#include "ppapi/c/private/ppb_flash.h"
#include "ppapi/c/private/ppb_host_resolver_private.h"
#include "ppapi/c/private/ppb_net_address_private.h"
#include "ppapi/c/private/ppb_tcp_socket_private.h"
......@@ -58,6 +59,7 @@
IPC_ENUM_TRAITS(PP_DeviceType_Dev)
IPC_ENUM_TRAITS(PP_Flash_BrowserOperations_Permission)
IPC_ENUM_TRAITS(PP_Flash_BrowserOperations_SettingType)
IPC_ENUM_TRAITS(PP_FlashSetting)
IPC_ENUM_TRAITS(PP_InputEvent_MouseButton)
IPC_ENUM_TRAITS(PP_InputEvent_Type)
IPC_ENUM_TRAITS(PP_NetAddressFamily_Private)
......@@ -1304,6 +1306,10 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBFlash_QueryFileRef,
ppapi::HostResource /* file_ref */,
PP_FileInfo /* info */,
int32_t /* result */)
IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_GetSetting,
PP_Instance /* instance */,
PP_FlashSetting /* setting */,
ppapi::proxy::SerializedVar /* result */)
IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBFlash_InvokePrinting,
PP_Instance /* instance */)
......
......@@ -126,6 +126,8 @@ bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgGetDeviceID)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting,
OnHostMsgInvokePrinting)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetSetting,
OnHostMsgGetSetting)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
// TODO(brettw) handle bad messages!
......@@ -304,6 +306,12 @@ PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance,
PluginGlobals::Get()->plugin_proxy_delegate()->GetUILanguage());
case PP_FLASHSETTING_NUMCORES:
return PP_MakeInt32(plugin_dispatcher->preferences().number_of_cpu_cores);
case PP_FLASHSETTING_LSORESTRICTIONS: {
ReceiveSerializedVarReturnValue result;
dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetSetting(
API_ID_PPB_FLASH, instance, setting, &result));
return result.Return(dispatcher());
}
}
return PP_MakeUndefined();
}
......@@ -831,6 +839,19 @@ void PPB_Flash_Proxy::OnHostMsgQueryFileRef(
instance, host_resource.host_resource(), info);
}
void PPB_Flash_Proxy::OnHostMsgGetSetting(PP_Instance instance,
PP_FlashSetting setting,
SerializedVarReturnValue id) {
EnterInstanceNoLock enter(instance);
if (enter.succeeded()) {
id.Return(dispatcher(),
enter.functions()->GetFlashAPI()->GetSetting(
instance, setting));
} else {
id.Return(dispatcher(), PP_MakeUndefined());
}
}
void PPB_Flash_Proxy::OnHostMsgGetDeviceID(PP_Instance instance,
SerializedVarReturnValue id) {
EnterInstanceNoLock enter(instance);
......
......@@ -178,6 +178,9 @@ class PPB_Flash_Proxy : public InterfaceProxy, public PPB_Flash_Shared {
int32_t* result);
void OnHostMsgGetDeviceID(PP_Instance instance,
SerializedVarReturnValue id);
void OnHostMsgGetSetting(PP_Instance instance,
PP_FlashSetting setting,
SerializedVarReturnValue result);
void OnHostMsgInvokePrinting(PP_Instance instance);
DISALLOW_COPY_AND_ASSIGN(PPB_Flash_Proxy);
......
......@@ -460,5 +460,11 @@ std::string MockPluginDelegate::GetDeviceID() {
return std::string();
}
PP_FlashLSORestrictions MockPluginDelegate::GetLocalDataRestrictions(
const GURL& document_url,
const GURL& plugin_url) {
return PP_FLASHLSORESTRICTIONS_NONE;
}
} // namespace ppapi
} // namespace webkit
......@@ -204,6 +204,9 @@ class MockPluginDelegate : public PluginDelegate {
const EnumerateDevicesCallback& callback);
virtual webkit_glue::ClipboardClient* CreateClipboardClient() const;
virtual std::string GetDeviceID();
virtual PP_FlashLSORestrictions GetLocalDataRestrictions(
const GURL& document_url,
const GURL& plugin_url);
};
} // namespace ppapi
......
......@@ -25,6 +25,7 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/private/ppb_flash.h"
#include "ppapi/shared_impl/dir_contents.h"
#include "ui/gfx/size.h"
#include "webkit/fileapi/file_system_types.h"
......@@ -664,6 +665,11 @@ class PluginDelegate {
// Returns a Device ID
virtual std::string GetDeviceID() = 0;
// Returns restrictions on local data handled by the plug-in.
virtual PP_FlashLSORestrictions GetLocalDataRestrictions(
const GURL& document_url,
const GURL& plugin_url) = 0;
};
} // namespace ppapi
......
......@@ -27,6 +27,9 @@
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkTemplates.h"
#include "third_party/skia/include/core/SkTypeface.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
#include "ui/gfx/rect.h"
#include "webkit/glue/clipboard_client.h"
#include "webkit/glue/scoped_clipboard_writer_glue.h"
......@@ -249,9 +252,18 @@ int32_t PPB_Flash_Impl::GetSettingInt(PP_Instance instance,
}
PP_Var PPB_Flash_Impl::GetSetting(PP_Instance instance,
PP_FlashSetting setting) {
// No current settings are supported in-process.
return PP_MakeUndefined();
PP_FlashSetting setting) {
switch(setting) {
case PP_FLASHSETTING_LSORESTRICTIONS: {
return PP_MakeInt32(
instance_->delegate()->GetLocalDataRestrictions(
instance_->container()->element().document().url(),
instance_->plugin_url()));
}
default:
// No other settings are supported in-process.
return PP_MakeUndefined();
}
}
PP_Bool PPB_Flash_Impl::SetCrashData(PP_Instance instance,
......
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