SandboxInitializationParameters.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #ifndef SandboxInitializationParameters_h
  26. #define SandboxInitializationParameters_h
  27. #include <wtf/Vector.h>
  28. #include <wtf/text/WTFString.h>
  29. #if PLATFORM(MAC)
  30. OBJC_CLASS NSString;
  31. #endif
  32. namespace WebKit {
  33. class SandboxInitializationParameters {
  34. WTF_MAKE_NONCOPYABLE(SandboxInitializationParameters);
  35. public:
  36. SandboxInitializationParameters();
  37. ~SandboxInitializationParameters();
  38. #if PLATFORM(MAC)
  39. // Name must be a literal.
  40. void addConfDirectoryParameter(const char* name, int confID);
  41. void addPathParameter(const char* name, NSString *path);
  42. void addPathParameter(const char* name, const char* path);
  43. void addParameter(const char* name, const char* value);
  44. const char* const* namedParameterArray() const;
  45. size_t count() const;
  46. const char* name(size_t index) const;
  47. const char* value(size_t index) const;
  48. enum ProfileSelectionMode {
  49. UseDefaultSandboxProfilePath,
  50. UseOverrideSandboxProfilePath,
  51. UseSandboxProfile
  52. };
  53. ProfileSelectionMode mode() const { return m_profileSelectionMode; }
  54. void setOverrideSandboxProfilePath(const String& path)
  55. {
  56. m_profileSelectionMode = UseOverrideSandboxProfilePath;
  57. m_overrideSandboxProfilePathOrSandboxProfile = path;
  58. }
  59. const String& overrideSandboxProfilePath() const
  60. {
  61. ASSERT(m_profileSelectionMode == UseOverrideSandboxProfilePath);
  62. return m_overrideSandboxProfilePathOrSandboxProfile;
  63. }
  64. void setSandboxProfile(const String& profile)
  65. {
  66. m_profileSelectionMode = UseSandboxProfile;
  67. m_overrideSandboxProfilePathOrSandboxProfile = profile;
  68. }
  69. const String& sandboxProfile() const
  70. {
  71. ASSERT(m_profileSelectionMode == UseSandboxProfile);
  72. return m_overrideSandboxProfilePathOrSandboxProfile;
  73. }
  74. void setSystemDirectorySuffix(const String& suffix) { m_systemDirectorySuffix = suffix; }
  75. const String& systemDirectorySuffix() const { return m_systemDirectorySuffix; }
  76. #endif
  77. private:
  78. #if PLATFORM(MAC)
  79. void appendPathInternal(const char* name, const char* path);
  80. mutable Vector<const char*> m_namedParameters;
  81. String m_systemDirectorySuffix;
  82. ProfileSelectionMode m_profileSelectionMode;
  83. String m_overrideSandboxProfilePathOrSandboxProfile;
  84. #endif
  85. };
  86. #if !PLATFORM(MAC)
  87. SandboxInitializationParameters::SandboxInitializationParameters()
  88. {
  89. }
  90. SandboxInitializationParameters::~SandboxInitializationParameters()
  91. {
  92. }
  93. #endif
  94. } // namespace WebKit
  95. #endif // SandboxInitializationParameters_h