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

Side by Side Diff: webkit/glue/plugins/test/plugin_test.cc

Issue 1661: port some parts of webkit/glue/plugins/test to Linux... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 3 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/string_util.h"
5 #include "webkit/glue/plugins/test/plugin_test.h" 6 #include "webkit/glue/plugins/test/plugin_test.h"
6 #include "webkit/glue/plugins/test/npapi_constants.h" 7 #include "webkit/glue/plugins/test/npapi_constants.h"
7 8
8 namespace NPAPIClient { 9 namespace NPAPIClient {
9 10
10 PluginTest::PluginTest(NPP id, NPNetscapeFuncs *host_functions) { 11 PluginTest::PluginTest(NPP id, NPNetscapeFuncs *host_functions) {
11 id_ = id; 12 id_ = id;
12 id_->pdata = this; 13 id_->pdata = this;
13 host_functions_ = host_functions; 14 host_functions_ = host_functions;
14 } 15 }
(...skipping 10 matching lines...) Expand all
25 } 26 }
26 27
27 // It's a shame I have to implement URLEncode. But, using webkit's 28 // It's a shame I have to implement URLEncode. But, using webkit's
28 // or using chrome's means a ball of string of dlls and dependencies that 29 // or using chrome's means a ball of string of dlls and dependencies that
29 // is very very long. After spending far too much time on it, 30 // is very very long. After spending far too much time on it,
30 // I'll just encode it myself. Too bad Microsoft doesn't implement 31 // I'll just encode it myself. Too bad Microsoft doesn't implement
31 // this in a reusable way either. Both webkit and chrome will 32 // this in a reusable way either. Both webkit and chrome will
32 // end up using libicu, which is a string of dependencies we don't 33 // end up using libicu, which is a string of dependencies we don't
33 // want. 34 // want.
34 35
35 inline BYTE toHex(const BYTE &x) { 36 inline unsigned char toHex(const unsigned char &x) {
36 return x > 9 ? x + 55: x + 48; 37 return x > 9 ? x + 55: x + 48;
Mark Mentovai 2008/09/16 17:53:36 Existing code, but I think this is far less obtuse
37 } 38 }
38 39
39 std::string URLEncode(const std::string &sIn) { 40 std::string URLEncode(const std::string &sIn) {
40 std::string sOut; 41 std::string sOut;
41 42
42 const size_t length = sIn.length(); 43 const size_t length = sIn.length();
43 for (size_t idx = 0; idx < length;) { 44 for (size_t idx = 0; idx < length;) {
44 const char ch = sIn.at(idx); 45 const char ch = sIn.at(idx);
45 if (isalnum(ch)) { 46 if (isalnum(ch)) {
46 sOut.append(1, ch); 47 sOut.append(1, ch);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 82 }
82 script_url = URLEncode(script_url); 83 script_url = URLEncode(script_url);
83 script_result.append("javascript:"); 84 script_result.append("javascript:");
84 script_result.append(script_url); 85 script_result.append(script_url);
85 host_functions_->geturl(id_, script_result.c_str(), "_self"); 86 host_functions_->geturl(id_, script_result.c_str(), "_self");
86 } 87 }
87 88
88 const char *PluginTest::GetArgValue(const char *name, const int16 argc, 89 const char *PluginTest::GetArgValue(const char *name, const int16 argc,
89 const char *argn[], const char *argv[]) { 90 const char *argn[], const char *argv[]) {
90 for (int idx = 0; idx < argc; idx++) 91 for (int idx = 0; idx < argc; idx++)
91 if (_stricmp(argn[idx], name) == 0) 92 if (base::strcasecmp(argn[idx], name) == 0)
92 return argv[idx]; 93 return argv[idx];
93 return NULL; 94 return NULL;
94 } 95 }
95 96
96 void PluginTest::SetError(const std::string &msg) { 97 void PluginTest::SetError(const std::string &msg) {
97 test_status_.append(msg); 98 test_status_.append(msg);
98 } 99 }
99 100
100 NPError PluginTest::NewStream(NPMIMEType type, NPStream* stream, 101 NPError PluginTest::NewStream(NPMIMEType type, NPStream* stream,
101 NPBool seekable, uint16* stype) { 102 NPBool seekable, uint16* stype) {
(...skipping 25 matching lines...) Expand all
127 // There is no default action 128 // There is no default action
128 } 129 }
129 130
130 int16 PluginTest::HandleEvent(void* event) { 131 int16 PluginTest::HandleEvent(void* event) {
131 // There is no default action 132 // There is no default action
132 return 0; 133 return 0;
133 } 134 }
134 135
135 } // namespace NPAPIClient 136 } // namespace NPAPIClient
136 137
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698