John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium 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. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/javascript/console.h" |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 8 | |
Dan Sinclair | 3ebd121 | 2016-03-09 09:59:23 -0500 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 11 | #include "fpdfsdk/javascript/JS_Define.h" |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 12 | #include "fpdfsdk/javascript/JS_Object.h" |
| 13 | #include "fpdfsdk/javascript/JS_Value.h" |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 14 | #include "fpdfsdk/javascript/cjs_event_context.h" |
dan sinclair | 8b6acdd | 2017-10-25 20:35:19 -0400 | [diff] [blame] | 15 | #include "fpdfsdk/javascript/cjs_eventhandler.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 16 | |
Dan Sinclair | c94a793 | 2017-10-26 16:48:57 -0400 | [diff] [blame] | 17 | const JSMethodSpec CJS_Console::MethodSpecs[] = {{"clear", clear_static}, |
| 18 | {"hide", hide_static}, |
| 19 | {"println", println_static}, |
| 20 | {"show", show_static}, |
| 21 | {0, 0}}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 22 | |
Dan Sinclair | ef29953 | 2017-10-26 16:48:30 -0400 | [diff] [blame] | 23 | int CJS_Console::ObjDefnID = -1; |
Dan Sinclair | 89d26c8 | 2017-10-26 12:21:28 -0400 | [diff] [blame] | 24 | |
Dan Sinclair | ef29953 | 2017-10-26 16:48:30 -0400 | [diff] [blame] | 25 | // static |
Dan Sinclair | bef4d3e | 2017-10-26 16:49:38 -0400 | [diff] [blame^] | 26 | void CJS_Console::DefineJSObjects(CFXJS_Engine* pEngine) { |
| 27 | ObjDefnID = pEngine->DefineObj("console", FXJSOBJTYPE_STATIC, |
Dan Sinclair | ef29953 | 2017-10-26 16:48:30 -0400 | [diff] [blame] | 28 | JSConstructor<CJS_Console, console>, |
| 29 | JSDestructor<CJS_Console>); |
| 30 | DefineMethods(pEngine, ObjDefnID, MethodSpecs); |
Dan Sinclair | 89d26c8 | 2017-10-26 12:21:28 -0400 | [diff] [blame] | 31 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 32 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 33 | console::console(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {} |
| 34 | |
| 35 | console::~console() {} |
| 36 | |
Dan Sinclair | 8f524d6 | 2017-10-25 13:30:31 -0400 | [diff] [blame] | 37 | CJS_Return console::clear(CJS_Runtime* pRuntime, |
| 38 | const std::vector<v8::Local<v8::Value>>& params) { |
| 39 | return CJS_Return(true); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Dan Sinclair | 8f524d6 | 2017-10-25 13:30:31 -0400 | [diff] [blame] | 42 | CJS_Return console::hide(CJS_Runtime* pRuntime, |
| 43 | const std::vector<v8::Local<v8::Value>>& params) { |
| 44 | return CJS_Return(true); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Dan Sinclair | 8f524d6 | 2017-10-25 13:30:31 -0400 | [diff] [blame] | 47 | CJS_Return console::println(CJS_Runtime* pRuntime, |
| 48 | const std::vector<v8::Local<v8::Value>>& params) { |
| 49 | return CJS_Return(params.size() > 0); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Dan Sinclair | 8f524d6 | 2017-10-25 13:30:31 -0400 | [diff] [blame] | 52 | CJS_Return console::show(CJS_Runtime* pRuntime, |
| 53 | const std::vector<v8::Local<v8::Value>>& params) { |
| 54 | return CJS_Return(true); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 55 | } |