summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-19 14:49:32 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-19 14:49:32 +0000
commit8cef2068010fa12968211e3721d60d4d5fd3d4e9 (patch)
tree63907b7fd8fc28fd2d9a343772edb66a79a4d19a /ppapi
parent304d682f570f60644c97fea6d86bc303ba6b2ac5 (diff)
downloadchromium_src-8cef2068010fa12968211e3721d60d4d5fd3d4e9.zip
chromium_src-8cef2068010fa12968211e3721d60d4d5fd3d4e9.tar.gz
chromium_src-8cef2068010fa12968211e3721d60d4d5fd3d4e9.tar.bz2
Rename Instance_Trusted to Instance_Private, wire it up in Chrome.
Add C++ InstancePrivate. BUG=None TEST=PPAPI tests Review URL: http://codereview.chromium.org/6871040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/private/ppb_instance_private.h (renamed from ppapi/c/trusted/ppb_instance_trusted.h)14
-rw-r--r--ppapi/c/private/ppp_instance_private.h (renamed from ppapi/c/trusted/ppp_instance_trusted.h)14
-rw-r--r--ppapi/cpp/private/instance_private.cc72
-rw-r--r--ppapi/cpp/private/instance_private.h60
-rw-r--r--ppapi/cpp/private/var_private.cc4
-rw-r--r--ppapi/cpp/private/var_private.h4
-rw-r--r--ppapi/example/example.cc13
-rw-r--r--ppapi/ppapi_cpp.gypi6
-rw-r--r--ppapi/tests/all_c_includes.h4
-rw-r--r--ppapi/tests/all_cpp_includes.h4
10 files changed, 167 insertions, 28 deletions
diff --git a/ppapi/c/trusted/ppb_instance_trusted.h b/ppapi/c/private/ppb_instance_private.h
index 44c9f77..730d909 100644
--- a/ppapi/c/trusted/ppb_instance_trusted.h
+++ b/ppapi/c/private/ppb_instance_private.h
@@ -2,17 +2,17 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef PPAPI_C_TRUSTED_PPB_INSTANCE_TRUSTED_H_
-#define PPAPI_C_TRUSTED_PPB_INSTANCE_TRUSTED_H_
+#ifndef PPAPI_C_PRIVATE_PPB_INSTANCE_PRIVATE_H_
+#define PPAPI_C_PRIVATE_PPB_INSTANCE_PRIVATE_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_var.h"
-#define PPB_INSTANCE_TRUSTED_INTERFACE "PPB_Instance_Trusted;0.1"
+#define PPB_INSTANCE_PRIVATE_INTERFACE "PPB_Instance_Private;0.1"
/**
* @file
- * This file defines the PPB_Instance_Trusted interface implemented by the
+ * This file defines the PPB_Instance_Private interface implemented by the
* browser and containing pointers to functions available only to trusted plugin
* instances.
*
@@ -21,11 +21,11 @@
*/
/**
- * The PPB_Instance_Trusted interface contains functions available only to
+ * The PPB_Instance_Private interface contains functions available only to
* trusted plugin instances.
*
*/
-struct PPB_Instance_Trusted {
+struct PPB_Instance_Private {
/**
* GetWindowObject is a pointer to a function that determines
* the DOM window containing this module instance.
@@ -70,5 +70,5 @@ struct PPB_Instance_Trusted {
* @}
*/
-#endif /* PPAPI_C_TRUSTED_PPB_INSTANCE_TRUSTED_H_ */
+#endif /* PPAPI_C_PRIVATE_PPB_INSTANCE_PRIVATE_H_ */
diff --git a/ppapi/c/trusted/ppp_instance_trusted.h b/ppapi/c/private/ppp_instance_private.h
index b010db4..e587d26 100644
--- a/ppapi/c/trusted/ppp_instance_trusted.h
+++ b/ppapi/c/private/ppp_instance_private.h
@@ -2,18 +2,18 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef PPAPI_C_TRUSTED_PPP_INSTANCE_TRUSTED_H_
-#define PPAPI_C_TRUSTED_PPP_INSTANCE_TRUSTED_H_
+#ifndef PPAPI_C_PRIVATE_PPP_INSTANCE_PRIVATE_H_
+#define PPAPI_C_PRIVATE_PPP_INSTANCE_PRIVATE_H_
#include "ppapi/c/pp_instance.h"
struct PP_Var;
-#define PPP_INSTANCE_TRUSTED_INTERFACE "PPP_Instance_Trusted;0.1"
+#define PPP_INSTANCE_PRIVATE_INTERFACE "PPP_Instance_Private;0.1"
/**
* @file
- * This file defines the PPP_InstanceTrusted structure; a series of functions
+ * This file defines the PPP_InstancePrivate structure; a series of functions
* that a trusted plugin may implement to provide capabilities only available
* to trusted plugins.
*
@@ -24,12 +24,12 @@ struct PP_Var;
*/
/**
- * The PPP_Instance_Trusted interface contains pointers to a series of
+ * The PPP_Instance_Private interface contains pointers to a series of
* functions that may be implemented in a trusted plugin to provide capabilities
* that aren't possible in untrusted modules.
*/
-struct PPP_Instance_Trusted {
+struct PPP_Instance_Private {
/**
* GetInstanceObject returns a PP_Var representing the scriptable object for
* the given instance. Normally this will be a PPP_Class_Deprecated object
@@ -50,5 +50,5 @@ struct PPP_Instance_Trusted {
* @}
*/
-#endif /* PPAPI_C_TRUSTED_PPP_INSTANCE_TRUSTED_H_ */
+#endif /* PPAPI_C_PRIVATE_PPP_INSTANCE_PRIVATE_H_ */
diff --git a/ppapi/cpp/private/instance_private.cc b/ppapi/cpp/private/instance_private.cc
new file mode 100644
index 0000000..2a924a3
--- /dev/null
+++ b/ppapi/cpp/private/instance_private.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/private/instance_private.h"
+
+#include "ppapi/c/private/ppb_instance_private.h"
+#include "ppapi/c/private/ppp_instance_private.h"
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/private/var_private.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Instance_Private>() {
+ return PPB_INSTANCE_PRIVATE_INTERFACE;
+}
+
+PP_Var GetInstanceObject(PP_Instance pp_instance) {
+ Module* module_singleton = Module::Get();
+ if (!module_singleton)
+ return Var().Detach();
+ InstancePrivate* instance_private = static_cast<InstancePrivate*>(
+ module_singleton->InstanceForPPInstance(pp_instance));
+ if (!instance_private)
+ return Var().Detach();
+ return instance_private->GetInstanceObject().Detach();
+}
+
+const PPP_Instance_Private ppp_instance_private = {
+ &GetInstanceObject
+};
+
+} // namespace
+
+InstancePrivate::InstancePrivate(PP_Instance instance) : Instance(instance) {
+ // If at least 1 InstancePrivate is created, register the PPP_INSTANCE_PRIVATE
+ // interface.
+ Module::Get()->AddPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE,
+ &ppp_instance_private);
+}
+
+InstancePrivate::~InstancePrivate() {}
+
+VarPrivate InstancePrivate::GetWindowObject() {
+ if (!has_interface<PPB_Instance_Private>())
+ return VarPrivate();
+ return VarPrivate(Var::PassRef(),
+ get_interface<PPB_Instance_Private>()->GetWindowObject(pp_instance()));
+}
+
+VarPrivate InstancePrivate::GetOwnerElementObject() {
+ if (!has_interface<PPB_Instance_Private>())
+ return VarPrivate();
+ return VarPrivate(Var::PassRef(),
+ get_interface<PPB_Instance_Private>()->GetOwnerElementObject(
+ pp_instance()));
+}
+
+VarPrivate InstancePrivate::ExecuteScript(const VarPrivate& script,
+ VarPrivate* exception) {
+ if (!has_interface<PPB_Instance_Private>())
+ return VarPrivate();
+ return VarPrivate(Var::PassRef(),
+ get_interface<PPB_Instance_Private>()->ExecuteScript(
+ pp_instance(),
+ script.pp_var(),
+ VarPrivate::OutException(exception).get()));
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/private/instance_private.h b/ppapi/cpp/private/instance_private.h
new file mode 100644
index 0000000..226494c
--- /dev/null
+++ b/ppapi/cpp/private/instance_private.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_PRIVATE_INSTANCE_PRIVATE_H_
+#define PPAPI_CPP_PRIVATE_INSTANCE_PRIVATE_H_
+
+/**
+ * @file
+ * Defines the API ...
+ *
+ * @addtogroup CPP
+ * @{
+ */
+
+#include "ppapi/cpp/instance.h"
+
+/** The C++ interface to the Pepper API. */
+namespace pp {
+
+class VarPrivate;
+
+class InstancePrivate : public Instance {
+ public:
+ explicit InstancePrivate(PP_Instance instance);
+ virtual ~InstancePrivate();
+
+ // @{
+ /// @name PPP_Instance_Private methods for the plugin to override:
+
+ /// See PPP_Instance_Private.GetInstanceObject.
+ // TODO(dmichael): Put this virtual function here and remove the
+ // 'Var GetInstanceObject()' version from pp::Instance.
+ //virtual VarPrivate GetInstanceObject();
+
+ // @}
+
+ // @{
+ /// @name PPB_Instance_Private methods for querying the browser:
+
+ /// See PPB_Instance_Private.GetWindowObject.
+ VarPrivate GetWindowObject();
+
+ /// See PPB_Instance_Private.GetOwnerElementObject.
+ VarPrivate GetOwnerElementObject();
+
+ /// See PPB_Instance.ExecuteScript.
+ VarPrivate ExecuteScript(const VarPrivate& script,
+ VarPrivate* exception = NULL);
+
+ // @}
+};
+
+} // namespace pp
+
+/**
+ * @}
+ * End addtogroup CPP
+ */
+#endif // PPAPI_CPP_PRIVATE_INSTANCE_PRIVATE_H_
diff --git a/ppapi/cpp/private/var_private.cc b/ppapi/cpp/private/var_private.cc
index c3da55d..5db0aa3 100644
--- a/ppapi/cpp/private/var_private.cc
+++ b/ppapi/cpp/private/var_private.cc
@@ -5,7 +5,7 @@
#include "ppapi/cpp/private/var_private.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
-#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/private/instance_private.h"
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/module_impl.h"
#include "ppapi/cpp/dev/scriptable_object_deprecated.h"
@@ -22,7 +22,7 @@ template <> const char* interface_name<PPB_Var_Deprecated>() {
using namespace deprecated;
-VarPrivate::VarPrivate(Instance* instance, ScriptableObject* object) {
+VarPrivate::VarPrivate(InstancePrivate* instance, ScriptableObject* object) {
if (has_interface<PPB_Var_Deprecated>()) {
var_ = get_interface<PPB_Var_Deprecated>()->CreateObject(
instance->pp_instance(), object->GetClass(), object);
diff --git a/ppapi/cpp/private/var_private.h b/ppapi/cpp/private/var_private.h
index 55068bc..5ab1e07b 100644
--- a/ppapi/cpp/private/var_private.h
+++ b/ppapi/cpp/private/var_private.h
@@ -9,6 +9,8 @@
namespace pp {
+class InstancePrivate;
+
// VarPrivate is a version of Var that exposes the private scripting API.
// It's designed to be mostly interchangable with Var since most callers will
// be dealing with Vars from various places.
@@ -23,7 +25,7 @@ class VarPrivate : public Var {
VarPrivate(const std::string& utf8_str) : Var(utf8_str) {}
VarPrivate(PassRef, PP_Var var) : Var(PassRef(), var) {}
VarPrivate(DontManage, PP_Var var) : Var(DontManage(), var) {}
- VarPrivate(Instance* instance, deprecated::ScriptableObject* object);
+ VarPrivate(InstancePrivate* instance, deprecated::ScriptableObject* object);
VarPrivate(const Var& other) : Var(other) {}
virtual ~VarPrivate() {}
diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc
index d660bc4..6f5c950 100644
--- a/ppapi/example/example.cc
+++ b/ppapi/example/example.cc
@@ -23,7 +23,7 @@
#include "ppapi/cpp/dev/scriptable_object_deprecated.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
-#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/private/instance_private.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/private/var_private.h"
#include "ppapi/cpp/rect.h"
@@ -48,7 +48,8 @@ void FillRect(pp::ImageData* image, int left, int top, int width, int height,
class MyScriptableObject : public pp::deprecated::ScriptableObject {
public:
- explicit MyScriptableObject(pp::Instance* instance) : instance_(instance) {}
+ explicit MyScriptableObject(pp::InstancePrivate* instance)
+ : instance_(instance) {}
virtual bool HasMethod(const pp::Var& method, pp::Var* exception) {
return method.AsString() == "toString";
@@ -80,7 +81,7 @@ class MyScriptableObject : public pp::deprecated::ScriptableObject {
}
private:
- pp::Instance* instance_;
+ pp::InstancePrivate* instance_;
};
class MyFetcherClient {
@@ -94,7 +95,7 @@ class MyFetcher {
callback_factory_.Initialize(this);
}
- void Start(const pp::Instance& instance,
+ void Start(const pp::InstancePrivate& instance,
const pp::Var& url,
MyFetcherClient* client) {
pp::URLRequestInfo request;
@@ -157,10 +158,10 @@ class MyFetcher {
std::string data_;
};
-class MyInstance : public pp::Instance, public MyFetcherClient {
+class MyInstance : public pp::InstancePrivate, public MyFetcherClient {
public:
MyInstance(PP_Instance instance)
- : pp::Instance(instance),
+ : pp::InstancePrivate(instance),
time_at_last_check_(0.0),
fetcher_(NULL),
width_(0),
diff --git a/ppapi/ppapi_cpp.gypi b/ppapi/ppapi_cpp.gypi
index 259fdaad..4ce6d01 100644
--- a/ppapi/ppapi_cpp.gypi
+++ b/ppapi/ppapi_cpp.gypi
@@ -90,9 +90,11 @@
'c/private/ppb_flash_file.h',
'c/private/ppb_flash_menu.h',
'c/private/ppb_flash_net_connector.h',
+ 'c/private/ppb_instance_private.h',
'c/private/ppb_nacl_private.h',
'c/private/ppb_pdf.h',
'c/private/ppb_proxy_private.h',
+ 'c/private/ppp_instance_private.h',
# Deprecated interfaces.
'c/dev/deprecated_bool.h',
@@ -103,10 +105,8 @@
'c/trusted/ppb_audio_trusted.h',
'c/trusted/ppb_image_data_trusted.h',
'c/trusted/ppb_broker_trusted.h',
- 'c/trusted/ppb_instance_trusted.h',
'c/trusted/ppb_url_loader_trusted.h',
'c/trusted/ppp_broker.h',
- 'c/trusted/ppp_instance_trusted.h',
],
},
{
@@ -210,6 +210,8 @@
'cpp/dev/scriptable_object_deprecated.cc',
# Private interfaces.
+ 'cpp/private/instance_private.cc',
+ 'cpp/private/instance_private.h',
'cpp/private/var_private.cc',
'cpp/private/var_private.h',
],
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index 62f2f96..ab68dd1 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -80,13 +80,13 @@
#include "ppapi/c/ppp_messaging.h"
#include "ppapi/c/private/ppb_flash.h"
#include "ppapi/c/private/ppb_flash_menu.h"
+#include "ppapi/c/private/ppb_instance_private.h"
#include "ppapi/c/private/ppb_nacl_private.h"
#include "ppapi/c/private/ppb_pdf.h"
+#include "ppapi/c/private/ppp_instance_private.h"
#include "ppapi/c/trusted/ppb_audio_trusted.h"
#include "ppapi/c/trusted/ppb_image_data_trusted.h"
-#include "ppapi/c/trusted/ppb_instance_trusted.h"
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
-#include "ppapi/c/trusted/ppp_instance_trusted.h"
#endif /* PPAPI_TESTS_ALL_C_INCLUDES_H_ */
diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h
index 5860f65..91862fe 100644
--- a/ppapi/tests/all_cpp_includes.h
+++ b/ppapi/tests/all_cpp_includes.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -46,6 +46,8 @@
#include "ppapi/cpp/non_thread_safe_ref_count.h"
#include "ppapi/cpp/paint_aggregator.h"
#include "ppapi/cpp/paint_manager.h"
+#include "ppapi/cpp/private/instance_private.cc"
+#include "ppapi/cpp/private/instance_private.h"
#include "ppapi/cpp/point.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/resource.h"