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

Side by Side Diff: chrome/renderer/pepper/pepper_flash_font_file_host.cc

Issue 10905227: Introduce PPB_Flash_Font. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
6
7 #include "build/build_config.h"
8 #include "content/public/renderer/renderer_ppapi_host.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/host/dispatch_host_message.h"
11 #include "ppapi/host/host_message_context.h"
12 #include "ppapi/host/ppapi_host.h"
13 #include "ppapi/proxy/ppapi_messages.h"
14 #include "ppapi/proxy/serialized_structs.h"
15
16 #if defined(OS_LINUX) || defined(OS_OPENBSD)
17 #include "content/public/common/child_process_sandbox_support_linux.h"
18 #endif
19
20 namespace chrome {
21
22 PepperFlashFontFileHost::PepperFlashFontFileHost(
23 content::RendererPpapiHost* host,
24 PP_Instance instance,
25 PP_Resource resource,
26 const ppapi::proxy::SerializedFontDescription& description,
27 PP_PrivateFontCharset charset)
28 : ResourceHost(host->GetPpapiHost(), instance, resource),
29 renderer_ppapi_host_(host),
30 fd_(-1) {
31 #if defined(OS_LINUX) || defined(OS_OPENBSD)
32 fd_ = content::MatchFontWithFallback(
33 description.face.c_str(), description.weight >= PP_FONTWEIGHT_BOLD,
34 description.italic, charset);
35 #endif // defined(OS_LINUX) || defined(OS_OPENBSD)
36 }
37
38 PepperFlashFontFileHost::~PepperFlashFontFileHost() {
39 }
40
41 int32_t PepperFlashFontFileHost::OnResourceMessageReceived(
42 const IPC::Message& msg,
43 ppapi::host::HostMessageContext* context) {
44 IPC_BEGIN_MESSAGE_MAP(PepperFlashFontFileHost, msg)
45 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFontFile_GetFontTable,
46 OnMsgGetFontTable)
47 IPC_END_MESSAGE_MAP()
48 return PP_ERROR_FAILED;
49 }
50
51 int32_t PepperFlashFontFileHost::OnMsgGetFontTable(
52 ppapi::host::HostMessageContext* context,
53 uint32_t table) {
54 std::string contents;
55 int32_t result = PP_ERROR_FAILED;
56 #if defined(OS_LINUX) || defined(OS_OPENBSD)
57 if (fd_ != -1) {
58 size_t length = 0;
59 if (content::GetFontTable(fd_, table, NULL, &length)) {
60 contents.resize(length);
61 uint8_t* contents_ptr =
62 reinterpret_cast<uint8_t*>(const_cast<char*>(contents.c_str()));
63 if (content::GetFontTable(fd_, table, contents_ptr, &length)) {
64 result = PP_OK;
65 } else {
66 contents.clear();
67 }
68 }
69 }
70 #endif // defined(OS_LINUX) || defined(OS_OPENBSD)
71
72 context->reply_msg = PpapiPluginMsg_FlashFontFile_GetFontTableReply(contents);
73 return result;
74 }
75
76 } // namespace chrome
77
OLDNEW
« no previous file with comments | « chrome/renderer/pepper/pepper_flash_font_file_host.h ('k') | chrome/renderer/pepper/pepper_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698