OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/pepper/pepper_flash_font_file_host.h" | 5 #include "chrome/renderer/pepper/pepper_flash_font_file_host.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "content/public/renderer/renderer_ppapi_host.h" | 8 #include "content/public/renderer/renderer_ppapi_host.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/host/dispatch_host_message.h" | 10 #include "ppapi/host/dispatch_host_message.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 charset, | 34 charset, |
35 PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT); | 35 PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT); |
36 #endif // defined(OS_LINUX) || defined(OS_OPENBSD) | 36 #endif // defined(OS_LINUX) || defined(OS_OPENBSD) |
37 } | 37 } |
38 | 38 |
39 PepperFlashFontFileHost::~PepperFlashFontFileHost() {} | 39 PepperFlashFontFileHost::~PepperFlashFontFileHost() {} |
40 | 40 |
41 int32_t PepperFlashFontFileHost::OnResourceMessageReceived( | 41 int32_t PepperFlashFontFileHost::OnResourceMessageReceived( |
42 const IPC::Message& msg, | 42 const IPC::Message& msg, |
43 ppapi::host::HostMessageContext* context) { | 43 ppapi::host::HostMessageContext* context) { |
44 IPC_BEGIN_MESSAGE_MAP(PepperFlashFontFileHost, msg) | 44 PPAPI_BEGIN_MESSAGE_MAP(PepperFlashFontFileHost, msg) |
45 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFontFile_GetFontTable, | 45 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFontFile_GetFontTable, |
46 OnGetFontTable) | 46 OnGetFontTable) |
47 IPC_END_MESSAGE_MAP() | 47 PPAPI_END_MESSAGE_MAP() |
48 return PP_ERROR_FAILED; | 48 return PP_ERROR_FAILED; |
49 } | 49 } |
50 | 50 |
51 int32_t PepperFlashFontFileHost::OnGetFontTable( | 51 int32_t PepperFlashFontFileHost::OnGetFontTable( |
52 ppapi::host::HostMessageContext* context, | 52 ppapi::host::HostMessageContext* context, |
53 uint32_t table) { | 53 uint32_t table) { |
54 std::string contents; | 54 std::string contents; |
55 int32_t result = PP_ERROR_FAILED; | 55 int32_t result = PP_ERROR_FAILED; |
56 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 56 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
57 if (fd_ != -1) { | 57 if (fd_ != -1) { |
58 size_t length = 0; | 58 size_t length = 0; |
59 if (content::GetFontTable(fd_, table, 0 /* offset */, NULL, &length)) { | 59 if (content::GetFontTable(fd_, table, 0 /* offset */, NULL, &length)) { |
60 contents.resize(length); | 60 contents.resize(length); |
61 uint8_t* contents_ptr = | 61 uint8_t* contents_ptr = |
62 reinterpret_cast<uint8_t*>(const_cast<char*>(contents.c_str())); | 62 reinterpret_cast<uint8_t*>(const_cast<char*>(contents.c_str())); |
63 if (content::GetFontTable( | 63 if (content::GetFontTable( |
64 fd_, table, 0 /* offset */, contents_ptr, &length)) { | 64 fd_, table, 0 /* offset */, contents_ptr, &length)) { |
65 result = PP_OK; | 65 result = PP_OK; |
66 } else { | 66 } else { |
67 contents.clear(); | 67 contents.clear(); |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |
71 #endif // defined(OS_LINUX) || defined(OS_OPENBSD) | 71 #endif // defined(OS_LINUX) || defined(OS_OPENBSD) |
72 | 72 |
73 context->reply_msg = PpapiPluginMsg_FlashFontFile_GetFontTableReply(contents); | 73 context->reply_msg = PpapiPluginMsg_FlashFontFile_GetFontTableReply(contents); |
74 return result; | 74 return result; |
75 } | 75 } |
OLD | NEW |