| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 base::PickleIterator iter, | 214 base::PickleIterator iter, |
| 215 const std::vector<base::ScopedFD>& fds) { | 215 const std::vector<base::ScopedFD>& fds) { |
| 216 uint32_t index; | 216 uint32_t index; |
| 217 if (!iter.ReadUInt32(&index)) | 217 if (!iter.ReadUInt32(&index)) |
| 218 return; | 218 return; |
| 219 if (index >= static_cast<uint32_t>(paths_.size())) | 219 if (index >= static_cast<uint32_t>(paths_.size())) |
| 220 return; | 220 return; |
| 221 const int result_fd = open(paths_[index].c_str(), O_RDONLY); | 221 const int result_fd = open(paths_[index].c_str(), O_RDONLY); |
| 222 | 222 |
| 223 base::Pickle reply; | 223 base::Pickle reply; |
| 224 if (result_fd == -1) { | 224 reply.WriteBool(result_fd != -1); |
| 225 reply.WriteBool(false); | |
| 226 } else { | |
| 227 reply.WriteBool(true); | |
| 228 } | |
| 229 | 225 |
| 230 // The receiver will have its own access to the file, so we will close it | 226 // The receiver will have its own access to the file, so we will close it |
| 231 // after this send. | 227 // after this send. |
| 232 SendRendererReply(fds, reply, result_fd); | 228 SendRendererReply(fds, reply, result_fd); |
| 233 | 229 |
| 234 if (result_fd >= 0) { | 230 if (result_fd >= 0) { |
| 235 int err = IGNORE_EINTR(close(result_fd)); | 231 int err = IGNORE_EINTR(close(result_fd)); |
| 236 DCHECK(!err); | 232 DCHECK(!err); |
| 237 } | 233 } |
| 238 } | 234 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 264 reply.WriteBool(fallback_font.is_bold); | 260 reply.WriteBool(fallback_font.is_bold); |
| 265 reply.WriteBool(fallback_font.is_italic); | 261 reply.WriteBool(fallback_font.is_italic); |
| 266 SendRendererReply(fds, reply, -1); | 262 SendRendererReply(fds, reply, -1); |
| 267 } | 263 } |
| 268 | 264 |
| 269 void SandboxIPCHandler::HandleGetStyleForStrike( | 265 void SandboxIPCHandler::HandleGetStyleForStrike( |
| 270 int fd, | 266 int fd, |
| 271 base::PickleIterator iter, | 267 base::PickleIterator iter, |
| 272 const std::vector<base::ScopedFD>& fds) { | 268 const std::vector<base::ScopedFD>& fds) { |
| 273 std::string family; | 269 std::string family; |
| 274 bool bold, italic; | 270 bool bold; |
| 271 bool italic; |
| 275 uint16_t pixel_size; | 272 uint16_t pixel_size; |
| 276 | 273 |
| 277 if (!iter.ReadString(&family) || | 274 if (!iter.ReadString(&family) || |
| 278 !iter.ReadBool(&bold) || | 275 !iter.ReadBool(&bold) || |
| 279 !iter.ReadBool(&italic) || | 276 !iter.ReadBool(&italic) || |
| 280 !iter.ReadUInt16(&pixel_size)) { | 277 !iter.ReadUInt16(&pixel_size)) { |
| 281 return; | 278 return; |
| 282 } | 279 } |
| 283 | 280 |
| 284 gfx::FontRenderParamsQuery query; | 281 gfx::FontRenderParamsQuery query; |
| 285 query.families.push_back(family); | 282 query.families.push_back(family); |
| 286 query.pixel_size = pixel_size; | 283 query.pixel_size = pixel_size; |
| 287 query.style = italic ? gfx::Font::ITALIC : 0; | 284 query.style = italic ? gfx::Font::ITALIC : 0; |
| 288 query.weight = bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL; | 285 query.weight = bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL; |
| 289 const gfx::FontRenderParams params = gfx::GetFontRenderParams(query, NULL); | 286 const gfx::FontRenderParams params = gfx::GetFontRenderParams(query, nullptr); |
| 290 | 287 |
| 291 // These are passed as ints since they're interpreted as tri-state chars in | 288 // These are passed as ints since they're interpreted as tri-state chars in |
| 292 // Blink. | 289 // Blink. |
| 293 base::Pickle reply; | 290 base::Pickle reply; |
| 294 reply.WriteInt(params.use_bitmaps); | 291 reply.WriteInt(params.use_bitmaps); |
| 295 reply.WriteInt(params.autohinter); | 292 reply.WriteInt(params.autohinter); |
| 296 reply.WriteInt(params.hinting != gfx::FontRenderParams::HINTING_NONE); | 293 reply.WriteInt(params.hinting != gfx::FontRenderParams::HINTING_NONE); |
| 297 reply.WriteInt(ConvertHinting(params.hinting)); | 294 reply.WriteInt(ConvertHinting(params.hinting)); |
| 298 reply.WriteInt(params.antialiasing); | 295 reply.WriteInt(params.antialiasing); |
| 299 reply.WriteInt(ConvertSubpixelRendering(params.subpixel_rendering)); | 296 reply.WriteInt(ConvertSubpixelRendering(params.subpixel_rendering)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 313 return; | 310 return; |
| 314 | 311 |
| 315 time_t time; | 312 time_t time; |
| 316 memcpy(&time, time_string.data(), sizeof(time)); | 313 memcpy(&time, time_string.data(), sizeof(time)); |
| 317 // We use localtime here because we need the tm_zone field to be filled | 314 // We use localtime here because we need the tm_zone field to be filled |
| 318 // out. Since we are a single-threaded process, this is safe. | 315 // out. Since we are a single-threaded process, this is safe. |
| 319 const struct tm* expanded_time = localtime(&time); | 316 const struct tm* expanded_time = localtime(&time); |
| 320 | 317 |
| 321 std::string result_string; | 318 std::string result_string; |
| 322 const char* time_zone_string = ""; | 319 const char* time_zone_string = ""; |
| 323 if (expanded_time != NULL) { | 320 if (expanded_time) { |
| 324 result_string = std::string(reinterpret_cast<const char*>(expanded_time), | 321 result_string = std::string(reinterpret_cast<const char*>(expanded_time), |
| 325 sizeof(struct tm)); | 322 sizeof(struct tm)); |
| 326 time_zone_string = expanded_time->tm_zone; | 323 time_zone_string = expanded_time->tm_zone; |
| 327 } | 324 } |
| 328 | 325 |
| 329 base::Pickle reply; | 326 base::Pickle reply; |
| 330 reply.WriteString(result_string); | 327 reply.WriteString(result_string); |
| 331 reply.WriteString(time_zone_string); | 328 reply.WriteString(time_zone_string); |
| 332 SendRendererReply(fds, reply, -1); | 329 SendRendererReply(fds, reply, -1); |
| 333 } | 330 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 349 shm_fd = shm.handle().fd; | 346 shm_fd = shm.handle().fd; |
| 350 base::Pickle reply; | 347 base::Pickle reply; |
| 351 SendRendererReply(fds, reply, shm_fd); | 348 SendRendererReply(fds, reply, shm_fd); |
| 352 } | 349 } |
| 353 | 350 |
| 354 void SandboxIPCHandler::HandleMatchWithFallback( | 351 void SandboxIPCHandler::HandleMatchWithFallback( |
| 355 int fd, | 352 int fd, |
| 356 base::PickleIterator iter, | 353 base::PickleIterator iter, |
| 357 const std::vector<base::ScopedFD>& fds) { | 354 const std::vector<base::ScopedFD>& fds) { |
| 358 std::string face; | 355 std::string face; |
| 359 bool is_bold, is_italic; | 356 bool is_bold; |
| 360 uint32_t charset, fallback_family; | 357 bool is_italic; |
| 358 uint32_t charset; |
| 359 uint32_t fallback_family; |
| 361 | 360 |
| 362 if (!iter.ReadString(&face) || face.empty() || | 361 if (!iter.ReadString(&face) || face.empty() || |
| 363 !iter.ReadBool(&is_bold) || | 362 !iter.ReadBool(&is_bold) || |
| 364 !iter.ReadBool(&is_italic) || | 363 !iter.ReadBool(&is_italic) || |
| 365 !iter.ReadUInt32(&charset) || | 364 !iter.ReadUInt32(&charset) || |
| 366 !iter.ReadUInt32(&fallback_family)) { | 365 !iter.ReadUInt32(&fallback_family)) { |
| 367 return; | 366 return; |
| 368 } | 367 } |
| 369 | 368 |
| 370 int font_fd = MatchFontFaceWithFallback( | 369 int font_fd = MatchFontFaceWithFallback( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } | 415 } |
| 417 | 416 |
| 418 SandboxIPCHandler::~SandboxIPCHandler() { | 417 SandboxIPCHandler::~SandboxIPCHandler() { |
| 419 if (IGNORE_EINTR(close(lifeline_fd_)) < 0) | 418 if (IGNORE_EINTR(close(lifeline_fd_)) < 0) |
| 420 PLOG(ERROR) << "close"; | 419 PLOG(ERROR) << "close"; |
| 421 if (IGNORE_EINTR(close(browser_socket_)) < 0) | 420 if (IGNORE_EINTR(close(browser_socket_)) < 0) |
| 422 PLOG(ERROR) << "close"; | 421 PLOG(ERROR) << "close"; |
| 423 } | 422 } |
| 424 | 423 |
| 425 } // namespace content | 424 } // namespace content |
| OLD | NEW |