1 // Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30 #ifndef CEF_INCLUDE_CEF_SANDBOX_WIN_H_ 31 #define CEF_INCLUDE_CEF_SANDBOX_WIN_H_ 32 #pragma once 33 34 #include "include/base/cef_build.h" 35 36 #if defined(OS_WIN) 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 // The sandbox is used to restrict sub-processes (renderer, plugin, GPU, etc) 43 // from directly accessing system resources. This helps to protect the user 44 // from untrusted and potentially malicious Web content. 45 // See http://www.chromium.org/developers/design-documents/sandbox for 46 // complete details. 47 // 48 // To enable the sandbox on Windows the following requirements must be met: 49 // 1. Use the same executable for the browser process and all sub-processes. 50 // 2. Link the executable with the cef_sandbox static library. 51 // 3. Call the cef_sandbox_info_create() function from within the executable 52 // (not from a separate DLL) and pass the resulting pointer into both the 53 // CefExecuteProcess() and CefInitialize() functions via the 54 // |windows_sandbox_info| parameter. 55 56 /// 57 // Create the sandbox information object for this process. It is safe to create 58 // multiple of this object and to destroy the object immediately after passing 59 // into the CefExecuteProcess() and/or CefInitialize() functions. 60 /// 61 void* cef_sandbox_info_create(); 62 63 /// 64 // Destroy the specified sandbox information object. 65 /// 66 void cef_sandbox_info_destroy(void* sandbox_info); 67 68 #ifdef __cplusplus 69 } 70 71 /// 72 // Manages the life span of a sandbox information object. 73 /// 74 class CefScopedSandboxInfo { 75 public: CefScopedSandboxInfo()76 CefScopedSandboxInfo() { sandbox_info_ = cef_sandbox_info_create(); } ~CefScopedSandboxInfo()77 ~CefScopedSandboxInfo() { cef_sandbox_info_destroy(sandbox_info_); } 78 sandbox_info()79 void* sandbox_info() const { return sandbox_info_; } 80 81 private: 82 void* sandbox_info_; 83 }; 84 #endif // __cplusplus 85 86 #endif // defined(OS_WIN) 87 88 #endif // CEF_INCLUDE_CEF_SANDBOX_WIN_H_ 89