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

Side by Side Diff: testing/embedder_test.h

Issue 1353063002: Merge to M45: Fix heap use after free in CPDFSDK_Annot::GetPDFAnnot. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@2454
Patch Set: Created 5 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
« no previous file with comments | « fpdfsdk/src/fsdk_mgr.cpp ('k') | testing/embedder_test.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 PDFium Authors. All rights reserved. 1 // Copyright (c) 2015 PDFium 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 #ifndef TESTING_EMBEDDER_TEST_H_ 5 #ifndef TESTING_EMBEDDER_TEST_H_
6 #define TESTING_EMBEDDER_TEST_H_ 6 #define TESTING_EMBEDDER_TEST_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 10
10 #include "../public/fpdf_dataavail.h" 11 #include "../public/fpdf_dataavail.h"
11 #include "../public/fpdf_ext.h" 12 #include "../public/fpdf_ext.h"
12 #include "../public/fpdf_formfill.h" 13 #include "../public/fpdf_formfill.h"
13 #include "../public/fpdfview.h" 14 #include "../public/fpdfview.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
16 17
17 class TestLoader; 18 class TestLoader;
(...skipping 16 matching lines...) Expand all
34 virtual int Alert(FPDF_WIDESTRING message, FPDF_WIDESTRING title, 35 virtual int Alert(FPDF_WIDESTRING message, FPDF_WIDESTRING title,
35 int type, int icon) { 36 int type, int icon) {
36 return 0; 37 return 0;
37 } 38 }
38 39
39 // Equivalent to FPDF_FORMFILLINFO::FFI_SetTimer(). 40 // Equivalent to FPDF_FORMFILLINFO::FFI_SetTimer().
40 virtual int SetTimer(int msecs, TimerCallback fn) { return 0; } 41 virtual int SetTimer(int msecs, TimerCallback fn) { return 0; }
41 42
42 // Equivalent to FPDF_FORMFILLINFO::FFI_KillTimer(). 43 // Equivalent to FPDF_FORMFILLINFO::FFI_KillTimer().
43 virtual void KillTimer(int id) { } 44 virtual void KillTimer(int id) { }
45
46 // Equivalent to FPDF_FORMFILLINFO::FFI_GetPage().
47 virtual FPDF_PAGE GetPage(FPDF_FORMHANDLE form_handle,
48 FPDF_DOCUMENT document,
49 int page_index);
50
51 private:
52 std::map<int, FPDF_PAGE> m_pageMap;
44 }; 53 };
45 54
46 EmbedderTest(); 55 EmbedderTest();
47 virtual ~EmbedderTest(); 56 virtual ~EmbedderTest();
48 57
49 void SetUp() override; 58 void SetUp() override;
50 void TearDown() override; 59 void TearDown() override;
51 60
52 void SetDelegate(Delegate* delegate) { 61 void SetDelegate(Delegate* delegate) {
53 delegate_ = delegate ? delegate : default_delegate_; 62 delegate_ = delegate ? delegate : default_delegate_;
54 } 63 }
55 64
56 FPDF_DOCUMENT document() { return document_; } 65 FPDF_DOCUMENT document() { return document_; }
57 FPDF_FORMHANDLE form_handle() { return form_handle_; } 66 FPDF_FORMHANDLE form_handle() { return form_handle_; }
58 67
59 // Open the document specified by |filename|, and create its form fill 68 // Open the document specified by |filename|, and create its form fill
60 // environment, or return false on failure. 69 // environment, or return false on failure.
61 virtual bool OpenDocument(const std::string& filename); 70 virtual bool OpenDocument(const std::string& filename);
62 71
63 // Perform JavaScript actions that are to run at document open time. 72 // Perform JavaScript actions that are to run at document open time.
64 virtual void DoOpenActions(); 73 virtual void DoOpenActions();
65 74
66 // Determine the page numbers present in the document. 75 // Determine the page numbers present in the document.
67 virtual int GetFirstPageNum(); 76 virtual int GetFirstPageNum();
68 virtual int GetPageCount(); 77 virtual int GetPageCount();
69 78
70 // Load a specific page of the open document. 79 // Load a specific page of the open document.
71 virtual FPDF_PAGE LoadPage(int page_number); 80 virtual FPDF_PAGE LoadPage(int page_number);
72 81
82 // Load a specific page of the open document using delegate_->GetPage.
83 // delegate_->GetPage also caches loaded page.
84 virtual FPDF_PAGE LoadAndCachePage(int page_number);
85
73 // Convert a loaded page into a bitmap. 86 // Convert a loaded page into a bitmap.
74 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page); 87 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page);
75 88
76 // Relese the resources obtained from LoadPage(). Further use of |page| 89 // Relese the resources obtained from LoadPage(). Further use of |page|
77 // is prohibited after this call is made. 90 // is prohibited after this call is made.
78 virtual void UnloadPage(FPDF_PAGE page); 91 virtual void UnloadPage(FPDF_PAGE page);
79 92
80 protected: 93 protected:
81 Delegate* delegate_; 94 Delegate* delegate_;
82 Delegate* default_delegate_; 95 Delegate* default_delegate_;
(...skipping 10 matching lines...) Expand all
93 size_t file_length_; 106 size_t file_length_;
94 char* file_contents_; 107 char* file_contents_;
95 108
96 private: 109 private:
97 static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type); 110 static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type);
98 static int AlertTrampoline(IPDF_JSPLATFORM* plaform, FPDF_WIDESTRING message, 111 static int AlertTrampoline(IPDF_JSPLATFORM* plaform, FPDF_WIDESTRING message,
99 FPDF_WIDESTRING title, int type, int icon); 112 FPDF_WIDESTRING title, int type, int icon);
100 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info, int msecs, 113 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info, int msecs,
101 TimerCallback fn); 114 TimerCallback fn);
102 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id); 115 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id);
116 static FPDF_PAGE GetPageTrampoline(FPDF_FORMFILLINFO* info,
117 FPDF_DOCUMENT document,
118 int page_index);
103 }; 119 };
104 120
105 #endif // TESTING_EMBEDDER_TEST_H_ 121 #endif // TESTING_EMBEDDER_TEST_H_
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_mgr.cpp ('k') | testing/embedder_test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698