1/* 2 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef SandboxInitializationParameters_h 27#define SandboxInitializationParameters_h 28 29#include <wtf/Vector.h> 30#include <wtf/text/WTFString.h> 31 32#if PLATFORM(MAC) 33OBJC_CLASS NSString; 34#endif 35 36namespace WebKit { 37 38class SandboxInitializationParameters { 39 WTF_MAKE_NONCOPYABLE(SandboxInitializationParameters); 40public: 41 SandboxInitializationParameters(); 42 ~SandboxInitializationParameters(); 43 44#if PLATFORM(MAC) 45 // Name must be a literal. 46 void addConfDirectoryParameter(const char* name, int confID); 47 void addPathParameter(const char* name, NSString *path); 48 void addPathParameter(const char* name, const char* path); 49 void addParameter(const char* name, const char* value); 50 51 const char* const* namedParameterArray() const; 52 53 size_t count() const; 54 const char* name(size_t index) const; 55 const char* value(size_t index) const; 56 57 enum ProfileSelectionMode { 58 UseDefaultSandboxProfilePath, 59 UseOverrideSandboxProfilePath, 60 UseSandboxProfile 61 }; 62 63 ProfileSelectionMode mode() const { return m_profileSelectionMode; } 64 65 void setOverrideSandboxProfilePath(const String& path) 66 { 67 m_profileSelectionMode = UseOverrideSandboxProfilePath; 68 m_overrideSandboxProfilePathOrSandboxProfile = path; 69 } 70 71 const String& overrideSandboxProfilePath() const 72 { 73 ASSERT(m_profileSelectionMode == UseOverrideSandboxProfilePath); 74 return m_overrideSandboxProfilePathOrSandboxProfile; 75 } 76 77 void setSandboxProfile(const String& profile) 78 { 79 m_profileSelectionMode = UseSandboxProfile; 80 m_overrideSandboxProfilePathOrSandboxProfile = profile; 81 } 82 83 const String& sandboxProfile() const 84 { 85 ASSERT(m_profileSelectionMode == UseSandboxProfile); 86 return m_overrideSandboxProfilePathOrSandboxProfile; 87 } 88 89 void setSystemDirectorySuffix(const String& suffix) { m_systemDirectorySuffix = suffix; } 90 const String& systemDirectorySuffix() const { return m_systemDirectorySuffix; } 91#endif 92 93private: 94#if PLATFORM(MAC) 95 void appendPathInternal(const char* name, const char* path); 96 97 mutable Vector<const char*> m_namedParameters; 98 String m_systemDirectorySuffix; 99 100 ProfileSelectionMode m_profileSelectionMode; 101 String m_overrideSandboxProfilePathOrSandboxProfile; 102#endif 103}; 104 105#if !PLATFORM(MAC) 106SandboxInitializationParameters::SandboxInitializationParameters() 107{ 108} 109 110SandboxInitializationParameters::~SandboxInitializationParameters() 111{ 112} 113#endif 114 115} // namespace WebKit 116 117#endif // SandboxInitializationParameters_h 118