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

Side by Side Diff: remoting/host/host_plugin_utils.cc

Issue 7210025: Split host plugin into multiple files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge gary's changes Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/host_plugin_utils.h ('k') | remoting/host/host_script_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/host/host_plugin_utils.h"
6
7 namespace remoting {
8
9 NPNetscapeFuncs* g_npnetscape_funcs = NULL;
10
11 std::string StringFromNPIdentifier(NPIdentifier identifier) {
12 if (!g_npnetscape_funcs->identifierisstring(identifier))
13 return std::string();
14 NPUTF8* np_string = g_npnetscape_funcs->utf8fromidentifier(identifier);
15 std::string string(np_string);
16 g_npnetscape_funcs->memfree(np_string);
17 return string;
18 }
19
20 std::string StringFromNPVariant(const NPVariant& variant) {
21 if (!NPVARIANT_IS_STRING(variant))
22 return std::string();
23 const NPString& np_string = NPVARIANT_TO_STRING(variant);
24 return std::string(np_string.UTF8Characters, np_string.UTF8Length);
25 }
26
27 NPVariant NPVariantFromString(const std::string& val) {
28 size_t len = val.length();
29 NPUTF8* chars =
30 reinterpret_cast<NPUTF8*>(g_npnetscape_funcs->memalloc(len + 1));
31 strcpy(chars, val.c_str());
32 NPVariant variant;
33 STRINGN_TO_NPVARIANT(chars, len, variant);
34 return variant;
35 }
36
37 NPObject* ObjectFromNPVariant(const NPVariant& variant) {
38 if (!NPVARIANT_IS_OBJECT(variant))
39 return NULL;
40 return NPVARIANT_TO_OBJECT(variant);
41 }
42
43 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_plugin_utils.h ('k') | remoting/host/host_script_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698