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

Unified Diff: remoting/host/plugin/host_plugin_utils.cc

Issue 340993002: Revert of Remove NPAPI plugin from chromoting webapp. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | « remoting/host/plugin/host_plugin_utils.h ('k') | remoting/host/plugin/host_script_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/plugin/host_plugin_utils.cc
diff --git a/remoting/host/plugin/host_plugin_utils.cc b/remoting/host/plugin/host_plugin_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d8061cf621e49846e2a0cfff60f3484173eeada4
--- /dev/null
+++ b/remoting/host/plugin/host_plugin_utils.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2012 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 "remoting/host/plugin/host_plugin_utils.h"
+
+namespace remoting {
+
+NPNetscapeFuncs* g_npnetscape_funcs = NULL;
+
+std::string StringFromNPIdentifier(NPIdentifier identifier) {
+ if (!g_npnetscape_funcs->identifierisstring(identifier))
+ return std::string();
+ NPUTF8* np_string = g_npnetscape_funcs->utf8fromidentifier(identifier);
+ std::string string(np_string);
+ g_npnetscape_funcs->memfree(np_string);
+ return string;
+}
+
+std::string StringFromNPVariant(const NPVariant& variant) {
+ if (!NPVARIANT_IS_STRING(variant))
+ return std::string();
+ const NPString& np_string = NPVARIANT_TO_STRING(variant);
+ return std::string(np_string.UTF8Characters, np_string.UTF8Length);
+}
+
+NPVariant NPVariantFromString(const std::string& val) {
+ size_t len = val.length();
+ NPUTF8* chars =
+ reinterpret_cast<NPUTF8*>(g_npnetscape_funcs->memalloc(len + 1));
+ strcpy(chars, val.c_str());
+ NPVariant variant;
+ STRINGN_TO_NPVARIANT(chars, len, variant);
+ return variant;
+}
+
+NPObject* ObjectFromNPVariant(const NPVariant& variant) {
+ if (!NPVARIANT_IS_OBJECT(variant))
+ return NULL;
+ return NPVARIANT_TO_OBJECT(variant);
+}
+
+ScopedRefNPObject::ScopedRefNPObject() : object_(NULL) { }
+
+ScopedRefNPObject::ScopedRefNPObject(NPObject* object)
+ : object_(NULL) {
+ *this = object;
+}
+
+ScopedRefNPObject::ScopedRefNPObject(const ScopedRefNPObject& object)
+ : object_(NULL) {
+ *this = object;
+}
+
+ScopedRefNPObject::~ScopedRefNPObject() {
+ *this = NULL;
+}
+
+ScopedRefNPObject& ScopedRefNPObject::operator=(NPObject* object) {
+ if (object) {
+ g_npnetscape_funcs->retainobject(object);
+ }
+ if (object_) {
+ g_npnetscape_funcs->releaseobject(object_);
+ }
+ object_ = object;
+ return *this;
+}
+
+ScopedRefNPObject& ScopedRefNPObject::operator=(
+ const ScopedRefNPObject& object) {
+ return *this = object.get();
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/plugin/host_plugin_utils.h ('k') | remoting/host/plugin/host_script_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698