Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2403)

Unified Diff: ppapi/cpp/private/instance_private.cc

Issue 6871040: Rename Instance_Trusted to Instance_Private, wire it up in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix up based on review comments. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/private/instance_private.h ('k') | ppapi/cpp/private/var_private.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/private/instance_private.cc
diff --git a/ppapi/cpp/private/instance_private.cc b/ppapi/cpp/private/instance_private.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2a924a31e7175c46086655f84c3ce4587ffe382b
--- /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
« no previous file with comments | « ppapi/cpp/private/instance_private.h ('k') | ppapi/cpp/private/var_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698