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> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "base/string16.h" | 24 #include "base/string16.h" |
25 #include "base/string_piece.h" | 25 #include "base/string_piece.h" |
26 #include "base/string_util.h" | 26 #include "base/string_util.h" |
27 #include "base/stringprintf.h" | 27 #include "base/stringprintf.h" |
28 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
29 #include "base/sys_string_conversions.h" | 29 #include "base/sys_string_conversions.h" |
30 #include "base/utf_string_conversions.h" | 30 #include "base/utf_string_conversions.h" |
31 #include "content/public/common/content_client.h" | 31 #include "content/public/common/content_client.h" |
32 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
33 #include "grit/content_resources.h" | 33 #include "grit/content_resources.h" |
| 34 #include "ui/base/layout.h" |
34 #include "ui/gl/gl_surface.h" | 35 #include "ui/gl/gl_surface.h" |
35 #include "unicode/uchar.h" | 36 #include "unicode/uchar.h" |
36 | 37 |
37 namespace { | 38 namespace { |
38 | 39 |
39 struct SandboxTypeToResourceIDMapping { | 40 struct SandboxTypeToResourceIDMapping { |
40 content::SandboxType sandbox_type; | 41 content::SandboxType sandbox_type; |
41 int sandbox_profile_resource_id; | 42 int sandbox_profile_resource_id; |
42 }; | 43 }; |
43 | 44 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 357 } |
357 if (sandbox_profile_resource_id == -1) { | 358 if (sandbox_profile_resource_id == -1) { |
358 // Check if the embedder knows about this sandbox process type. | 359 // Check if the embedder knows about this sandbox process type. |
359 bool sandbox_type_found = | 360 bool sandbox_type_found = |
360 content::GetContentClient()->GetSandboxProfileForSandboxType( | 361 content::GetContentClient()->GetSandboxProfileForSandboxType( |
361 sandbox_type, &sandbox_profile_resource_id); | 362 sandbox_type, &sandbox_profile_resource_id); |
362 CHECK(sandbox_type_found) << "Unknown sandbox type " << sandbox_type; | 363 CHECK(sandbox_type_found) << "Unknown sandbox type " << sandbox_type; |
363 } | 364 } |
364 | 365 |
365 base::StringPiece sandbox_definition = | 366 base::StringPiece sandbox_definition = |
366 content::GetContentClient()->GetDataResource(sandbox_profile_resource_id); | 367 content::GetContentClient()->GetDataResource( |
| 368 sandbox_profile_resource_id, ui::SCALE_FACTOR_NONE); |
367 if (sandbox_definition.empty()) { | 369 if (sandbox_definition.empty()) { |
368 LOG(FATAL) << "Failed to load the sandbox profile (resource id " | 370 LOG(FATAL) << "Failed to load the sandbox profile (resource id " |
369 << sandbox_profile_resource_id << ")"; | 371 << sandbox_profile_resource_id << ")"; |
370 return nil; | 372 return nil; |
371 } | 373 } |
372 | 374 |
373 base::StringPiece common_sandbox_definition = | 375 base::StringPiece common_sandbox_definition = |
374 content::GetContentClient()->GetDataResource(IDR_COMMON_SANDBOX_PROFILE); | 376 content::GetContentClient()->GetDataResource( |
| 377 IDR_COMMON_SANDBOX_PROFILE, ui::SCALE_FACTOR_NONE); |
375 if (common_sandbox_definition.empty()) { | 378 if (common_sandbox_definition.empty()) { |
376 LOG(FATAL) << "Failed to load the common sandbox profile"; | 379 LOG(FATAL) << "Failed to load the common sandbox profile"; |
377 return nil; | 380 return nil; |
378 } | 381 } |
379 | 382 |
380 scoped_nsobject<NSString> common_sandbox_prefix_data( | 383 scoped_nsobject<NSString> common_sandbox_prefix_data( |
381 [[NSString alloc] initWithBytes:common_sandbox_definition.data() | 384 [[NSString alloc] initWithBytes:common_sandbox_definition.data() |
382 length:common_sandbox_definition.length() | 385 length:common_sandbox_definition.length() |
383 encoding:NSUTF8StringEncoding]); | 386 encoding:NSUTF8StringEncoding]); |
384 | 387 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { | 578 if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { |
576 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " | 579 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " |
577 << path->value(); | 580 << path->value(); |
578 return; | 581 return; |
579 } | 582 } |
580 | 583 |
581 *path = FilePath(canonical_path); | 584 *path = FilePath(canonical_path); |
582 } | 585 } |
583 | 586 |
584 } // namespace sandbox | 587 } // namespace sandbox |
OLD | NEW |