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

Side by Side Diff: content/common/sandbox_mac.mm

Issue 673443002: [Mac] Shut down connections to WindowServer before engaging the sandbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 6 years, 1 month 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 | « no previous file | 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) 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
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
41 namespace content { 46 namespace content {
42 namespace { 47 namespace {
43 48
44 // Is the sandbox currently active. 49 // Is the sandbox currently active.
45 bool gSandboxIsActive = false; 50 bool gSandboxIsActive = false;
46 51
47 struct SandboxTypeToResourceIDMapping { 52 struct SandboxTypeToResourceIDMapping {
48 SandboxType sandbox_type; 53 SandboxType sandbox_type;
49 int sandbox_profile_resource_id; 54 int sandbox_profile_resource_id;
50 }; 55 };
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 base::ScopedCFTypeRef<CGContextRef> context(CGBitmapContextCreate( 266 base::ScopedCFTypeRef<CGContextRef> context(CGBitmapContextCreate(
262 data, 267 data,
263 1, 268 1,
264 1, 269 1,
265 8, 270 8,
266 1 * 4, 271 1 * 4,
267 rgb_colorspace, 272 rgb_colorspace,
268 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); 273 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
269 274
270 // Load in the color profiles we'll need (as a side effect). 275 // Load in the color profiles we'll need (as a side effect).
271 (void) base::mac::GetSRGBColorSpace(); 276 ignore_result(base::mac::GetSRGBColorSpace());
272 (void) base::mac::GetSystemColorSpace(); 277 ignore_result(base::mac::GetSystemColorSpace());
273 278
274 // CGColorSpaceCreateSystemDefaultCMYK - 10.6 279 // CGColorSpaceCreateSystemDefaultCMYK - 10.6
275 base::ScopedCFTypeRef<CGColorSpaceRef> cmyk_colorspace( 280 base::ScopedCFTypeRef<CGColorSpaceRef> cmyk_colorspace(
276 CGColorSpaceCreateWithName(kCGColorSpaceGenericCMYK)); 281 CGColorSpaceCreateWithName(kCGColorSpaceGenericCMYK));
277 } 282 }
278 283
279 { // localtime() - 10.5.6 284 { // localtime() - 10.5.6
280 time_t tv = {0}; 285 time_t tv = {0};
281 localtime(&tv); 286 localtime(&tv);
282 } 287 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // Preload either the desktop GL or the osmesa so, depending on the 323 // Preload either the desktop GL or the osmesa so, depending on the
319 // --use-gl flag. 324 // --use-gl flag.
320 gfx::GLSurface::InitializeOneOff(); 325 gfx::GLSurface::InitializeOneOff();
321 } 326 }
322 327
323 if (sandbox_type == SANDBOX_TYPE_PPAPI) { 328 if (sandbox_type == SANDBOX_TYPE_PPAPI) {
324 // Preload AppKit color spaces used for Flash/ppapi. http://crbug.com/348304 329 // Preload AppKit color spaces used for Flash/ppapi. http://crbug.com/348304
325 NSColor* color = [NSColor controlTextColor]; 330 NSColor* color = [NSColor controlTextColor];
326 [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; 331 [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
327 } 332 }
333
334 if (sandbox_type == SANDBOX_TYPE_RENDERER &&
335 base::mac::IsOSMountainLionOrLater()) {
336 // Now disconnect from WindowServer, after all objects have been warmed up.
337 // Shutting down the connection requires connecting to WindowServer,
338 // so do this before actually engaging the sandbox. This is only done on
339 // 10.8 and higher because doing it on earlier OSes causes layout tests to
340 // fail <http://crbug.com/397642#c48>. This may cause two log messages to
341 // be printed to the system logger on certain OS versions.
342 CGSSetDenyWindowServerConnections(true);
343 CGSShutdownServerConnections();
344 }
328 } 345 }
329 346
330 // static 347 // static
331 NSString* Sandbox::BuildAllowDirectoryAccessSandboxString( 348 NSString* Sandbox::BuildAllowDirectoryAccessSandboxString(
332 const base::FilePath& allowed_dir, 349 const base::FilePath& allowed_dir,
333 SandboxVariableSubstitions* substitutions) { 350 SandboxVariableSubstitions* substitutions) {
334 // A whitelist is used to determine which directories can be statted 351 // A whitelist is used to determine which directories can be statted
335 // This means that in the case of an /a/b/c/d/ directory, we may be able to 352 // This means that in the case of an /a/b/c/d/ directory, we may be able to
336 // stat the leaf directory, but not its parent. 353 // stat the leaf directory, but not its parent.
337 // The extension code in Chrome calls realpath() which fails if it can't call 354 // 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
614 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) { 631 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) {
615 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " 632 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: "
616 << path.value(); 633 << path.value();
617 return path; 634 return path;
618 } 635 }
619 636
620 return base::FilePath(canonical_path); 637 return base::FilePath(canonical_path);
621 } 638 }
622 639
623 } // namespace content 640 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698