| 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 "content/common/sandbox_mac.h" | 5 #include "content/common/sandbox_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 extern "C" { | 9 extern "C" { |
| 10 #include <sandbox.h> | 10 #include <sandbox.h> |
| 11 } | 11 } |
| 12 #include <signal.h> | 12 #include <signal.h> |
| 13 #include <sys/param.h> | 13 #include <sys/param.h> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/mac/bundle_locations.h" | 19 #include "base/mac/bundle_locations.h" |
| 20 #include "base/mac/mac_util.h" | 20 #include "base/mac/mac_util.h" |
| 21 #include "base/mac/scoped_cftyperef.h" | 21 #include "base/mac/scoped_cftyperef.h" |
| 22 #include "base/mac/scoped_nsautorelease_pool.h" | 22 #include "base/mac/scoped_nsautorelease_pool.h" |
| 23 #include "base/memory/scoped_nsobject.h" | 23 #include "base/mac/scoped_nsobject.h" |
| 24 #include "base/rand_util.h" | 24 #include "base/rand_util.h" |
| 25 #include "base/strings/string16.h" | 25 #include "base/strings/string16.h" |
| 26 #include "base/strings/string_piece.h" | 26 #include "base/strings/string_piece.h" |
| 27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
| 28 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
| 29 #include "base/strings/sys_string_conversions.h" | 29 #include "base/strings/sys_string_conversions.h" |
| 30 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
| 31 #include "base/sys_info.h" | 31 #include "base/sys_info.h" |
| 32 #include "content/public/common/content_client.h" | 32 #include "content/public/common/content_client.h" |
| 33 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 } | 385 } |
| 386 | 386 |
| 387 base::StringPiece common_sandbox_definition = | 387 base::StringPiece common_sandbox_definition = |
| 388 GetContentClient()->GetDataResource( | 388 GetContentClient()->GetDataResource( |
| 389 IDR_COMMON_SANDBOX_PROFILE, ui::SCALE_FACTOR_NONE); | 389 IDR_COMMON_SANDBOX_PROFILE, ui::SCALE_FACTOR_NONE); |
| 390 if (common_sandbox_definition.empty()) { | 390 if (common_sandbox_definition.empty()) { |
| 391 LOG(FATAL) << "Failed to load the common sandbox profile"; | 391 LOG(FATAL) << "Failed to load the common sandbox profile"; |
| 392 return nil; | 392 return nil; |
| 393 } | 393 } |
| 394 | 394 |
| 395 scoped_nsobject<NSString> common_sandbox_prefix_data( | 395 base::scoped_nsobject<NSString> common_sandbox_prefix_data( |
| 396 [[NSString alloc] initWithBytes:common_sandbox_definition.data() | 396 [[NSString alloc] initWithBytes:common_sandbox_definition.data() |
| 397 length:common_sandbox_definition.length() | 397 length:common_sandbox_definition.length() |
| 398 encoding:NSUTF8StringEncoding]); | 398 encoding:NSUTF8StringEncoding]); |
| 399 | 399 |
| 400 scoped_nsobject<NSString> sandbox_data( | 400 base::scoped_nsobject<NSString> sandbox_data( |
| 401 [[NSString alloc] initWithBytes:sandbox_definition.data() | 401 [[NSString alloc] initWithBytes:sandbox_definition.data() |
| 402 length:sandbox_definition.length() | 402 length:sandbox_definition.length() |
| 403 encoding:NSUTF8StringEncoding]); | 403 encoding:NSUTF8StringEncoding]); |
| 404 | 404 |
| 405 // Prefix sandbox_data with common_sandbox_prefix_data. | 405 // Prefix sandbox_data with common_sandbox_prefix_data. |
| 406 return [common_sandbox_prefix_data stringByAppendingString:sandbox_data]; | 406 return [common_sandbox_prefix_data stringByAppendingString:sandbox_data]; |
| 407 } | 407 } |
| 408 | 408 |
| 409 // static | 409 // static |
| 410 bool Sandbox::PostProcessSandboxProfile( | 410 bool Sandbox::PostProcessSandboxProfile( |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { | 601 if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { |
| 602 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " | 602 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " |
| 603 << path.value(); | 603 << path.value(); |
| 604 return path; | 604 return path; |
| 605 } | 605 } |
| 606 | 606 |
| 607 return base::FilePath(canonical_path); | 607 return base::FilePath(canonical_path); |
| 608 } | 608 } |
| 609 | 609 |
| 610 } // namespace content | 610 } // namespace content |
| OLD | NEW |