| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/renderer_host/sandbox_ipc_linux.h" | 5 #include "content/browser/renderer_host/sandbox_ipc_linux.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return i; | 166 return i; |
| 167 } | 167 } |
| 168 paths_.emplace_back(path); | 168 paths_.emplace_back(path); |
| 169 return count; | 169 return count; |
| 170 } | 170 } |
| 171 | 171 |
| 172 void SandboxIPCHandler::HandleFontMatchRequest( | 172 void SandboxIPCHandler::HandleFontMatchRequest( |
| 173 int fd, | 173 int fd, |
| 174 base::PickleIterator iter, | 174 base::PickleIterator iter, |
| 175 const std::vector<base::ScopedFD>& fds) { | 175 const std::vector<base::ScopedFD>& fds) { |
| 176 uint32_t requested_style; | 176 SkFontStyle requested_style; |
| 177 std::string family; | 177 std::string family; |
| 178 if (!iter.ReadString(&family) || !iter.ReadUInt32(&requested_style)) | 178 if (!iter.ReadString(&family) || |
| 179 !skia::ReadSkFontStyle(&iter, &requested_style)) |
| 179 return; | 180 return; |
| 180 | 181 |
| 181 SkFontConfigInterface::FontIdentity result_identity; | 182 SkFontConfigInterface::FontIdentity result_identity; |
| 182 SkString result_family; | 183 SkString result_family; |
| 183 SkTypeface::Style result_style; | 184 SkFontStyle result_style; |
| 184 SkFontConfigInterface* fc = | 185 SkFontConfigInterface* fc = |
| 185 SkFontConfigInterface::GetSingletonDirectInterface(); | 186 SkFontConfigInterface::GetSingletonDirectInterface(); |
| 186 const bool r = | 187 const bool r = |
| 187 fc->matchFamilyName(family.c_str(), | 188 fc->matchFamilyName(family.c_str(), |
| 188 static_cast<SkTypeface::Style>(requested_style), | 189 requested_style, |
| 189 &result_identity, | 190 &result_identity, |
| 190 &result_family, | 191 &result_family, |
| 191 &result_style); | 192 &result_style); |
| 192 | 193 |
| 193 base::Pickle reply; | 194 base::Pickle reply; |
| 194 if (!r) { | 195 if (!r) { |
| 195 reply.WriteBool(false); | 196 reply.WriteBool(false); |
| 196 } else { | 197 } else { |
| 197 // Stash away the returned path, so we can give it an ID (index) | 198 // Stash away the returned path, so we can give it an ID (index) |
| 198 // which will later be given to us in a request to open the file. | 199 // which will later be given to us in a request to open the file. |
| 199 int index = FindOrAddPath(result_identity.fString); | 200 int index = FindOrAddPath(result_identity.fString); |
| 200 result_identity.fID = static_cast<uint32_t>(index); | 201 result_identity.fID = static_cast<uint32_t>(index); |
| 201 | 202 |
| 202 reply.WriteBool(true); | 203 reply.WriteBool(true); |
| 203 skia::WriteSkString(&reply, result_family); | 204 skia::WriteSkString(&reply, result_family); |
| 204 skia::WriteSkFontIdentity(&reply, result_identity); | 205 skia::WriteSkFontIdentity(&reply, result_identity); |
| 205 reply.WriteUInt32(result_style); | 206 skia::WriteSkFontStyle(&reply, result_style); |
| 206 } | 207 } |
| 207 SendRendererReply(fds, reply, -1); | 208 SendRendererReply(fds, reply, -1); |
| 208 } | 209 } |
| 209 | 210 |
| 210 void SandboxIPCHandler::HandleFontOpenRequest( | 211 void SandboxIPCHandler::HandleFontOpenRequest( |
| 211 int fd, | 212 int fd, |
| 212 base::PickleIterator iter, | 213 base::PickleIterator iter, |
| 213 const std::vector<base::ScopedFD>& fds) { | 214 const std::vector<base::ScopedFD>& fds) { |
| 214 uint32_t index; | 215 uint32_t index; |
| 215 if (!iter.ReadUInt32(&index)) | 216 if (!iter.ReadUInt32(&index)) |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 415 } |
| 415 | 416 |
| 416 SandboxIPCHandler::~SandboxIPCHandler() { | 417 SandboxIPCHandler::~SandboxIPCHandler() { |
| 417 if (IGNORE_EINTR(close(lifeline_fd_)) < 0) | 418 if (IGNORE_EINTR(close(lifeline_fd_)) < 0) |
| 418 PLOG(ERROR) << "close"; | 419 PLOG(ERROR) << "close"; |
| 419 if (IGNORE_EINTR(close(browser_socket_)) < 0) | 420 if (IGNORE_EINTR(close(browser_socket_)) < 0) |
| 420 PLOG(ERROR) << "close"; | 421 PLOG(ERROR) << "close"; |
| 421 } | 422 } |
| 422 | 423 |
| 423 } // namespace content | 424 } // namespace content |
| OLD | NEW |