summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 18:37:04 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 18:37:04 +0000
commit95cfdc807c92568d9c9d99ba0c3de5a53c02dee1 (patch)
treeffcf6381969e520eeb9bddea98d19ce3541fb9ed /ppapi
parentbe21444e83285f8087371a50dc3c45c956a75605 (diff)
downloadchromium_src-95cfdc807c92568d9c9d99ba0c3de5a53c02dee1.zip
chromium_src-95cfdc807c92568d9c9d99ba0c3de5a53c02dee1.tar.gz
chromium_src-95cfdc807c92568d9c9d99ba0c3de5a53c02dee1.tar.bz2
Remove scripting from PPP_Instance and PPB_Instance (behind precompiler flag).
Create 0.5 versions of the instance interfaces that are the default only if PPAPI_INSTANCE_REMOVE_SCRIPTING is defined. This is so [hopefully] plugins can opt in to the new version and migrate to InstancePrivate/VarPrivate more easily. BUG=82606 TEST=PPAPI tests Review URL: http://codereview.chromium.org/7038044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86458 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/ppb_instance.h58
-rw-r--r--ppapi/c/ppp_instance.h52
-rw-r--r--ppapi/cpp/instance.cc30
-rw-r--r--ppapi/cpp/instance.h14
-rw-r--r--ppapi/cpp/module.cc4
5 files changed, 87 insertions, 71 deletions
diff --git a/ppapi/c/ppb_instance.h b/ppapi/c/ppb_instance.h
index e63eff4..09e8c99 100644
--- a/ppapi/c/ppb_instance.h
+++ b/ppapi/c/ppb_instance.h
@@ -11,7 +11,12 @@
#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"
+#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING
+#define PPB_INSTANCE_INTERFACE PPB_INSTANCE_INTERFACE_0_5
+#else
#define PPB_INSTANCE_INTERFACE PPB_INSTANCE_INTERFACE_0_4
+#endif
/**
* @file
@@ -28,25 +33,12 @@
* related to the module instance on a web page.
*
*/
-struct PPB_Instance {
- /**
- * GetWindowObject is a pointer to a function that determines
- * the DOM window containing this module instance.
- *
- * @param[in] instance A PP_Instance whose WindowObject should be retrieved.
- * @return A PP_Var containing window object on success.
- */
- struct PP_Var (*GetWindowObject)(PP_Instance instance);
-
- /**
- * GetOwnerElementObject is a pointer to a function that determines
- * the DOM element containing this module instance.
- *
- * @param[in] instance A PP_Instance whose WindowObject should be retrieved.
- * @return A PP_Var containing DOM element on success.
- */
- struct PP_Var (*GetOwnerElementObject)(PP_Instance instance);
+#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING
+struct PPB_Instance {
+#else
+struct PPB_Instance_0_5 {
+#endif
/**
* BindGraphics is a pointer to a function that binds the given
* graphics as the current drawing surface. The
@@ -87,28 +79,22 @@ struct PPB_Instance {
*/
PP_Bool (*IsFullFrame)(PP_Instance instance);
- /**
- * ExecuteScript is a pointer to a function that executes the given
- * script in the context of the frame containing the module.
- *
- * The exception, if any, will be returned in *exception. As with the PPB_Var
- * interface, the exception parameter, if non-NULL, must be initialized
- * to a void exception or the function will immediately return. On success,
- * the exception parameter will be set to a "void" var. On failure, the
- * return value will be a "void" var.
- *
- * @param[in] script A string containing the JavaScript to execute.
- * @param[in/out] exception PP_Var containing the exception. Initialize
- * this to NULL if you don't want exception info; initialize this to a void
- * exception if want exception info.
- *
- * @return The result of the script execution, or a "void" var
- * if execution failed.
- */
+};
+
+#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);
};
+
/**
* @}
*/
diff --git a/ppapi/c/ppp_instance.h b/ppapi/c/ppp_instance.h
index b0f2f30..26f9614 100644
--- a/ppapi/c/ppp_instance.h
+++ b/ppapi/c/ppp_instance.h
@@ -13,7 +13,14 @@
struct PP_InputEvent;
struct PP_Var;
-#define PPP_INSTANCE_INTERFACE "PPP_Instance;0.4"
+#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
@@ -33,7 +40,11 @@ struct PP_Var;
* events.
*/
+#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING
struct PPP_Instance {
+#else
+struct PPP_Instance_0_5 {
+#endif
/**
* This value represents a pointer to a function that is called when a new
* module is instantiated on the web page. The identifier of the new
@@ -159,26 +170,37 @@ struct PPP_Instance {
* @return PP_TRUE if the data was handled, PP_FALSE otherwise.
*/
PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader);
+};
- /**
- * This value represents a pointer to a function that returns a Var
- * representing the scriptable object for the given instance. Normally
- * this will be a PPP_Class object that exposes certain methods the page
- * may want to call.
- *
- * On Failure, the returned var should be a "void" var.
- *
- * The returned PP_Var should have a reference added for the caller, which
- * will be responsible for Release()ing that reference.
- *
- * @param[in] instance A PP_Instance indentifying one instance of a module.
- * @return A PP_Var containing scriptable object.
- */
+#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 12cfc02..985e9b7 100644
--- a/ppapi/cpp/instance.cc
+++ b/ppapi/cpp/instance.cc
@@ -70,14 +70,11 @@ void Instance::HandleMessage(const Var& /*message*/) {
return;
}
-Var Instance::GetInstanceObject() {
- return Var();
-}
-
Var Instance::GetSelectedText(bool /* html */) {
return Var();
}
+#ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING
Var Instance::GetWindowObject() {
if (!has_interface<PPB_Instance>())
return Var();
@@ -93,6 +90,21 @@ Var 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;
@@ -114,16 +126,6 @@ bool Instance::IsFullFrame() {
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()));
-}
-
void Instance::PostMessage(const Var& message) {
if (!has_interface<PPB_Messaging>())
return;
diff --git a/ppapi/cpp/instance.h b/ppapi/cpp/instance.h
index 81d4176..5d0844db 100644
--- a/ppapi/cpp/instance.h
+++ b/ppapi/cpp/instance.h
@@ -69,9 +69,6 @@ class Instance {
/** See PPP_Instance.HandleDocumentLoad. */
virtual bool HandleDocumentLoad(const URLLoader& url_loader);
- /** See PPP_Instance.GetInstanceObject. */
- virtual Var GetInstanceObject();
-
/** See PPP_Instance.GetSelectedText. */
virtual Var GetSelectedText(bool html);
// @}
@@ -79,12 +76,20 @@ 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);
@@ -94,9 +99,6 @@ class Instance {
/** See PPB_Instance.IsFullFrame. */
bool IsFullFrame();
- /** See PPB_Instance.ExecuteScript. */
- Var ExecuteScript(const Var& script, Var* exception = NULL);
-
// These functions use the PPP_Messaging and PPB_Messaging interfaces, so that
// messaging can be done conveniently for a pp::Instance without using a
// separate C++ class.
diff --git a/ppapi/cpp/module.cc b/ppapi/cpp/module.cc
index 3883a5c2..6791d0a 100644
--- a/ppapi/cpp/module.cc
+++ b/ppapi/cpp/module.cc
@@ -115,6 +115,7 @@ PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance,
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)
@@ -124,6 +125,7 @@ PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) {
return Var().Detach();
return instance->GetInstanceObject().Detach();
}
+#endif
static PPP_Instance instance_interface = {
&Instance_DidCreate,
@@ -132,7 +134,9 @@ static PPP_Instance instance_interface = {
&Instance_DidChangeFocus,
&Instance_HandleInputEvent,
&Instance_HandleDocumentLoad,
+#ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING
&Instance_GetInstanceObject
+#endif
};
void Messaging_HandleMessage(PP_Instance pp_instance, PP_Var var) {