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

Side by Side Diff: content/test/plugin/plugin_execute_stream_javascript.cc

Issue 1182303010: Delete the NPAPI plugin browsertests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 "content/test/plugin/plugin_execute_stream_javascript.h"
6
7 #include "base/basictypes.h"
8 #include "content/test/plugin/plugin_client.h"
9
10 namespace NPAPIClient {
11
12 static const int kMaxLength = 4096;
13
14 ExecuteStreamJavaScript::ExecuteStreamJavaScript(
15 NPP id, NPNetscapeFuncs *host_functions)
16 : PluginTest(id, host_functions) {
17 }
18
19 NPError ExecuteStreamJavaScript::NewStream(NPMIMEType type, NPStream* stream,
20 NPBool seekable, uint16* stype) {
21 return NPERR_NO_ERROR;
22 }
23
24 int32 ExecuteStreamJavaScript::WriteReady(NPStream *stream) {
25 return kMaxLength;
26 }
27
28 int32 ExecuteStreamJavaScript::Write(NPStream *stream, int32 offset, int32 len,
29 void *buffer) {
30 if (stream == NULL) {
31 SetError("Write got null stream");
32 return -1;
33 }
34 if (len < 0 || len > kMaxLength) {
35 SetError("Write got bogus stream chunk size");
36 return -1;
37 }
38
39 std::string javascript("javascript:");
40 javascript.append(static_cast<char*>(buffer), len);
41 size_t js_length = javascript.length();
42 if (js_length != static_cast<uint32_t>(js_length)) {
43 SetError("Javascript too long.");
44 return -1;
45 }
46
47 NPString script_string = { javascript.c_str(),
48 static_cast<uint32_t>(js_length) };
49 NPObject *window_obj = NULL;
50 NPAPIClient::PluginClient::HostFunctions()->getvalue(
51 id(), NPNVWindowNPObject, &window_obj);
52
53 NPVariant unused_result;
54 NPAPIClient::PluginClient::HostFunctions()->evaluate(
55 id(), window_obj, &script_string, &unused_result);
56
57 return len;
58 }
59
60 NPError ExecuteStreamJavaScript::DestroyStream(NPStream *stream,
61 NPError reason) {
62 return NPERR_NO_ERROR;
63 }
64
65 } // namespace NPAPIClient
OLDNEW
« no previous file with comments | « content/test/plugin/plugin_execute_stream_javascript.h ('k') | content/test/plugin/plugin_get_javascript_url2_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698