2 * Copyright (C) 2012 Intel Corporation. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "ewk_url_scheme_request.h"
29 #include "GOwnPtrSoup.h"
32 #include "ewk_url_scheme_request_private.h"
34 using namespace WebKit;
36 Ewk_Url_Scheme_Request::Ewk_Url_Scheme_Request(WKSoupRequestManagerRef manager, WKURLRef url, uint64_t requestID)
37 : m_wkRequestManager(manager)
39 , m_requestID(requestID)
41 GOwnPtr<SoupURI> soupURI(soup_uri_new(m_url));
42 m_scheme = soupURI->scheme;
43 m_path = soupURI->path;
46 uint64_t Ewk_Url_Scheme_Request::id() const
51 const char* Ewk_Url_Scheme_Request::url() const
56 const char* Ewk_Url_Scheme_Request::scheme() const
61 const char* Ewk_Url_Scheme_Request::path() const
66 void Ewk_Url_Scheme_Request::finish(const void* contentData, uint64_t contentLength, const char* mimeType)
68 WKRetainPtr<WKDataRef> wkData(AdoptWK, WKDataCreate(contentLength ? reinterpret_cast<const unsigned char*>(contentData) : 0, contentLength));
69 WKRetainPtr<WKStringRef> wkMimeType = mimeType ? adoptWK(WKStringCreateWithUTF8CString(mimeType)) : 0;
71 // In case of empty reply an empty WKDataRef is sent to the WebProcess.
72 WKSoupRequestManagerDidHandleURIRequest(m_wkRequestManager.get(), wkData.get(), contentLength, wkMimeType.get(), m_requestID);
75 Ewk_Url_Scheme_Request* ewk_url_scheme_request_ref(Ewk_Url_Scheme_Request* request)
77 EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0);
83 void ewk_url_scheme_request_unref(Ewk_Url_Scheme_Request* request)
85 EINA_SAFETY_ON_NULL_RETURN(request);
90 const char* ewk_url_scheme_request_scheme_get(const Ewk_Url_Scheme_Request* request)
92 EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0);
94 return request->scheme();
97 const char* ewk_url_scheme_request_url_get(const Ewk_Url_Scheme_Request* request)
99 EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0);
101 return request->url();
104 const char* ewk_url_scheme_request_path_get(const Ewk_Url_Scheme_Request* request)
106 EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0);
108 return request->path();
111 Eina_Bool ewk_url_scheme_request_finish(Ewk_Url_Scheme_Request* request, const void* contentData, uint64_t contentLength, const char* mimeType)
113 EINA_SAFETY_ON_NULL_RETURN_VAL(request, false);
115 request->finish(contentData, contentLength, mimeType);