1 /* 2 * Copyright (C) 2011 Google 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 are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior 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 31 #ifndef ResourceLoaderOptions_h 32 #define ResourceLoaderOptions_h 33 34 #include "core/fetch/FetchInitiatorInfo.h" 35 #include "platform/weborigin/SecurityOrigin.h" 36 37 namespace WebCore { 38 39 enum SendCallbackPolicy { 40 SendCallbacks, 41 DoNotSendCallbacks 42 }; 43 44 enum ContentSniffingPolicy { 45 SniffContent, 46 DoNotSniffContent 47 }; 48 49 enum DataBufferingPolicy { 50 BufferData, 51 DoNotBufferData 52 }; 53 54 enum ClientCrossOriginCredentialPolicy { 55 AskClientForCrossOriginCredentials, 56 DoNotAskClientForCrossOriginCredentials 57 }; 58 59 enum SecurityCheckPolicy { 60 SkipSecurityCheck, 61 DoSecurityCheck 62 }; 63 64 enum ContentSecurityPolicyCheck { 65 CheckContentSecurityPolicy, 66 DoNotCheckContentSecurityPolicy 67 }; 68 69 enum RequestInitiatorContext { 70 DocumentContext, 71 WorkerContext, 72 }; 73 74 enum StoredCredentials { 75 AllowStoredCredentials, 76 DoNotAllowStoredCredentials 77 }; 78 79 // APIs like XMLHttpRequest and EventSource let the user decide 80 // whether to send credentials, but they're always sent for 81 // same-origin requests. Additional information is needed to handle 82 // cross-origin redirects correctly. 83 enum CredentialRequest { 84 ClientRequestedCredentials, 85 ClientDidNotRequestCredentials 86 }; 87 88 enum MixedContentBlockingTreatment { 89 TreatAsDefaultForType, 90 TreatAsPassiveContent, 91 TreatAsActiveContent, 92 TreatAsAlwaysAllowedContent 93 }; 94 95 enum SynchronousPolicy { 96 RequestSynchronously, 97 RequestAsynchronously 98 }; 99 100 struct ResourceLoaderOptions { 101 ResourceLoaderOptions() 102 : sendLoadCallbacks(DoNotSendCallbacks) 103 , sniffContent(DoNotSniffContent) 104 , dataBufferingPolicy(BufferData) 105 , allowCredentials(DoNotAllowStoredCredentials) 106 , credentialsRequested(ClientDidNotRequestCredentials) 107 , crossOriginCredentialPolicy(DoNotAskClientForCrossOriginCredentials) 108 , securityCheck(DoSecurityCheck) 109 , contentSecurityPolicyOption(CheckContentSecurityPolicy) 110 , requestInitiatorContext(DocumentContext) 111 , mixedContentBlockingTreatment(TreatAsDefaultForType) 112 , synchronousPolicy(RequestAsynchronously) 113 { 114 } 115 116 ResourceLoaderOptions( 117 SendCallbackPolicy sendLoadCallbacks, 118 ContentSniffingPolicy sniffContent, 119 DataBufferingPolicy dataBufferingPolicy, 120 StoredCredentials allowCredentials, 121 CredentialRequest credentialsRequested, 122 ClientCrossOriginCredentialPolicy crossOriginCredentialPolicy, 123 SecurityCheckPolicy securityCheck, 124 ContentSecurityPolicyCheck contentSecurityPolicyOption, 125 RequestInitiatorContext requestInitiatorContext) 126 : sendLoadCallbacks(sendLoadCallbacks) 127 , sniffContent(sniffContent) 128 , dataBufferingPolicy(dataBufferingPolicy) 129 , allowCredentials(allowCredentials) 130 , credentialsRequested(credentialsRequested) 131 , crossOriginCredentialPolicy(crossOriginCredentialPolicy) 132 , securityCheck(securityCheck) 133 , contentSecurityPolicyOption(contentSecurityPolicyOption) 134 , requestInitiatorContext(requestInitiatorContext) 135 , mixedContentBlockingTreatment(TreatAsDefaultForType) 136 , synchronousPolicy(RequestAsynchronously) 137 { 138 } 139 140 SendCallbackPolicy sendLoadCallbacks; 141 ContentSniffingPolicy sniffContent; 142 DataBufferingPolicy dataBufferingPolicy; 143 StoredCredentials allowCredentials; // Whether HTTP credentials and cookies are sent with the request. 144 CredentialRequest credentialsRequested; // Whether the client (e.g. XHR) wanted credentials in the first place. 145 ClientCrossOriginCredentialPolicy crossOriginCredentialPolicy; // Whether we will ask the client for credentials (if we allow credentials at all). 146 SecurityCheckPolicy securityCheck; 147 ContentSecurityPolicyCheck contentSecurityPolicyOption; 148 FetchInitiatorInfo initiatorInfo; 149 RequestInitiatorContext requestInitiatorContext; 150 MixedContentBlockingTreatment mixedContentBlockingTreatment; 151 SynchronousPolicy synchronousPolicy; 152 RefPtr<SecurityOrigin> securityOrigin; 153 }; 154 155 } // namespace WebCore 156 157 #endif // ResourceLoaderOptions_h 158