2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 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 CEF_LIBCEF_COMMON_REQUEST_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_COMMON_REQUEST_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "include/cef_request.h"
|
|
|
|
#include "net/base/upload_data.h"
|
|
|
|
#include "net/http/http_request_headers.h"
|
2012-06-19 18:29:49 +02:00
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
namespace net {
|
|
|
|
class URLRequest;
|
|
|
|
};
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
namespace WebKit {
|
|
|
|
class WebURLRequest;
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Implementation of CefRequest
|
|
|
|
class CefRequestImpl : public CefRequest {
|
|
|
|
public:
|
|
|
|
CefRequestImpl();
|
|
|
|
~CefRequestImpl() {}
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
virtual bool IsReadOnly() OVERRIDE;
|
2012-04-03 03:34:16 +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;
|
|
|
|
virtual void Set(const CefString& url,
|
|
|
|
const CefString& method,
|
|
|
|
CefRefPtr<CefPostData> postData,
|
|
|
|
const HeaderMap& headerMap) OVERRIDE;
|
2012-06-19 18:29:49 +02:00
|
|
|
virtual int GetFlags() OVERRIDE;
|
|
|
|
virtual void SetFlags(int flags) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual CefString GetFirstPartyForCookies() OVERRIDE;
|
|
|
|
virtual void SetFirstPartyForCookies(const CefString& url) OVERRIDE;
|
|
|
|
|
|
|
|
// Populate this object from the URLRequest object.
|
|
|
|
void Set(net::URLRequest* request);
|
|
|
|
|
|
|
|
// Populate the URLRequest object from this object.
|
|
|
|
void Get(net::URLRequest* request);
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
// Populate this object from a WebURLRequest object.
|
|
|
|
void Set(const WebKit::WebURLRequest& request);
|
|
|
|
|
|
|
|
// Populate the WebURLRequest object from this object.
|
|
|
|
void Get(WebKit::WebURLRequest& request);
|
|
|
|
|
|
|
|
void SetReadOnly(bool read_only);
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
static void GetHeaderMap(const net::HttpRequestHeaders& headers,
|
|
|
|
HeaderMap& map);
|
2012-06-19 18:29:49 +02:00
|
|
|
static void GetHeaderMap(const WebKit::WebURLRequest& request,
|
|
|
|
HeaderMap& map);
|
|
|
|
static void SetHeaderMap(const HeaderMap& map,
|
|
|
|
WebKit::WebURLRequest& request);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CefString url_;
|
|
|
|
CefString method_;
|
|
|
|
CefRefPtr<CefPostData> postdata_;
|
|
|
|
HeaderMap headermap_;
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
// The below members are used by CefURLRequest.
|
|
|
|
int flags_;
|
2012-04-03 03:34:16 +02:00
|
|
|
CefString first_party_for_cookies_;
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
// True if this object is read-only.
|
|
|
|
bool read_only_;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(CefRequestImpl);
|
|
|
|
IMPLEMENT_LOCKING(CefRequestImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Implementation of CefPostData
|
|
|
|
class CefPostDataImpl : public CefPostData {
|
|
|
|
public:
|
|
|
|
CefPostDataImpl();
|
|
|
|
~CefPostDataImpl() {}
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
virtual bool IsReadOnly() OVERRIDE;
|
2012-04-03 03:34:16 +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;
|
|
|
|
virtual void RemoveElements();
|
|
|
|
|
2012-08-04 02:59:58 +02:00
|
|
|
void Set(const net::UploadData& data);
|
2012-04-03 03:34:16 +02:00
|
|
|
void Get(net::UploadData& data);
|
2012-06-19 18:29:49 +02:00
|
|
|
void Set(const WebKit::WebHTTPBody& data);
|
|
|
|
void Get(WebKit::WebHTTPBody& data);
|
|
|
|
|
|
|
|
void SetReadOnly(bool read_only);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ElementVector elements_;
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
// True if this object is read-only.
|
|
|
|
bool read_only_;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(CefPostDataImpl);
|
|
|
|
IMPLEMENT_LOCKING(CefPostDataImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Implementation of CefPostDataElement
|
|
|
|
class CefPostDataElementImpl : public CefPostDataElement {
|
|
|
|
public:
|
|
|
|
CefPostDataElementImpl();
|
|
|
|
~CefPostDataElementImpl();
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
virtual bool IsReadOnly() OVERRIDE;
|
2012-04-03 03:34:16 +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;
|
|
|
|
|
|
|
|
void* GetBytes() { return data_.bytes.bytes; }
|
|
|
|
|
2012-08-29 00:26:35 +02:00
|
|
|
void Set(const net::UploadElement& element);
|
|
|
|
void Get(net::UploadElement& element);
|
2012-06-19 18:29:49 +02:00
|
|
|
void Set(const WebKit::WebHTTPBody::Element& element);
|
|
|
|
void Get(WebKit::WebHTTPBody::Element& element);
|
|
|
|
|
|
|
|
void SetReadOnly(bool read_only);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
protected:
|
2012-06-19 18:29:49 +02:00
|
|
|
void Cleanup();
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
Type type_;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
void* bytes;
|
|
|
|
size_t size;
|
|
|
|
} bytes;
|
|
|
|
cef_string_t filename;
|
|
|
|
} data_;
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
// True if this object is read-only.
|
|
|
|
bool read_only_;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(CefPostDataElementImpl);
|
|
|
|
IMPLEMENT_LOCKING(CefPostDataElementImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_COMMON_REQUEST_IMPL_H_
|