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

Side by Side Diff: chrome/renderer/renderer_sandbox_support_linux.cc

Issue 2673003: [prelim] Additional renderer fontconfig support. (Closed)
Patch Set: ... Created 10 years, 6 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 | « chrome/renderer/renderer_sandbox_support_linux.h ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "chrome/renderer/renderer_sandbox_support_linux.h" 5 #include "chrome/renderer/renderer_sandbox_support_linux.h"
6 6
7 #include "base/eintr_wrapper.h"
7 #include "base/global_descriptors_posix.h" 8 #include "base/global_descriptors_posix.h"
8 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/scoped_ptr.h"
9 #include "base/unix_domain_socket_posix.h" 11 #include "base/unix_domain_socket_posix.h"
10 #include "chrome/common/chrome_descriptors.h" 12 #include "chrome/common/chrome_descriptors.h"
11 #include "chrome/common/sandbox_methods_linux.h" 13 #include "chrome/common/sandbox_methods_linux.h"
12 14
13 #include "third_party/WebKit/WebKit/chromium/public/linux/WebFontRenderStyle.h" 15 #include "third_party/WebKit/WebKit/chromium/public/linux/WebFontRenderStyle.h"
14 16
15 static int GetSandboxFD() { 17 static int GetSandboxFD() {
16 return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor; 18 return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor;
17 } 19 }
18 20
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 uint8_t reply_buf[10]; 82 uint8_t reply_buf[10];
81 int result_fd; 83 int result_fd;
82 ssize_t result = base::SendRecvMsg(GetSandboxFD(), 84 ssize_t result = base::SendRecvMsg(GetSandboxFD(),
83 reply_buf, sizeof(reply_buf), 85 reply_buf, sizeof(reply_buf),
84 &result_fd, request); 86 &result_fd, request);
85 if (result == -1) 87 if (result == -1)
86 return -1; 88 return -1;
87 return result_fd; 89 return result_fd;
88 } 90 }
89 91
92 int MatchFontWithFallback(const std::string& family, bool bold,
93 bool italic, uint32_t microsoft_charset) {
94 Pickle request;
95 request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK);
96 request.WriteString(family);
97 request.WriteBool(bold);
98 request.WriteBool(italic);
99 request.WriteUInt32(microsoft_charset);
100 uint8_t reply_buf[64];
101 int fd = -1;
102 base::SendRecvMsg(GetSandboxFD(), reply_buf, sizeof(reply_buf),
103 &fd, request);
104 return fd;
105 }
106
107 bool GetFontTable(uint8_t** output, size_t* output_length,
108 int fd, uint32_t table) {
109 unsigned num_tables;
110 uint8_t num_tables_buf[2];
111
112 ssize_t n = HANDLE_EINTR(pread(fd, &num_tables_buf, sizeof(num_tables_buf),
113 4 /* skip the font type */));
114 if (n != sizeof(num_tables_buf))
115 return false;
116
117 num_tables = static_cast<unsigned>(num_tables_buf[0]) << 8 |
118 num_tables_buf[1];
119
120 // The size in bytes of an entry in the table directory.
121 static const unsigned kTableEntrySize = 16;
122 scoped_array<uint8_t> table_entries(
123 new uint8_t[num_tables * kTableEntrySize]);
124 n = HANDLE_EINTR(pread(fd, table_entries.get(), num_tables * kTableEntrySize,
125 12 /* skip the SFNT header */));
126 if (n != num_tables * kTableEntrySize)
127 return false;
128
129 size_t offset;
130 size_t length = 0;
131 for (unsigned i = 0; i < num_tables; i++) {
132 const uint8_t* entry = table_entries.get() + i * kTableEntrySize;
133 if (memcmp(entry, &table, sizeof(table)) == 0) {
134 offset = static_cast<size_t>(entry[8]) << 24 |
135 static_cast<size_t>(entry[9]) << 16 |
136 static_cast<size_t>(entry[10]) << 8 |
137 static_cast<size_t>(entry[11]);
138 length = static_cast<size_t>(entry[12]) << 24 |
139 static_cast<size_t>(entry[13]) << 16 |
140 static_cast<size_t>(entry[14]) << 8 |
141 static_cast<size_t>(entry[15]);
142
143 break;
144 }
145 }
146
147 if (!length)
148 return false;
149
150 *output = new uint8_t[length];
151 n = HANDLE_EINTR(pread(fd, *output, length, offset));
152 if (n != static_cast<ssize_t>(length)) {
153 delete[] *output;
154 return false;
155 }
156 *output_length = length;
157 return true;
158 }
159
90 } // namespace render_sandbox_support 160 } // namespace render_sandbox_support
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_sandbox_support_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698