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

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

Issue 316016: Move the json-related files into a separate json directory. This hopefully al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/common/sandbox_mac.h" 5 #include "chrome/common/sandbox_mac.h"
6 6
7 #include "base/debug_util.h" 7 #include "base/debug_util.h"
8 8
9 #import <Cocoa/Cocoa.h> 9 #import <Cocoa/Cocoa.h>
10 extern "C" { 10 extern "C" {
11 #include <sandbox.h> 11 #include <sandbox.h>
12 } 12 }
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/json/string_escape.h"
16 #include "base/mac_util.h" 17 #include "base/mac_util.h"
17 #include "base/scoped_cftyperef.h" 18 #include "base/scoped_cftyperef.h"
18 #include "base/scoped_nsautorelease_pool.h" 19 #include "base/scoped_nsautorelease_pool.h"
19 #include "base/string16.h" 20 #include "base/string16.h"
20 #include "base/string_escape.h"
21 #include "base/sys_info.h" 21 #include "base/sys_info.h"
22 #include "base/sys_string_conversions.h" 22 #include "base/sys_string_conversions.h"
23 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
24 24
25 namespace sandbox { 25 namespace sandbox {
26 26
27 // Warm up System APIs that empirically need to be accessed before the Sandbox 27 // Warm up System APIs that empirically need to be accessed before the Sandbox
28 // is turned on. 28 // is turned on.
29 // This method is layed out in blocks, each one containing a separate function 29 // This method is layed out in blocks, each one containing a separate function
30 // that needs to be warmed up. The OS version on which we found the need to 30 // that needs to be warmed up. The OS version on which we found the need to
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 stringByReplacingOccurrencesOfString:@";10.6_ONLY" 118 stringByReplacingOccurrencesOfString:@";10.6_ONLY"
119 withString:@""]; 119 withString:@""];
120 // Splice the path of the user's home directory into the sandbox profile 120 // Splice the path of the user's home directory into the sandbox profile
121 // (see renderer.sb for details). 121 // (see renderer.sb for details).
122 // This code is in the 10.6-only block because the sandbox syntax we use 122 // This code is in the 10.6-only block because the sandbox syntax we use
123 // for this "subdir" is only supported on 10.6. 123 // for this "subdir" is only supported on 10.6.
124 // If we ever need this on pre-10.6 OSs then we'll have to rethink the 124 // If we ever need this on pre-10.6 OSs then we'll have to rethink the
125 // surrounding sandbox syntax. 125 // surrounding sandbox syntax.
126 string16 home_dir = base::SysNSStringToUTF16(NSHomeDirectory()); 126 string16 home_dir = base::SysNSStringToUTF16(NSHomeDirectory());
127 std::string home_dir_escaped; 127 std::string home_dir_escaped;
128 string_escape::JsonDoubleQuote(home_dir, false, &home_dir_escaped); 128 base::JsonDoubleQuote(home_dir, false, &home_dir_escaped);
129 NSString* home_dir_escaped_ns = base::SysUTF8ToNSString(home_dir_escaped); 129 NSString* home_dir_escaped_ns = base::SysUTF8ToNSString(home_dir_escaped);
130 sandbox_data = [sandbox_data 130 sandbox_data = [sandbox_data
131 stringByReplacingOccurrencesOfString:@"USER_HOMEDIR" 131 stringByReplacingOccurrencesOfString:@"USER_HOMEDIR"
132 withString:home_dir_escaped_ns]; 132 withString:home_dir_escaped_ns];
133 } 133 }
134 134
135 char* error_buff = NULL; 135 char* error_buff = NULL;
136 int error = sandbox_init([sandbox_data UTF8String], 0, &error_buff); 136 int error = sandbox_init([sandbox_data UTF8String], 0, &error_buff);
137 bool success = (error == 0 && error_buff == NULL); 137 bool success = (error == 0 && error_buff == NULL);
138 if (error == -1) { 138 if (error == -1) {
139 LOG(ERROR) << "Failed to Initialize Sandbox: " << error_buff; 139 LOG(ERROR) << "Failed to Initialize Sandbox: " << error_buff;
140 } 140 }
141 sandbox_free_error(error_buff); 141 sandbox_free_error(error_buff);
142 return success; 142 return success;
143 } 143 }
144 144
145 } // namespace sandbox 145 } // namespace sandbox
OLDNEW
« no previous file with comments | « chrome/common/json_value_serializer_unittest.cc ('k') | chrome/common/web_resource/web_resource_unpacker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698