blob: c3cb8b7da7cc45b54dd953618a1d9cde3aa2b52b [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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 Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Dan Sinclairf766ad22016-03-14 13:51:24 -04007#include "fpdfsdk/javascript/console.h"
Tom Sepez37458412015-10-06 11:33:46 -07008
Dan Sinclair3ebd1212016-03-09 09:59:23 -05009#include <vector>
10
Dan Sinclairf766ad22016-03-14 13:51:24 -040011#include "fpdfsdk/javascript/JS_Define.h"
Dan Sinclairf766ad22016-03-14 13:51:24 -040012#include "fpdfsdk/javascript/JS_Object.h"
13#include "fpdfsdk/javascript/JS_Value.h"
Tom Sepezd6ae2af2017-02-16 11:49:55 -080014#include "fpdfsdk/javascript/cjs_event_context.h"
dan sinclair8b6acdd2017-10-25 20:35:19 -040015#include "fpdfsdk/javascript/cjs_eventhandler.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070016
Dan Sinclairc94a7932017-10-26 16:48:57 -040017const 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-Malek3f3b45c2014-05-23 17:28:10 -070022
Dan Sinclairef299532017-10-26 16:48:30 -040023int CJS_Console::ObjDefnID = -1;
Dan Sinclair89d26c82017-10-26 12:21:28 -040024
Dan Sinclairef299532017-10-26 16:48:30 -040025// static
Dan Sinclairbef4d3e2017-10-26 16:49:38 -040026void CJS_Console::DefineJSObjects(CFXJS_Engine* pEngine) {
27 ObjDefnID = pEngine->DefineObj("console", FXJSOBJTYPE_STATIC,
Dan Sinclairef299532017-10-26 16:48:30 -040028 JSConstructor<CJS_Console, console>,
29 JSDestructor<CJS_Console>);
30 DefineMethods(pEngine, ObjDefnID, MethodSpecs);
Dan Sinclair89d26c82017-10-26 12:21:28 -040031}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070032
Nico Weber9d8ec5a2015-08-04 13:00:21 -070033console::console(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
34
35console::~console() {}
36
Dan Sinclair8f524d62017-10-25 13:30:31 -040037CJS_Return console::clear(CJS_Runtime* pRuntime,
38 const std::vector<v8::Local<v8::Value>>& params) {
39 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070040}
41
Dan Sinclair8f524d62017-10-25 13:30:31 -040042CJS_Return console::hide(CJS_Runtime* pRuntime,
43 const std::vector<v8::Local<v8::Value>>& params) {
44 return CJS_Return(true);
tsepez4cf55152016-11-02 14:37:54 -070045}
46
Dan Sinclair8f524d62017-10-25 13:30:31 -040047CJS_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-Malek3f3b45c2014-05-23 17:28:10 -070050}
51
Dan Sinclair8f524d62017-10-25 13:30:31 -040052CJS_Return console::show(CJS_Runtime* pRuntime,
53 const std::vector<v8::Local<v8::Value>>& params) {
54 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070055}