Commit 815a3a5b authored by rsesek's avatar rsesek Committed by Commit bot

Remove unnecessary NSString conversions in sandbox_mac.mm.

BUG=none
R=avi@chromium.org

Review-Url: https://codereview.chromium.org/2581743002
Cr-Commit-Position: refs/heads/master@{#438909}
parent f4361e32
...@@ -18,14 +18,6 @@ namespace base { ...@@ -18,14 +18,6 @@ namespace base {
class FilePath; class FilePath;
} }
#if __OBJC__
@class NSArray;
@class NSString;
#else
class NSArray;
class NSString;
#endif
namespace content { namespace content {
// This class wraps the C-style sandbox APIs in a class to ensure proper // This class wraps the C-style sandbox APIs in a class to ensure proper
......
...@@ -359,8 +359,8 @@ void Sandbox::SandboxWarmup(int sandbox_type) { ...@@ -359,8 +359,8 @@ void Sandbox::SandboxWarmup(int sandbox_type) {
} }
// Load the appropriate template for the given sandbox type. // Load the appropriate template for the given sandbox type.
// Returns the template as an NSString or nil on error. // Returns the template as a string or an empty string on error.
NSString* LoadSandboxTemplate(int sandbox_type) { std::string LoadSandboxTemplate(int sandbox_type) {
// We use a custom sandbox definition to lock things down as tightly as // We use a custom sandbox definition to lock things down as tightly as
// possible. // possible.
int sandbox_profile_resource_id = -1; int sandbox_profile_resource_id = -1;
...@@ -390,7 +390,7 @@ NSString* LoadSandboxTemplate(int sandbox_type) { ...@@ -390,7 +390,7 @@ NSString* LoadSandboxTemplate(int sandbox_type) {
if (sandbox_definition.empty()) { if (sandbox_definition.empty()) {
LOG(FATAL) << "Failed to load the sandbox profile (resource id " LOG(FATAL) << "Failed to load the sandbox profile (resource id "
<< sandbox_profile_resource_id << ")"; << sandbox_profile_resource_id << ")";
return nil; return std::string();
} }
base::StringPiece common_sandbox_definition = base::StringPiece common_sandbox_definition =
...@@ -398,21 +398,13 @@ NSString* LoadSandboxTemplate(int sandbox_type) { ...@@ -398,21 +398,13 @@ NSString* LoadSandboxTemplate(int sandbox_type) {
IDR_COMMON_SANDBOX_PROFILE, ui::SCALE_FACTOR_NONE); IDR_COMMON_SANDBOX_PROFILE, ui::SCALE_FACTOR_NONE);
if (common_sandbox_definition.empty()) { if (common_sandbox_definition.empty()) {
LOG(FATAL) << "Failed to load the common sandbox profile"; LOG(FATAL) << "Failed to load the common sandbox profile";
return nil; return std::string();
} }
base::scoped_nsobject<NSString> common_sandbox_prefix_data(
[[NSString alloc] initWithBytes:common_sandbox_definition.data()
length:common_sandbox_definition.length()
encoding:NSUTF8StringEncoding]);
base::scoped_nsobject<NSString> sandbox_data(
[[NSString alloc] initWithBytes:sandbox_definition.data()
length:sandbox_definition.length()
encoding:NSUTF8StringEncoding]);
// Prefix sandbox_data with common_sandbox_prefix_data. // Prefix sandbox_data with common_sandbox_prefix_data.
return [common_sandbox_prefix_data stringByAppendingString:sandbox_data]; std::string sandbox_profile = common_sandbox_definition.as_string();
sandbox_definition.AppendToString(&sandbox_profile);
return sandbox_profile;
} }
// Turns on the OS X sandbox for this process. // Turns on the OS X sandbox for this process.
...@@ -428,12 +420,12 @@ bool Sandbox::EnableSandbox(int sandbox_type, ...@@ -428,12 +420,12 @@ bool Sandbox::EnableSandbox(int sandbox_type,
<< "Only SANDBOX_TYPE_UTILITY allows a custom directory parameter."; << "Only SANDBOX_TYPE_UTILITY allows a custom directory parameter.";
} }
NSString* sandbox_data = LoadSandboxTemplate(sandbox_type); std::string sandbox_data = LoadSandboxTemplate(sandbox_type);
if (!sandbox_data) { if (sandbox_data.empty()) {
return false; return false;
} }
SandboxCompiler compiler([sandbox_data UTF8String]); SandboxCompiler compiler(sandbox_data);
if (!allowed_dir.empty()) { if (!allowed_dir.empty()) {
// Add the sandbox parameters necessary to access the given directory. // Add the sandbox parameters necessary to access the given directory.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment