diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 16:39:23 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 16:39:23 +0000 |
commit | 657f4efd9e3a2716b7d634ead39bffa4a03ef57c (patch) | |
tree | 0e3d0f72f21d4fceae9a0d168763e9ecf76a2a30 /ppapi | |
parent | e8d45e0f903a649e04ce421a3b60146af4695f4d (diff) | |
download | chromium_src-657f4efd9e3a2716b7d634ead39bffa4a03ef57c.zip chromium_src-657f4efd9e3a2716b7d634ead39bffa4a03ef57c.tar.gz chromium_src-657f4efd9e3a2716b7d634ead39bffa4a03ef57c.tar.bz2 |
Remove untrusted scripting support.
BUG=82606
TEST=ppapi_tests,ppapi_unittests
Review URL: http://codereview.chromium.org/7362012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/c/ppb_instance.h | 28 | ||||
-rw-r--r-- | ppapi/c/ppp_instance.h | 35 | ||||
-rw-r--r-- | ppapi/cpp/instance.cc | 31 | ||||
-rw-r--r-- | ppapi/cpp/instance.h | 14 | ||||
-rw-r--r-- | ppapi/cpp/module.cc | 17 | ||||
-rw-r--r-- | ppapi/cpp/private/instance_private.cc | 2 | ||||
-rw-r--r-- | ppapi/cpp/private/instance_private.h | 2 | ||||
-rw-r--r-- | ppapi/cpp/var.cc | 207 | ||||
-rw-r--r-- | ppapi/cpp/var.h | 37 | ||||
-rw-r--r-- | ppapi/proxy/dispatcher.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_proxy_test.h | 4 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.cc | 18 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.h | 1 | ||||
-rw-r--r-- | ppapi/proxy/ppp_instance_proxy.cc | 43 | ||||
-rw-r--r-- | ppapi/proxy/ppp_instance_proxy.h | 5 | ||||
-rw-r--r-- | ppapi/proxy/ppp_instance_proxy_test.cc | 112 | ||||
-rw-r--r-- | ppapi/shared_impl/ppp_instance_combined.cc | 15 | ||||
-rw-r--r-- | ppapi/shared_impl/ppp_instance_combined.h | 3 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_thunk.cc | 11 | ||||
-rw-r--r-- | ppapi/thunk/thunk.h | 7 |
21 files changed, 24 insertions, 573 deletions
diff --git a/ppapi/c/ppb_instance.h b/ppapi/c/ppb_instance.h index dbda74d6..b2fa404 100644 --- a/ppapi/c/ppb_instance.h +++ b/ppapi/c/ppb_instance.h @@ -8,16 +8,10 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_var.h" -#define PPB_INSTANCE_INTERFACE_0_4 "PPB_Instance;0.4" #define PPB_INSTANCE_INTERFACE_0_5 "PPB_Instance;0.5" #define PPB_INSTANCE_INTERFACE_1_0 "PPB_Instance;1.0" -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING #define PPB_INSTANCE_INTERFACE PPB_INSTANCE_INTERFACE_1_0 -#else -#define PPB_INSTANCE_INTERFACE PPB_INSTANCE_INTERFACE_0_4 -#endif /** * @file @@ -35,11 +29,7 @@ * */ -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING struct PPB_Instance { -#else -struct PPB_Instance_1_0 { -#endif /** * BindGraphics() binds the given graphics as the current drawing surface. * The contents of this device is what will be displayed in the module's @@ -86,25 +76,7 @@ struct PPB_Instance_1_0 { }; -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING -struct PPB_Instance_0_4 { -#else -struct PPB_Instance { -#endif - struct PP_Var (*GetWindowObject)(PP_Instance instance); - struct PP_Var (*GetOwnerElementObject)(PP_Instance instance); - PP_Bool (*BindGraphics)(PP_Instance instance, PP_Resource device); - PP_Bool (*IsFullFrame)(PP_Instance instance); - struct PP_Var (*ExecuteScript)(PP_Instance instance, - struct PP_Var script, - struct PP_Var* exception); -}; - -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING typedef struct PPB_Instance PPB_Instance_1_0; -#else -typedef struct PPB_Instance PPB_Instance_0_4; -#endif /** * @} diff --git a/ppapi/c/ppp_instance.h b/ppapi/c/ppp_instance.h index 52ad9cb..3fd8263 100644 --- a/ppapi/c/ppp_instance.h +++ b/ppapi/c/ppp_instance.h @@ -11,16 +11,9 @@ #include "ppapi/c/pp_resource.h" struct PP_InputEvent; -struct PP_Var; -#define PPP_INSTANCE_INTERFACE_0_4 "PPP_Instance;0.4" #define PPP_INSTANCE_INTERFACE_0_5 "PPP_Instance;0.5" -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING #define PPP_INSTANCE_INTERFACE PPP_INSTANCE_INTERFACE_0_5 -#else -#define PPP_INSTANCE_INTERFACE PPP_INSTANCE_INTERFACE_0_4 -#endif - /** * @file @@ -40,11 +33,7 @@ struct PP_Var; * events. */ -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING struct PPP_Instance { -#else -struct PPP_Instance_0_5 { -#endif /** * DidCreate() is a creation handler that is called when a new instance is * created. This function is called for each instantiation on the page, @@ -231,35 +220,11 @@ struct PPP_Instance_0_5 { PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); }; -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING -struct PPP_Instance_0_4 { -#else -struct PPP_Instance { -#endif - PP_Bool (*DidCreate)(PP_Instance instance, - uint32_t argc, - const char* argn[], - const char* argv[]); - void (*DidDestroy)(PP_Instance instance); - void (*DidChangeView)(PP_Instance instance, - const struct PP_Rect* position, - const struct PP_Rect* clip); - void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); - PP_Bool (*HandleInputEvent)(PP_Instance instance, - const struct PP_InputEvent* event); - PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); - struct PP_Var (*GetInstanceObject)(PP_Instance instance); -}; - /** * @} */ -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING typedef struct PPP_Instance PPP_Instance_0_5; -#else -typedef struct PPP_Instance PPP_Instance_0_4; -#endif #endif /* PPAPI_C_PPP_INSTANCE_H_ */ diff --git a/ppapi/cpp/instance.cc b/ppapi/cpp/instance.cc index ea1e6d5..5cf4e35 100644 --- a/ppapi/cpp/instance.cc +++ b/ppapi/cpp/instance.cc @@ -78,37 +78,6 @@ void Instance::HandleMessage(const Var& /*message*/) { return; } -#ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING -Var Instance::GetWindowObject() { - if (!has_interface<PPB_Instance>()) - return Var(); - return Var(Var::PassRef(), - get_interface<PPB_Instance>()->GetWindowObject(pp_instance())); -} - -Var Instance::GetOwnerElementObject() { - if (!has_interface<PPB_Instance>()) - return Var(); - return Var(Var::PassRef(), - get_interface<PPB_Instance>()->GetOwnerElementObject( - pp_instance())); -} - -Var Instance::ExecuteScript(const Var& script, Var* exception) { - if (!has_interface<PPB_Instance>()) - return Var(); - return Var(Var::PassRef(), - get_interface<PPB_Instance>()->ExecuteScript( - pp_instance(), - script.pp_var(), - Var::OutException(exception).get())); -} - -Var Instance::GetInstanceObject() { - return Var(); -} -#endif - bool Instance::BindGraphics(const Graphics2D& graphics) { if (!has_interface<PPB_Instance>()) return false; diff --git a/ppapi/cpp/instance.h b/ppapi/cpp/instance.h index 03c3259..a55660e 100644 --- a/ppapi/cpp/instance.h +++ b/ppapi/cpp/instance.h @@ -185,20 +185,6 @@ class Instance { /// @{ /// @name PPB_Instance methods for querying the browser: -#ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING - /// See PPP_Instance.GetInstanceObject. - virtual Var GetInstanceObject(); - - /// See PPB_Instance.GetWindowObject. - Var GetWindowObject(); - - /// See PPB_Instance.GetOwnerElementObject. - Var GetOwnerElementObject(); - - /// See PPB_Instance.ExecuteScript. - Var ExecuteScript(const Var& script, Var* exception = NULL); -#endif - /// See PPB_Instance.BindGraphics. bool BindGraphics(const Graphics2D& graphics); diff --git a/ppapi/cpp/module.cc b/ppapi/cpp/module.cc index 412a38f..927710a 100644 --- a/ppapi/cpp/module.cc +++ b/ppapi/cpp/module.cc @@ -132,28 +132,13 @@ PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, return PP_FromBool(instance->HandleDocumentLoad(URLLoader(pp_url_loader))); } -#ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING -PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { - Module* module_singleton = Module::Get(); - if (!module_singleton) - return Var().Detach(); - Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); - if (!instance) - return Var().Detach(); - return instance->GetInstanceObject().Detach(); -} -#endif - static PPP_Instance instance_interface = { &Instance_DidCreate, &Instance_DidDestroy, &Instance_DidChangeView, &Instance_DidChangeFocus, &Instance_HandleInputEvent, - &Instance_HandleDocumentLoad, -#ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING - &Instance_GetInstanceObject -#endif + &Instance_HandleDocumentLoad }; // PPP_Messaging implementation ------------------------------------------------ diff --git a/ppapi/cpp/private/instance_private.cc b/ppapi/cpp/private/instance_private.cc index 9bf8135..ad6e1a2 100644 --- a/ppapi/cpp/private/instance_private.cc +++ b/ppapi/cpp/private/instance_private.cc @@ -43,11 +43,9 @@ InstancePrivate::InstancePrivate(PP_Instance instance) : Instance(instance) { InstancePrivate::~InstancePrivate() {} -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING Var InstancePrivate::GetInstanceObject() { return Var(); } -#endif VarPrivate InstancePrivate::GetWindowObject() { if (!has_interface<PPB_Instance_Private>()) diff --git a/ppapi/cpp/private/instance_private.h b/ppapi/cpp/private/instance_private.h index 2d7add8..d658f0b 100644 --- a/ppapi/cpp/private/instance_private.h +++ b/ppapi/cpp/private/instance_private.h @@ -28,10 +28,8 @@ class InstancePrivate : public Instance { // @{ /// @name PPP_Instance_Private methods for the plugin to override: -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING /// See PPP_Instance_Private.GetInstanceObject. virtual Var GetInstanceObject(); -#endif // @} diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc index bedd257..8df9b67 100644 --- a/ppapi/cpp/var.cc +++ b/ppapi/cpp/var.cc @@ -9,17 +9,12 @@ #include <algorithm> -#include "ppapi/c/dev/ppb_memory_dev.h" -#ifndef PPAPI_VAR_REMOVE_SCRIPTING -# include "ppapi/c/dev/ppb_var_deprecated.h" -#endif #include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_var.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/logging.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" -#include "ppapi/cpp/dev/scriptable_object_deprecated.h" // Define equivalent to snprintf on Windows. #if defined(_MSC_VER) @@ -34,16 +29,6 @@ template <> const char* interface_name<PPB_Var>() { return PPB_VAR_INTERFACE; } -#ifdef PPAPI_VAR_REMOVE_SCRIPTING -typedef PPB_Var PPB_Var_Interface_Type; -#else -typedef PPB_Var_Deprecated PPB_Var_Interface_Type; - -template <> const char* interface_name<PPB_Var_Deprecated>() { - return PPB_VAR_DEPRECATED_INTERFACE; -} -#endif - // Technically you can call AddRef and Release on any Var, but it may involve // cross-process calls depending on the plugin. This is an optimization so we // only do refcounting on the necessary objects. @@ -53,8 +38,6 @@ inline bool NeedsRefcounting(const PP_Var& var) { } // namespace -using namespace deprecated; - Var::Var() { memset(&var_, 0, sizeof(var_)); var_.type = PP_VARTYPE_UNDEFINED; @@ -89,10 +72,10 @@ Var::Var(double d) { } Var::Var(const char* utf8_str) { - if (has_interface<PPB_Var_Interface_Type>()) { + if (has_interface<PPB_Var>()) { uint32_t len = utf8_str ? static_cast<uint32_t>(strlen(utf8_str)) : 0; - var_ = get_interface<PPB_Var_Interface_Type>()->VarFromUtf8( - Module::Get()->pp_module(), utf8_str, len); + var_ = get_interface<PPB_Var>()->VarFromUtf8(Module::Get()->pp_module(), + utf8_str, len); } else { var_.type = PP_VARTYPE_NULL; var_.padding = 0; @@ -101,8 +84,8 @@ Var::Var(const char* utf8_str) { } Var::Var(const std::string& utf8_str) { - if (has_interface<PPB_Var_Interface_Type>()) { - var_ = get_interface<PPB_Var_Interface_Type>()->VarFromUtf8( + if (has_interface<PPB_Var>()) { + var_ = get_interface<PPB_Var>()->VarFromUtf8( Module::Get()->pp_module(), utf8_str.c_str(), static_cast<uint32_t>(utf8_str.size())); @@ -116,9 +99,9 @@ Var::Var(const std::string& utf8_str) { Var::Var(const Var& other) { var_ = other.var_; if (NeedsRefcounting(var_)) { - if (has_interface<PPB_Var_Interface_Type>()) { + if (has_interface<PPB_Var>()) { needs_release_ = true; - get_interface<PPB_Var_Interface_Type>()->AddRef(var_); + get_interface<PPB_Var>()->AddRef(var_); } else { var_.type = PP_VARTYPE_NULL; needs_release_ = false; @@ -129,18 +112,18 @@ Var::Var(const Var& other) { } Var::~Var() { - if (needs_release_ && has_interface<PPB_Var_Interface_Type>()) - get_interface<PPB_Var_Interface_Type>()->Release(var_); + if (needs_release_ && has_interface<PPB_Var>()) + get_interface<PPB_Var>()->Release(var_); } Var& Var::operator=(const Var& other) { - if (needs_release_ && has_interface<PPB_Var_Interface_Type>()) - get_interface<PPB_Var_Interface_Type>()->Release(var_); + if (needs_release_ && has_interface<PPB_Var>()) + get_interface<PPB_Var>()->Release(var_); var_ = other.var_; if (NeedsRefcounting(var_)) { - if (has_interface<PPB_Var_Interface_Type>()) { + if (has_interface<PPB_Var>()) { needs_release_ = true; - get_interface<PPB_Var_Interface_Type>()->AddRef(var_); + get_interface<PPB_Var>()->AddRef(var_); } else { var_.type = PP_VARTYPE_NULL; needs_release_ = false; @@ -205,173 +188,13 @@ std::string Var::AsString() const { return std::string(); } - if (!has_interface<PPB_Var_Interface_Type>()) + if (!has_interface<PPB_Var>()) return std::string(); uint32_t len; - const char* str = - get_interface<PPB_Var_Interface_Type>()->VarToUtf8(var_, &len); + const char* str = get_interface<PPB_Var>()->VarToUtf8(var_, &len); return std::string(str, len); } -#ifndef PPAPI_VAR_REMOVE_SCRIPTING -Var::Var(Instance* instance, ScriptableObject* object) { - if (has_interface<PPB_Var_Deprecated>()) { - var_ = get_interface<PPB_Var_Deprecated>()->CreateObject( - instance->pp_instance(), object->GetClass(), object); - needs_release_ = true; - } else { - var_.type = PP_VARTYPE_NULL; - var_.padding = 0; - needs_release_ = false; - } -} - -ScriptableObject* Var::AsScriptableObject() const { - if (!is_object()) { - PP_NOTREACHED(); - } else if (has_interface<PPB_Var_Deprecated>()) { - void* object = NULL; - if (get_interface<PPB_Var_Deprecated>()->IsInstanceOf( - var_, ScriptableObject::GetClass(), &object)) { - return reinterpret_cast<ScriptableObject*>(object); - } - } - return NULL; -} - -bool Var::HasProperty(const Var& name, Var* exception) const { - if (!has_interface<PPB_Var_Deprecated>()) - return false; - return get_interface<PPB_Var_Deprecated>()->HasProperty( - var_, name.var_, OutException(exception).get()); -} - -bool Var::HasMethod(const Var& name, Var* exception) const { - if (!has_interface<PPB_Var_Deprecated>()) - return false; - return get_interface<PPB_Var_Deprecated>()->HasMethod( - var_, name.var_, OutException(exception).get()); -} - -Var Var::GetProperty(const Var& name, Var* exception) const { - if (!has_interface<PPB_Var_Deprecated>()) - return Var(); - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->GetProperty( - var_, name.var_, OutException(exception).get())); -} - -void Var::GetAllPropertyNames(std::vector<Var>* properties, - Var* exception) const { - if (!has_interface<PPB_Var_Deprecated>()) - return; - PP_Var* props = NULL; - uint32_t prop_count = 0; - get_interface<PPB_Var_Deprecated>()->GetAllPropertyNames( - var_, &prop_count, &props, OutException(exception).get()); - if (!prop_count) - return; - properties->resize(prop_count); - for (uint32_t i = 0; i < prop_count; ++i) { - Var temp(PassRef(), props[i]); - (*properties)[i] = temp; - } - const PPB_Memory_Dev* memory_if = static_cast<const PPB_Memory_Dev*>( - pp::Module::Get()->GetBrowserInterface(PPB_MEMORY_DEV_INTERFACE)); - memory_if->MemFree(props); -} - -void Var::SetProperty(const Var& name, const Var& value, Var* exception) { - if (!has_interface<PPB_Var_Deprecated>()) - return; - get_interface<PPB_Var_Deprecated>()->SetProperty( - var_, name.var_, value.var_, OutException(exception).get()); -} - -void Var::RemoveProperty(const Var& name, Var* exception) { - if (!has_interface<PPB_Var_Deprecated>()) - return; - get_interface<PPB_Var_Deprecated>()->RemoveProperty( - var_, name.var_, OutException(exception).get()); -} - -Var Var::Call(const Var& method_name, uint32_t argc, Var* argv, - Var* exception) { - if (!has_interface<PPB_Var_Deprecated>()) - return Var(); - if (argc > 0) { - std::vector<PP_Var> args; - args.reserve(argc); - for (size_t i = 0; i < argc; i++) - args.push_back(argv[i].var_); - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->Call( - var_, method_name.var_, argc, &args[0], OutException(exception).get())); - } else { - // Don't try to get the address of a vector if it's empty. - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->Call( - var_, method_name.var_, 0, NULL, OutException(exception).get())); - } -} - -Var Var::Construct(uint32_t argc, Var* argv, Var* exception) const { - if (!has_interface<PPB_Var_Deprecated>()) - return Var(); - if (argc > 0) { - std::vector<PP_Var> args; - args.reserve(argc); - for (size_t i = 0; i < argc; i++) - args.push_back(argv[i].var_); - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->Construct( - var_, argc, &args[0], OutException(exception).get())); - } else { - // Don't try to get the address of a vector if it's empty. - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->Construct( - var_, 0, NULL, OutException(exception).get())); - } -} - -Var Var::Call(const Var& method_name, Var* exception) { - if (!has_interface<PPB_Var_Deprecated>()) - return Var(); - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->Call( - var_, method_name.var_, 0, NULL, OutException(exception).get())); -} - -Var Var::Call(const Var& method_name, const Var& arg1, Var* exception) { - if (!has_interface<PPB_Var_Deprecated>()) - return Var(); - PP_Var args[1] = {arg1.var_}; - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->Call( - var_, method_name.var_, 1, args, OutException(exception).get())); -} - -Var Var::Call(const Var& method_name, const Var& arg1, const Var& arg2, - Var* exception) { - if (!has_interface<PPB_Var_Deprecated>()) - return Var(); - PP_Var args[2] = {arg1.var_, arg2.var_}; - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->Call( - var_, method_name.var_, 2, args, OutException(exception).get())); -} - -Var Var::Call(const Var& method_name, const Var& arg1, const Var& arg2, - const Var& arg3, Var* exception) { - if (!has_interface<PPB_Var_Deprecated>()) - return Var(); - PP_Var args[3] = {arg1.var_, arg2.var_, arg3.var_}; - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->Call( - var_, method_name.var_, 3, args, OutException(exception).get())); -} - -Var Var::Call(const Var& method_name, const Var& arg1, const Var& arg2, - const Var& arg3, const Var& arg4, Var* exception) { - if (!has_interface<PPB_Var_Deprecated>()) - return Var(); - PP_Var args[4] = {arg1.var_, arg2.var_, arg3.var_, arg4.var_}; - return Var(PassRef(), get_interface<PPB_Var_Deprecated>()->Call( - var_, method_name.var_, 4, args, OutException(exception).get())); -} -#endif - std::string Var::DebugString() const { char buf[256]; if (is_undefined()) { diff --git a/ppapi/cpp/var.h b/ppapi/cpp/var.h index 17bb0b8..a4dfb33 100644 --- a/ppapi/cpp/var.h +++ b/ppapi/cpp/var.h @@ -15,12 +15,6 @@ namespace pp { class Instance; -#ifndef PPAPI_VAR_REMOVE_SCRIPTING -namespace deprecated { -class ScriptableObject; -} -#endif - class Var { public: struct Null {}; // Special value passed to constructor to make NULL. @@ -100,37 +94,6 @@ class Var { // in debug mode, and return an empty string. std::string AsString() const; -#ifndef PPAPI_VAR_REMOVE_SCRIPTING - // Takes ownership of the given pointer. - Var(Instance* instance, deprecated::ScriptableObject* object); - - // This assumes the object is of type object. If it's not, it will assert in - // debug mode. If it is not an object or not a ScriptableObject type, returns - // NULL. - deprecated::ScriptableObject* AsScriptableObject() const; - - bool HasProperty(const Var& name, Var* exception = NULL) const; - bool HasMethod(const Var& name, Var* exception = NULL) const; - Var GetProperty(const Var& name, Var* exception = NULL) const; - void GetAllPropertyNames(std::vector<Var>* properties, - Var* exception = NULL) const; - void SetProperty(const Var& name, const Var& value, Var* exception = NULL); - void RemoveProperty(const Var& name, Var* exception = NULL); - Var Call(const Var& method_name, uint32_t argc, Var* argv, - Var* exception = NULL); - Var Construct(uint32_t argc, Var* argv, Var* exception = NULL) const; - - // Convenience functions for calling functions with small # of args. - Var Call(const Var& method_name, Var* exception = NULL); - Var Call(const Var& method_name, const Var& arg1, Var* exception = NULL); - Var Call(const Var& method_name, const Var& arg1, const Var& arg2, - Var* exception = NULL); - Var Call(const Var& method_name, const Var& arg1, const Var& arg2, - const Var& arg3, Var* exception = NULL); - Var Call(const Var& method_name, const Var& arg1, const Var& arg2, - const Var& arg3, const Var& arg4, Var* exception = NULL); -#endif // ifndef PPAPI_VAR_REMOVE_SCRIPTING - // Returns a const reference to the PP_Var managed by this Var object. const PP_Var& pp_var() const { return var_; diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc index e9b57c3..69e16ac 100644 --- a/ppapi/proxy/dispatcher.cc +++ b/ppapi/proxy/dispatcher.cc @@ -139,7 +139,6 @@ InterfaceList::InterfaceList() { AddPPB(PPB_Graphics2D_Proxy::GetInfo()); AddPPB(PPB_ImageData_Proxy::GetInfo()); AddPPB(PPB_InputEvent_Proxy::GetInfo()); - AddPPB(PPB_Instance_Proxy::GetInfo0_4()); AddPPB(PPB_Instance_Proxy::GetInfo0_5()); AddPPB(PPB_Instance_Proxy::GetInfo1_0()); AddPPB(PPB_Instance_Proxy::GetInfoFullscreen()); @@ -166,7 +165,6 @@ InterfaceList::InterfaceList() { AddPPP(PPP_Graphics3D_Proxy::GetInfo()); AddPPP(PPP_InputEvent_Proxy::GetInfo()); AddPPP(PPP_Instance_Private_Proxy::GetInfo()); - AddPPP(PPP_Instance_Proxy::GetInfo0_4()); AddPPP(PPP_Instance_Proxy::GetInfo0_5()); } diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 0eb8258..c516514 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -296,9 +296,6 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiMsg_PPPInstance_HandleDocumentLoad, PP_Instance /* instance */, pp::proxy::HostResource /* url_loader */, PP_Bool /* result */) -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPInstance_GetInstanceObject, - PP_Instance /* instance */, - pp::proxy::SerializedVar /* result */) // PPP_Instance_Private. IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPInstancePrivate_GetInstanceObject, diff --git a/ppapi/proxy/ppapi_proxy_test.h b/ppapi/proxy/ppapi_proxy_test.h index 373f8e3..775b75c 100644 --- a/ppapi/proxy/ppapi_proxy_test.h +++ b/ppapi/proxy/ppapi_proxy_test.h @@ -137,6 +137,8 @@ class PluginProxyTest : public PluginProxyTestHarness, public testing::Test { // testing::Test implementation. virtual void SetUp(); virtual void TearDown(); + private: + MessageLoop message_loop_; }; class HostProxyTestHarness : public ProxyTestHarnessBase { @@ -191,6 +193,8 @@ class HostProxyTest : public HostProxyTestHarness, public testing::Test { // testing::Test implementation. virtual void SetUp(); virtual void TearDown(); + private: + MessageLoop message_loop_; }; // Use this base class to test both sides of a proxy. diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 5a6158a..7bb6ba1 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -47,18 +47,6 @@ PPB_Instance_Proxy::~PPB_Instance_Proxy() { } // static -const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo0_4() { - static const Info info = { - ppapi::thunk::GetPPB_Instance_0_4_Thunk(), - PPB_INSTANCE_INTERFACE_0_4, - INTERFACE_ID_NONE, // 1_0 is the canonical one. - false, - &CreateInstanceProxy, - }; - return &info; -} - -// static const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo0_5() { static const Info info = { ppapi::thunk::GetPPB_Instance_1_0_Thunk(), @@ -87,7 +75,7 @@ const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoMessaging() { static const Info info = { ppapi::thunk::GetPPB_Messaging_Thunk(), PPB_MESSAGING_INTERFACE, - INTERFACE_ID_NONE, // 0_5 is the canonical one. + INTERFACE_ID_NONE, // 1_0 is the canonical one. false, &CreateInstanceProxy, }; @@ -99,7 +87,7 @@ const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { static const Info info = { ppapi::thunk::GetPPB_Instance_Private_Thunk(), PPB_INSTANCE_PRIVATE_INTERFACE, - INTERFACE_ID_NONE, // 0_5 is the canonical one. + INTERFACE_ID_NONE, // 1_0 is the canonical one. false, &CreateInstanceProxy, }; @@ -111,7 +99,7 @@ const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoFullscreen() { static const Info info = { ppapi::thunk::GetPPB_Fullscreen_Thunk(), PPB_FULLSCREEN_DEV_INTERFACE, - INTERFACE_ID_NONE, // 0_5 is the canonical one. + INTERFACE_ID_NONE, // 1_0 is the canonical one. false, &CreateInstanceProxy, }; diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index 9d045fb..fc2dac3 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -29,7 +29,6 @@ class PPB_Instance_Proxy : public InterfaceProxy, PPB_Instance_Proxy(Dispatcher* dispatcher, const void* target_interface); virtual ~PPB_Instance_Proxy(); - static const Info* GetInfo0_4(); static const Info* GetInfo0_5(); static const Info* GetInfo1_0(); static const Info* GetInfoMessaging(); diff --git a/ppapi/proxy/ppp_instance_proxy.cc b/ppapi/proxy/ppp_instance_proxy.cc index b09055d..99dcaab 100644 --- a/ppapi/proxy/ppp_instance_proxy.cc +++ b/ppapi/proxy/ppp_instance_proxy.cc @@ -112,24 +112,6 @@ PP_Bool HandleDocumentLoad(PP_Instance instance, return result; } -PP_Var GetInstanceObject(PP_Instance instance) { - Dispatcher* dispatcher = HostDispatcher::GetForInstance(instance); - ReceiveSerializedVarReturnValue result; - dispatcher->Send(new PpapiMsg_PPPInstance_GetInstanceObject( - INTERFACE_ID_PPP_INSTANCE, instance, &result)); - return result.Return(dispatcher); -} - -static const PPP_Instance_0_4 instance_interface_0_4 = { - &DidCreate, - &DidDestroy, - &DidChangeView, - &DidChangeFocus, - &HandleInputEvent, - &HandleDocumentLoad, - &GetInstanceObject -}; - static const PPP_Instance_0_5 instance_interface_0_5 = { &DidCreate, &DidDestroy, @@ -153,18 +135,6 @@ PPP_Instance_Proxy::~PPP_Instance_Proxy() { } // static -const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo0_4() { - static const Info info = { - &instance_interface_0_4, - PPP_INSTANCE_INTERFACE_0_4, - INTERFACE_ID_PPP_INSTANCE, - false, - &CreateInstanceProxy<PPP_Instance_0_4> - }; - return &info; -} - -// static const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo0_5() { static const Info info = { &instance_interface_0_5, @@ -191,8 +161,6 @@ bool PPP_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnMsgHandleInputEvent) IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_HandleDocumentLoad, OnMsgHandleDocumentLoad) - IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_GetInstanceObject, - OnMsgGetInstanceObject) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -278,16 +246,5 @@ void PPP_Instance_Proxy::OnMsgHandleDocumentLoad(PP_Instance instance, PluginResourceTracker::GetInstance()->ReleaseResource(plugin_loader); } -void PPP_Instance_Proxy::OnMsgGetInstanceObject( - PP_Instance instance, - SerializedVarReturnValue result) { - // GetInstanceObject_0_4 can be null if we're talking to version 0.5 or later, - // however the host side of the proxy should never call this function on an - // 0.5 or later version. - DCHECK(combined_interface_->GetInstanceObject_0_4); - result.Return(dispatcher(), - combined_interface_->GetInstanceObject_0_4(instance)); -} - } // namespace proxy } // namespace pp diff --git a/ppapi/proxy/ppp_instance_proxy.h b/ppapi/proxy/ppp_instance_proxy.h index e4ef2ba..9448332 100644 --- a/ppapi/proxy/ppp_instance_proxy.h +++ b/ppapi/proxy/ppp_instance_proxy.h @@ -35,9 +35,6 @@ class PPP_Instance_Proxy : public InterfaceProxy { } virtual ~PPP_Instance_Proxy(); - // Return the info for the 0.4 version of the interface. - static const Info* GetInfo0_4(); - // Return the info for the 0.5 (latest, canonical) version of the interface. static const Info* GetInfo0_5(); @@ -66,8 +63,6 @@ class PPP_Instance_Proxy : public InterfaceProxy { void OnMsgHandleDocumentLoad(PP_Instance instance, const HostResource& url_loader, PP_Bool* result); - void OnMsgGetInstanceObject(PP_Instance instance, - SerializedVarReturnValue result); scoped_ptr< ::ppapi::PPP_Instance_Combined> combined_interface_; }; diff --git a/ppapi/proxy/ppp_instance_proxy_test.cc b/ppapi/proxy/ppp_instance_proxy_test.cc index b545dd7..00d776b 100644 --- a/ppapi/proxy/ppp_instance_proxy_test.cc +++ b/ppapi/proxy/ppp_instance_proxy_test.cc @@ -95,16 +95,6 @@ void ResetReceived() { memset(&received_event, 0, sizeof(received_event)); } -PPP_Instance_0_4 ppp_instance_0_4 = { - &DidCreate, - &DidDestroy, - &DidChangeView, - &DidChangeFocus, - &HandleInputEvent, - &HandleDocumentLoad, - &GetInstanceObject -}; - PPP_Instance_0_5 ppp_instance_0_5 = { &DidCreate, &DidDestroy, @@ -130,108 +120,6 @@ class PPP_Instance_ProxyTest : public TwoWayTest { } }; -TEST_F(PPP_Instance_ProxyTest, PPPInstance0_4) { - plugin().RegisterTestInterface(PPP_INSTANCE_INTERFACE_0_4, &ppp_instance_0_4); - host().RegisterTestInterface(PPB_FULLSCREEN_DEV_INTERFACE, - &ppb_fullscreen_dev); - - // Try requesting the 0.5 version, like the browser does. This should come - // back NULL, since we're not registering 0.5. But this ensures that the - // behavior through the proxy code reflects more closely what happens for a - // real plug-in. - const void* interface = - host().host_dispatcher()->GetProxiedInterface(PPP_INSTANCE_INTERFACE_0_5); - EXPECT_EQ(NULL, interface); - - // Grab the host-side proxy for the 0.4 interface. - const PPP_Instance_0_4* ppp_instance = static_cast<const PPP_Instance_0_4*>( - host().host_dispatcher()->GetProxiedInterface( - PPP_INSTANCE_INTERFACE_0_4)); - - // Call each function in turn, make sure we get the expected values and - // returns. - // - // We don't test DidDestroy, because it has the side-effect of removing the - // PP_Instance from the PluginDispatcher, which will cause a failure later - // when the test is torn down. - PP_Instance expected_instance = pp_instance(); - std::vector<std::string> expected_argn, expected_argv; - expected_argn.push_back("Hello"); - expected_argn.push_back("world."); - expected_argv.push_back("elloHay"); - expected_argv.push_back("orldway."); - std::vector<const char*> argn_to_pass, argv_to_pass; - CHECK(expected_argn.size() == expected_argv.size()); - for (size_t i = 0; i < expected_argn.size(); ++i) { - argn_to_pass.push_back(expected_argn[i].c_str()); - argv_to_pass.push_back(expected_argv[i].c_str()); - } - uint32_t expected_argc = expected_argn.size(); - bool_to_return = PP_TRUE; - ResetReceived(); - EXPECT_EQ(bool_to_return, ppp_instance->DidCreate(expected_instance, - expected_argc, - &argn_to_pass[0], - &argv_to_pass[0])); - EXPECT_EQ(received_instance, expected_instance); - EXPECT_EQ(received_argc, expected_argc); - EXPECT_EQ(received_argn, expected_argn); - EXPECT_EQ(received_argv, expected_argv); - - PP_Rect expected_position = { {1, 2}, {3, 4} }; - PP_Rect expected_clip = { {5, 6}, {7, 8} }; - ResetReceived(); - ppp_instance->DidChangeView(expected_instance, &expected_position, - &expected_clip); - did_change_view_called.Wait(); - EXPECT_EQ(received_instance, expected_instance); - // If I define operator== for PP_Rect, it has to come before gtest's template - // definitions in the translation unit, or else it's not found. So instead of - // defining operator== before the #include that brings in gtest, I compare the - // individual parts. - EXPECT_EQ(received_position.point.x, expected_position.point.x); - EXPECT_EQ(received_position.point.y, expected_position.point.y); - EXPECT_EQ(received_position.size.width, expected_position.size.width); - EXPECT_EQ(received_position.size.height, expected_position.size.height); - EXPECT_EQ(received_clip.point.x, expected_clip.point.x); - EXPECT_EQ(received_clip.point.y, expected_clip.point.y); - EXPECT_EQ(received_clip.size.width, expected_clip.size.width); - EXPECT_EQ(received_clip.size.height, expected_clip.size.height); - - PP_Bool expected_has_focus = PP_TRUE; - ResetReceived(); - ppp_instance->DidChangeFocus(expected_instance, expected_has_focus); - did_change_focus_called.Wait(); - EXPECT_EQ(received_instance, expected_instance); - EXPECT_EQ(received_has_focus, expected_has_focus); - - PP_InputEvent expected_event = { PP_INPUTEVENT_TYPE_KEYDOWN, // type - 0, // padding - 1.0, // time_stamp - { { 2, 3 } } }; // u (as PP_InputEvent_Key) - ResetReceived(); - EXPECT_EQ(bool_to_return, - ppp_instance->HandleInputEvent(expected_instance, &expected_event)); - EXPECT_EQ(received_instance, expected_instance); - ASSERT_EQ(received_event.type, expected_event.type); - // Ignore padding; it's okay if it's not serialized. - EXPECT_EQ(received_event.time_stamp, expected_event.time_stamp); - EXPECT_EQ(received_event.u.key.modifier, expected_event.u.key.modifier); - EXPECT_EQ(received_event.u.key.key_code, expected_event.u.key.key_code); - - // TODO(dmichael): Need to mock out a resource Tracker to be able to test - // HandleResourceLoad. It also requires - // PPB_Core.AddRefResource and for PPB_URLLoader to be - // registered. - - var_to_return = PP_MakeInt32(100); - ResetReceived(); - PP_Var result(ppp_instance->GetInstanceObject(expected_instance)); - ASSERT_EQ(var_to_return.type, result.type); - EXPECT_EQ(var_to_return.value.as_int, result.value.as_int); - EXPECT_EQ(received_instance, expected_instance); -} - TEST_F(PPP_Instance_ProxyTest, PPPInstance0_5) { plugin().RegisterTestInterface(PPP_INSTANCE_INTERFACE_0_5, &ppp_instance_0_5); host().RegisterTestInterface(PPB_FULLSCREEN_DEV_INTERFACE, diff --git a/ppapi/shared_impl/ppp_instance_combined.cc b/ppapi/shared_impl/ppp_instance_combined.cc index 8da13af..ce3d2c4 100644 --- a/ppapi/shared_impl/ppp_instance_combined.cc +++ b/ppapi/shared_impl/ppp_instance_combined.cc @@ -8,20 +8,7 @@ namespace ppapi { PPP_Instance_Combined::PPP_Instance_Combined( const PPP_Instance_0_5& instance_if) - : PPP_Instance_0_5(instance_if), - GetInstanceObject_0_4(NULL) { -} - -PPP_Instance_Combined::PPP_Instance_Combined( - const PPP_Instance_0_4& instance_if) - : PPP_Instance_0_5(), // Zero-initialize. - GetInstanceObject_0_4(instance_if.GetInstanceObject) { - DidCreate = instance_if.DidCreate; - DidDestroy = instance_if.DidDestroy; - DidChangeView = instance_if.DidChangeView; - DidChangeFocus = instance_if.DidChangeFocus; - HandleInputEvent = instance_if.HandleInputEvent; - HandleDocumentLoad = instance_if.HandleDocumentLoad; + : PPP_Instance_0_5(instance_if) { } } // namespace ppapi diff --git a/ppapi/shared_impl/ppp_instance_combined.h b/ppapi/shared_impl/ppp_instance_combined.h index a186c06..33548d5 100644 --- a/ppapi/shared_impl/ppp_instance_combined.h +++ b/ppapi/shared_impl/ppp_instance_combined.h @@ -13,9 +13,6 @@ namespace ppapi { struct PPP_Instance_Combined : public PPP_Instance_0_5 { public: explicit PPP_Instance_Combined(const PPP_Instance_0_5& instance_if); - explicit PPP_Instance_Combined(const PPP_Instance_0_4& instance_if); - - PP_Var (*const GetInstanceObject_0_4)(PP_Instance instance); DISALLOW_COPY_AND_ASSIGN(PPP_Instance_Combined); }; diff --git a/ppapi/thunk/ppb_instance_thunk.cc b/ppapi/thunk/ppb_instance_thunk.cc index 3d7ef60..a05f030 100644 --- a/ppapi/thunk/ppb_instance_thunk.cc +++ b/ppapi/thunk/ppb_instance_thunk.cc @@ -54,14 +54,6 @@ const PPB_Instance_1_0 g_ppb_instance_1_0_thunk = { &IsFullFrame }; -const PPB_Instance_0_4 g_ppb_instance_0_4_thunk = { - &GetWindowObject, - &GetOwnerElementObject, - &BindGraphics, - &IsFullFrame, - &ExecuteScript -}; - const PPB_Instance_Private g_ppb_instance_private_thunk = { &GetWindowObject, &GetOwnerElementObject, @@ -70,9 +62,6 @@ const PPB_Instance_Private g_ppb_instance_private_thunk = { } // namespace -const PPB_Instance_0_4* GetPPB_Instance_0_4_Thunk() { - return &g_ppb_instance_0_4_thunk; -} const PPB_Instance_1_0* GetPPB_Instance_1_0_Thunk() { return &g_ppb_instance_1_0_thunk; } diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index e03a8e1..91484e1 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -52,13 +52,7 @@ struct PPB_WheelInputEvent; struct PPB_Widget_Dev; struct PPB_Zoom_Dev; -#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING -struct PPB_Instance_0_4; typedef PPB_Instance PPB_Instance_1_0; -#else -struct PPB_Instance_1_0; -typedef PPB_Instance PPB_Instance_0_4; -#endif namespace ppapi { namespace thunk { @@ -92,7 +86,6 @@ const PPB_Graphics3D_Dev* GetPPB_Graphics3D_Thunk(); const PPB_InputEvent* GetPPB_InputEvent_Thunk(); const PPB_ImageData* GetPPB_ImageData_Thunk(); const PPB_ImageDataTrusted* GetPPB_ImageDataTrusted_Thunk(); -const PPB_Instance_0_4* GetPPB_Instance_0_4_Thunk(); const PPB_Instance_1_0* GetPPB_Instance_1_0_Thunk(); const PPB_Instance_Private* GetPPB_Instance_Private_Thunk(); const PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk(); |