| 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 #include <CoreFoundation/CFTimeZone.h> | 9 #include <CoreFoundation/CFTimeZone.h> |
| 10 extern "C" { | 10 extern "C" { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "base/strings/sys_string_conversions.h" | 31 #include "base/strings/sys_string_conversions.h" |
| 32 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
| 33 #include "base/sys_info.h" | 33 #include "base/sys_info.h" |
| 34 #include "content/grit/content_resources.h" | 34 #include "content/grit/content_resources.h" |
| 35 #include "content/public/common/content_client.h" | 35 #include "content/public/common/content_client.h" |
| 36 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
| 37 #include "third_party/icu/source/common/unicode/uchar.h" | 37 #include "third_party/icu/source/common/unicode/uchar.h" |
| 38 #include "ui/base/layout.h" | 38 #include "ui/base/layout.h" |
| 39 #include "ui/gl/gl_surface.h" | 39 #include "ui/gl/gl_surface.h" |
| 40 | 40 |
| 41 extern "C" { | |
| 42 void CGSSetDenyWindowServerConnections(bool); | |
| 43 void CGSShutdownServerConnections(); | |
| 44 }; | |
| 45 | |
| 46 namespace content { | 41 namespace content { |
| 47 namespace { | 42 namespace { |
| 48 | 43 |
| 49 // Is the sandbox currently active. | 44 // Is the sandbox currently active. |
| 50 bool gSandboxIsActive = false; | 45 bool gSandboxIsActive = false; |
| 51 | 46 |
| 52 struct SandboxTypeToResourceIDMapping { | 47 struct SandboxTypeToResourceIDMapping { |
| 53 SandboxType sandbox_type; | 48 SandboxType sandbox_type; |
| 54 int sandbox_profile_resource_id; | 49 int sandbox_profile_resource_id; |
| 55 }; | 50 }; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 base::ScopedCFTypeRef<CGContextRef> context(CGBitmapContextCreate( | 261 base::ScopedCFTypeRef<CGContextRef> context(CGBitmapContextCreate( |
| 267 data, | 262 data, |
| 268 1, | 263 1, |
| 269 1, | 264 1, |
| 270 8, | 265 8, |
| 271 1 * 4, | 266 1 * 4, |
| 272 rgb_colorspace, | 267 rgb_colorspace, |
| 273 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); | 268 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); |
| 274 | 269 |
| 275 // Load in the color profiles we'll need (as a side effect). | 270 // Load in the color profiles we'll need (as a side effect). |
| 276 ignore_result(base::mac::GetSRGBColorSpace()); | 271 (void) base::mac::GetSRGBColorSpace(); |
| 277 ignore_result(base::mac::GetSystemColorSpace()); | 272 (void) base::mac::GetSystemColorSpace(); |
| 278 | 273 |
| 279 // CGColorSpaceCreateSystemDefaultCMYK - 10.6 | 274 // CGColorSpaceCreateSystemDefaultCMYK - 10.6 |
| 280 base::ScopedCFTypeRef<CGColorSpaceRef> cmyk_colorspace( | 275 base::ScopedCFTypeRef<CGColorSpaceRef> cmyk_colorspace( |
| 281 CGColorSpaceCreateWithName(kCGColorSpaceGenericCMYK)); | 276 CGColorSpaceCreateWithName(kCGColorSpaceGenericCMYK)); |
| 282 } | 277 } |
| 283 | 278 |
| 284 { // localtime() - 10.5.6 | 279 { // localtime() - 10.5.6 |
| 285 time_t tv = {0}; | 280 time_t tv = {0}; |
| 286 localtime(&tv); | 281 localtime(&tv); |
| 287 } | 282 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 // Preload either the desktop GL or the osmesa so, depending on the | 318 // Preload either the desktop GL or the osmesa so, depending on the |
| 324 // --use-gl flag. | 319 // --use-gl flag. |
| 325 gfx::GLSurface::InitializeOneOff(); | 320 gfx::GLSurface::InitializeOneOff(); |
| 326 } | 321 } |
| 327 | 322 |
| 328 if (sandbox_type == SANDBOX_TYPE_PPAPI) { | 323 if (sandbox_type == SANDBOX_TYPE_PPAPI) { |
| 329 // Preload AppKit color spaces used for Flash/ppapi. http://crbug.com/348304 | 324 // Preload AppKit color spaces used for Flash/ppapi. http://crbug.com/348304 |
| 330 NSColor* color = [NSColor controlTextColor]; | 325 NSColor* color = [NSColor controlTextColor]; |
| 331 [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; | 326 [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; |
| 332 } | 327 } |
| 333 | |
| 334 if (sandbox_type == SANDBOX_TYPE_RENDERER) { | |
| 335 // Now disconnect from WindowServer, after all objects have been warmed up. | |
| 336 // Shutting down the connection requires connecting to WindowServer, | |
| 337 // so do this before actually engaging the sandbox. | |
| 338 CGSSetDenyWindowServerConnections(true); | |
| 339 CGSShutdownServerConnections(); | |
| 340 } | |
| 341 } | 328 } |
| 342 | 329 |
| 343 // static | 330 // static |
| 344 NSString* Sandbox::BuildAllowDirectoryAccessSandboxString( | 331 NSString* Sandbox::BuildAllowDirectoryAccessSandboxString( |
| 345 const base::FilePath& allowed_dir, | 332 const base::FilePath& allowed_dir, |
| 346 SandboxVariableSubstitions* substitutions) { | 333 SandboxVariableSubstitions* substitutions) { |
| 347 // A whitelist is used to determine which directories can be statted | 334 // A whitelist is used to determine which directories can be statted |
| 348 // This means that in the case of an /a/b/c/d/ directory, we may be able to | 335 // This means that in the case of an /a/b/c/d/ directory, we may be able to |
| 349 // stat the leaf directory, but not its parent. | 336 // stat the leaf directory, but not its parent. |
| 350 // The extension code in Chrome calls realpath() which fails if it can't call | 337 // The extension code in Chrome calls realpath() which fails if it can't call |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) { | 614 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) { |
| 628 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " | 615 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " |
| 629 << path.value(); | 616 << path.value(); |
| 630 return path; | 617 return path; |
| 631 } | 618 } |
| 632 | 619 |
| 633 return base::FilePath(canonical_path); | 620 return base::FilePath(canonical_path); |
| 634 } | 621 } |
| 635 | 622 |
| 636 } // namespace content | 623 } // namespace content |
| OLD | NEW |