1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
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
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.
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.
30 // ---------------------------------------------------------------------------
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
37 #ifndef CEF_INCLUDE_CEF_RESOURCE_HANDLER_H_
38 #define CEF_INCLUDE_CEF_RESOURCE_HANDLER_H_
41 #include "include/cef_base.h"
42 #include "include/cef_browser.h"
43 #include "include/cef_callback.h"
44 #include "include/cef_cookie.h"
45 #include "include/cef_request.h"
46 #include "include/cef_response.h"
49 // Class used to implement a custom request handler interface. The methods of
50 // this class will always be called on the IO thread.
52 /*--cef(source=client)--*/
53 class CefResourceHandler : public virtual CefBase {
56 // Begin processing the request. To handle the request return true and call
57 // CefCallback::Continue() once the response header information is available
58 // (CefCallback::Continue() can also be called from inside this method if
59 // header information is available immediately). To cancel the request return
63 virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
64 CefRefPtr<CefCallback> callback) =0;
67 // Retrieve response header information. If the response length is not known
68 // set |response_length| to -1 and ReadResponse() will be called until it
69 // returns false. If the response length is known set |response_length|
70 // to a positive value and ReadResponse() will be called until it returns
71 // false or the specified number of bytes have been read. Use the |response|
72 // object to set the mime type, http status code and other optional header
73 // values. To redirect the request to a new URL set |redirectUrl| to the new
77 virtual void GetResponseHeaders(CefRefPtr<CefResponse> response,
78 int64& response_length,
79 CefString& redirectUrl) =0;
82 // Read response data. If data is available immediately copy up to
83 // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of
84 // bytes copied, and return true. To read the data at a later time set
85 // |bytes_read| to 0, return true and call CefCallback::Continue() when the
86 // data is available. To indicate response completion return false.
89 virtual bool ReadResponse(void* data_out,
92 CefRefPtr<CefCallback> callback) =0;
95 // Return true if the specified cookie can be sent with the request or false
96 // otherwise. If false is returned for any cookie then no cookies will be sent
100 virtual bool CanGetCookie(const CefCookie& cookie) { return true; }
103 // Return true if the specified cookie returned with the response can be set
104 // or false otherwise.
107 virtual bool CanSetCookie(const CefCookie& cookie) { return true; }
110 // Request processing has been canceled.
113 virtual void Cancel() =0;
116 #endif // CEF_INCLUDE_CEF_RESOURCE_HANDLER_H_