2010-10-03 23:04:50 +02:00
|
|
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef _REQUEST_IMPL_H
|
|
|
|
#define _REQUEST_IMPL_H
|
|
|
|
|
2011-02-09 23:04:35 +01:00
|
|
|
#include "include/cef.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#include "net/base/upload_data.h"
|
|
|
|
#include "net/http/http_request_headers.h"
|
2011-02-15 19:07:24 +01:00
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebHTTPBody.h"
|
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
namespace net {
|
2010-10-03 23:04:50 +02:00
|
|
|
class URLRequest;
|
2010-12-16 22:54:42 +01:00
|
|
|
};
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
// Implementation of CefRequest
|
2011-05-20 16:42:25 +02:00
|
|
|
class CefRequestImpl : public CefRequest
|
2010-10-03 23:04:50 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CefRequestImpl();
|
|
|
|
~CefRequestImpl() {}
|
|
|
|
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual CefString GetURL() OVERRIDE;
|
|
|
|
virtual void SetURL(const CefString& url) OVERRIDE;
|
|
|
|
virtual CefString GetMethod() OVERRIDE;
|
|
|
|
virtual void SetMethod(const CefString& method) OVERRIDE;
|
|
|
|
virtual CefRefPtr<CefPostData> GetPostData() OVERRIDE;
|
|
|
|
virtual void SetPostData(CefRefPtr<CefPostData> postData) OVERRIDE;
|
|
|
|
virtual void GetHeaderMap(HeaderMap& headerMap) OVERRIDE;
|
|
|
|
virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE;
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual void Set(const CefString& url,
|
|
|
|
const CefString& method,
|
2010-10-03 23:04:50 +02:00
|
|
|
CefRefPtr<CefPostData> postData,
|
2011-05-20 16:42:25 +02:00
|
|
|
const HeaderMap& headerMap) OVERRIDE;
|
|
|
|
virtual RequestFlags GetFlags() OVERRIDE;
|
|
|
|
virtual void SetFlags(RequestFlags flags) OVERRIDE;
|
|
|
|
virtual CefString GetFirstPartyForCookies() OVERRIDE;
|
|
|
|
virtual void SetFirstPartyForCookies(const CefString& url) OVERRIDE;
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
void Set(net::URLRequest* request);
|
2011-02-09 23:04:35 +01:00
|
|
|
void Set(const WebKit::WebURLRequest& request);
|
|
|
|
void Get(WebKit::WebURLRequest& request);
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
static void GetHeaderMap(const net::HttpRequestHeaders& headers,
|
|
|
|
HeaderMap& map);
|
|
|
|
static void GetHeaderMap(const WebKit::WebURLRequest& request,
|
|
|
|
HeaderMap& map);
|
|
|
|
static void SetHeaderMap(const HeaderMap& map,
|
|
|
|
WebKit::WebURLRequest& request);
|
|
|
|
|
|
|
|
protected:
|
2010-11-22 18:49:46 +01:00
|
|
|
CefString url_;
|
|
|
|
CefString method_;
|
2010-10-03 23:04:50 +02:00
|
|
|
CefRefPtr<CefPostData> postdata_;
|
|
|
|
HeaderMap headermap_;
|
2011-02-09 23:04:35 +01:00
|
|
|
|
|
|
|
// The below methods are used by WebURLRequest.
|
|
|
|
RequestFlags flags_;
|
|
|
|
CefString first_party_for_cookies_;
|
2011-05-20 16:42:25 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefRequestImpl);
|
|
|
|
IMPLEMENT_LOCKING(CefRequestImpl);
|
2010-10-03 23:04:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Implementation of CefPostData
|
2011-05-20 16:42:25 +02:00
|
|
|
class CefPostDataImpl : public CefPostData
|
2010-10-03 23:04:50 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CefPostDataImpl();
|
|
|
|
~CefPostDataImpl() {}
|
|
|
|
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual size_t GetElementCount() OVERRIDE;
|
|
|
|
virtual void GetElements(ElementVector& elements) OVERRIDE;
|
|
|
|
virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element) OVERRIDE;
|
|
|
|
virtual bool AddElement(CefRefPtr<CefPostDataElement> element) OVERRIDE;
|
2010-10-03 23:04:50 +02:00
|
|
|
virtual void RemoveElements();
|
|
|
|
|
|
|
|
void Set(net::UploadData& data);
|
|
|
|
void Get(net::UploadData& data);
|
|
|
|
void Set(const WebKit::WebHTTPBody& data);
|
|
|
|
void Get(WebKit::WebHTTPBody& data);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ElementVector elements_;
|
2011-05-20 16:42:25 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefPostDataImpl);
|
|
|
|
IMPLEMENT_LOCKING(CefPostDataImpl);
|
2010-10-03 23:04:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Implementation of CefPostDataElement
|
2011-05-20 16:42:25 +02:00
|
|
|
class CefPostDataElementImpl : public CefPostDataElement
|
2010-10-03 23:04:50 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CefPostDataElementImpl();
|
|
|
|
~CefPostDataElementImpl();
|
|
|
|
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual void SetToEmpty() OVERRIDE;
|
|
|
|
virtual void SetToFile(const CefString& fileName) OVERRIDE;
|
|
|
|
virtual void SetToBytes(size_t size, const void* bytes) OVERRIDE;
|
|
|
|
virtual Type GetType() OVERRIDE;
|
|
|
|
virtual CefString GetFile() OVERRIDE;
|
|
|
|
virtual size_t GetBytesCount() OVERRIDE;
|
|
|
|
virtual size_t GetBytes(size_t size, void* bytes) OVERRIDE;
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
void* GetBytes() { return data_.bytes.bytes; }
|
|
|
|
|
|
|
|
void Set(const net::UploadData::Element& element);
|
|
|
|
void Get(net::UploadData::Element& element);
|
|
|
|
void Set(const WebKit::WebHTTPBody::Element& element);
|
|
|
|
void Get(WebKit::WebHTTPBody::Element& element);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Type type_;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
void* bytes;
|
|
|
|
size_t size;
|
|
|
|
} bytes;
|
2010-11-22 18:49:46 +01:00
|
|
|
cef_string_t filename;
|
2010-10-03 23:04:50 +02:00
|
|
|
} data_;
|
2011-05-20 16:42:25 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefPostDataElementImpl);
|
|
|
|
IMPLEMENT_LOCKING(CefPostDataElementImpl);
|
2010-10-03 23:04:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _REQUEST_IMPL_H
|