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

Side by Side Diff: fpdfsdk/javascript/JS_Runtime.h

Issue 1847583004: Move the fpdfsdk/include/javascript folder (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « fpdfsdk/javascript/JS_Object.cpp ('k') | fpdfsdk/javascript/JS_Runtime.cpp » ('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 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.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef FPDFSDK_JAVASCRIPT_JS_RUNTIME_H_
8 #define FPDFSDK_JAVASCRIPT_JS_RUNTIME_H_
9
10 #include <map>
11 #include <memory>
12 #include <set>
13 #include <utility>
14 #include <vector>
15
16 #include "core/fxcrt/include/fx_basic.h"
17 #include "fpdfsdk/include/javascript/IJavaScript.h"
18 #include "fpdfsdk/include/jsapi/fxjs_v8.h"
19 #include "fpdfsdk/javascript/JS_EventHandler.h"
20
21 class CJS_Context;
22
23 class CJS_Runtime : public IJS_Runtime {
24 public:
25 class Observer {
26 public:
27 virtual void OnDestroyed() = 0;
28
29 protected:
30 virtual ~Observer() {}
31 };
32
33 using FieldEvent = std::pair<CFX_WideString, JS_EVENT_T>;
34
35 static CJS_Runtime* FromContext(const IJS_Context* cc);
36
37 explicit CJS_Runtime(CPDFDoc_Environment* pApp);
38 ~CJS_Runtime() override;
39
40 // IJS_Runtime
41 IJS_Context* NewContext() override;
42 void ReleaseContext(IJS_Context* pContext) override;
43 IJS_Context* GetCurrentContext() override;
44 void SetReaderDocument(CPDFSDK_Document* pReaderDoc) override;
45 CPDFSDK_Document* GetReaderDocument() override { return m_pDocument; }
46 int Execute(IJS_Context* cc,
47 const wchar_t* script,
48 CFX_WideString* info) override;
49
50 CPDFDoc_Environment* GetReaderApp() const { return m_pApp; }
51
52 // Returns true if the event isn't already found in the set.
53 bool AddEventToSet(const FieldEvent& event);
54 void RemoveEventFromSet(const FieldEvent& event);
55
56 void BeginBlock() { m_bBlocking = TRUE; }
57 void EndBlock() { m_bBlocking = FALSE; }
58 FX_BOOL IsBlocking() const { return m_bBlocking; }
59
60 v8::Isolate* GetIsolate() const { return m_isolate; }
61 v8::Local<v8::Context> NewJSContext();
62
63 void SetConstArray(const CFX_WideString& name, v8::Local<v8::Array> array);
64 v8::Local<v8::Array> GetConstArray(const CFX_WideString& name);
65
66 #ifdef PDF_ENABLE_XFA
67 FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name,
68 FXJSE_HVALUE hValue) override;
69 FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name,
70 FXJSE_HVALUE hValue) override;
71 #endif // PDF_ENABLE_XFA
72
73 void AddObserver(Observer* observer);
74 void RemoveObserver(Observer* observer);
75
76 private:
77 void DefineJSObjects();
78
79 std::vector<std::unique_ptr<CJS_Context>> m_ContextArray;
80 CPDFDoc_Environment* const m_pApp;
81 CPDFSDK_Document* m_pDocument;
82 FX_BOOL m_bBlocking;
83 std::set<FieldEvent> m_FieldEventSet;
84 v8::Isolate* m_isolate;
85 bool m_isolateManaged;
86 v8::Global<v8::Context> m_context;
87 std::vector<v8::Global<v8::Object>*> m_StaticObjects;
88 std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays;
89 std::set<Observer*> m_observers;
90 };
91
92 #endif // FPDFSDK_JAVASCRIPT_JS_RUNTIME_H_
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/JS_Object.cpp ('k') | fpdfsdk/javascript/JS_Runtime.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698