OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium 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 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "ppapi/c/pp_errors.h" | 6 #include "ppapi/c/pp_errors.h" |
7 #include "ppapi/c/private/ppb_pdf.h" | 7 #include "ppapi/c/private/ppb_pdf.h" |
8 #include "ppapi/thunk/enter.h" | 8 #include "ppapi/thunk/enter.h" |
9 #include "ppapi/thunk/ppb_flash_font_file_api.h" | 9 #include "ppapi/thunk/ppb_flash_font_file_api.h" |
10 #include "ppapi/thunk/ppb_pdf_api.h" | 10 #include "ppapi/thunk/ppb_pdf_api.h" |
11 #include "ppapi/thunk/resource_creation_api.h" | 11 #include "ppapi/thunk/resource_creation_api.h" |
12 #include "ppapi/thunk/thunk.h" | 12 #include "ppapi/thunk/thunk.h" |
13 | 13 |
14 namespace ppapi { | 14 namespace ppapi { |
15 namespace thunk { | 15 namespace thunk { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 PP_Var GetLocalizedString(PP_Instance instance, PP_ResourceString string_id) { | |
20 EnterInstanceAPI<PPB_PDF_API> enter(instance); | |
21 if (enter.failed()) | |
22 return PP_MakeUndefined(); | |
23 return enter.functions()->GetLocalizedString(string_id); | |
24 } | |
25 | |
26 PP_Resource GetFontFileWithFallback( | 19 PP_Resource GetFontFileWithFallback( |
27 PP_Instance instance, | 20 PP_Instance instance, |
28 const PP_BrowserFont_Trusted_Description* description, | 21 const PP_BrowserFont_Trusted_Description* description, |
29 PP_PrivateFontCharset charset) { | 22 PP_PrivateFontCharset charset) { |
30 // TODO(raymes): Eventually we should replace the use of this function with | 23 // TODO(raymes): Eventually we should replace the use of this function with |
31 // either PPB_Flash_Font_File or PPB_TrueType_Font directly in the PDF code. | 24 // either PPB_Flash_Font_File or PPB_TrueType_Font directly in the PDF code. |
32 // For now just call into PPB_Flash_Font_File which has the exact same API. | 25 // For now just call into PPB_Flash_Font_File which has the exact same API. |
33 EnterResourceCreation enter(instance); | 26 EnterResourceCreation enter(instance); |
34 if (enter.failed()) | 27 if (enter.failed()) |
35 return 0; | 28 return 0; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 const char** snapshot_data_out, | 123 const char** snapshot_data_out, |
131 int* snapshot_size_out) { | 124 int* snapshot_size_out) { |
132 EnterInstanceAPI<PPB_PDF_API> enter(instance); | 125 EnterInstanceAPI<PPB_PDF_API> enter(instance); |
133 if (enter.failed()) | 126 if (enter.failed()) |
134 return; | 127 return; |
135 enter.functions()->GetV8ExternalSnapshotData(natives_data_out, | 128 enter.functions()->GetV8ExternalSnapshotData(natives_data_out, |
136 natives_size_out, snapshot_data_out, snapshot_size_out); | 129 natives_size_out, snapshot_data_out, snapshot_size_out); |
137 } | 130 } |
138 | 131 |
139 const PPB_PDF g_ppb_pdf_thunk = { | 132 const PPB_PDF g_ppb_pdf_thunk = { |
140 &GetLocalizedString, | |
141 &GetFontFileWithFallback, | 133 &GetFontFileWithFallback, |
142 &GetFontTableForPrivateFontFile, | 134 &GetFontTableForPrivateFontFile, |
143 &SearchString, | 135 &SearchString, |
144 &DidStartLoading, | 136 &DidStartLoading, |
145 &DidStopLoading, | 137 &DidStopLoading, |
146 &SetContentRestriction, | 138 &SetContentRestriction, |
147 &UserMetricsRecordAction, | 139 &UserMetricsRecordAction, |
148 &HasUnsupportedFeature, | 140 &HasUnsupportedFeature, |
149 &SaveAs, | 141 &SaveAs, |
150 &Print, | 142 &Print, |
151 &IsFeatureEnabled, | 143 &IsFeatureEnabled, |
152 &SetSelectedText, | 144 &SetSelectedText, |
153 &SetLinkUnderCursor, | 145 &SetLinkUnderCursor, |
154 &GetV8ExternalSnapshotData, | 146 &GetV8ExternalSnapshotData, |
155 }; | 147 }; |
156 | 148 |
157 } // namespace | 149 } // namespace |
158 | 150 |
159 const PPB_PDF* GetPPB_PDF_Thunk() { | 151 const PPB_PDF* GetPPB_PDF_Thunk() { |
160 return &g_ppb_pdf_thunk; | 152 return &g_ppb_pdf_thunk; |
161 } | 153 } |
162 | 154 |
163 } // namespace thunk | 155 } // namespace thunk |
164 } // namespace ppapi | 156 } // namespace ppapi |
OLD | NEW |