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"
|
2014-07-15 00:18:51 +02:00
|
|
|
|
|
|
|
#include "base/synchronization/lock.h"
|
2013-06-22 04:06:32 +02:00
|
|
|
#include "third_party/WebKit/public/platform/WebHTTPBody.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
namespace net {
|
2012-11-30 20:08:20 +01:00
|
|
|
class HttpRequestHeaders;
|
|
|
|
class UploadData;
|
|
|
|
class UploadDataStream;
|
|
|
|
class UploadElement;
|
|
|
|
class UploadElementReader;
|
2012-04-03 03:34:16 +02:00
|
|
|
class URLRequest;
|
|
|
|
};
|
|
|
|
|
2013-11-08 22:28:56 +01:00
|
|
|
namespace blink {
|
2012-06-19 18:29:49 +02:00
|
|
|
class WebURLRequest;
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Implementation of CefRequest
|
|
|
|
class CefRequestImpl : public CefRequest {
|
|
|
|
public:
|
|
|
|
CefRequestImpl();
|
2014-11-12 20:25:15 +01:00
|
|
|
|
|
|
|
bool IsReadOnly() override;
|
|
|
|
CefString GetURL() override;
|
|
|
|
void SetURL(const CefString& url) override;
|
|
|
|
CefString GetMethod() override;
|
|
|
|
void SetMethod(const CefString& method) override;
|
|
|
|
CefRefPtr<CefPostData> GetPostData() override;
|
|
|
|
void SetPostData(CefRefPtr<CefPostData> postData) override;
|
|
|
|
void GetHeaderMap(HeaderMap& headerMap) override;
|
|
|
|
void SetHeaderMap(const HeaderMap& headerMap) override;
|
|
|
|
void Set(const CefString& url,
|
|
|
|
const CefString& method,
|
|
|
|
CefRefPtr<CefPostData> postData,
|
|
|
|
const HeaderMap& headerMap) override;
|
|
|
|
int GetFlags() override;
|
|
|
|
void SetFlags(int flags) override;
|
|
|
|
CefString GetFirstPartyForCookies() override;
|
|
|
|
void SetFirstPartyForCookies(const CefString& url) override;
|
|
|
|
ResourceType GetResourceType() override;
|
|
|
|
TransitionType GetTransitionType() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// 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.
|
2013-11-08 22:28:56 +01:00
|
|
|
void Set(const blink::WebURLRequest& request);
|
2012-06-19 18:29:49 +02:00
|
|
|
|
|
|
|
// Populate the WebURLRequest object from this object.
|
2013-11-08 22:28:56 +01:00
|
|
|
void Get(blink::WebURLRequest& request);
|
2012-06-19 18:29:49 +02:00
|
|
|
|
|
|
|
void SetReadOnly(bool read_only);
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
static void GetHeaderMap(const net::HttpRequestHeaders& headers,
|
|
|
|
HeaderMap& map);
|
2013-11-08 22:28:56 +01:00
|
|
|
static void GetHeaderMap(const blink::WebURLRequest& request,
|
2012-06-19 18:29:49 +02:00
|
|
|
HeaderMap& map);
|
|
|
|
static void SetHeaderMap(const HeaderMap& map,
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebURLRequest& request);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CefString url_;
|
|
|
|
CefString method_;
|
|
|
|
CefRefPtr<CefPostData> postdata_;
|
|
|
|
HeaderMap headermap_;
|
2013-09-10 21:42:53 +02:00
|
|
|
ResourceType resource_type_;
|
|
|
|
TransitionType transition_type_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
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_;
|
|
|
|
|
2014-07-15 00:18:51 +02:00
|
|
|
base::Lock lock_;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(CefRequestImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Implementation of CefPostData
|
|
|
|
class CefPostDataImpl : public CefPostData {
|
|
|
|
public:
|
|
|
|
CefPostDataImpl();
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool IsReadOnly() override;
|
|
|
|
size_t GetElementCount() override;
|
|
|
|
void GetElements(ElementVector& elements) override;
|
|
|
|
bool RemoveElement(CefRefPtr<CefPostDataElement> element) override;
|
|
|
|
bool AddElement(CefRefPtr<CefPostDataElement> element) override;
|
|
|
|
void RemoveElements() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-08-04 02:59:58 +02:00
|
|
|
void Set(const net::UploadData& data);
|
2012-11-30 20:08:20 +01:00
|
|
|
void Set(const net::UploadDataStream& data_stream);
|
2012-04-03 03:34:16 +02:00
|
|
|
void Get(net::UploadData& data);
|
2013-01-14 20:21:17 +01:00
|
|
|
net::UploadDataStream* Get();
|
2013-11-08 22:28:56 +01:00
|
|
|
void Set(const blink::WebHTTPBody& data);
|
|
|
|
void Get(blink::WebHTTPBody& data);
|
2012-06-19 18:29:49 +02:00
|
|
|
|
|
|
|
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_;
|
|
|
|
|
2014-07-15 00:18:51 +02:00
|
|
|
base::Lock lock_;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(CefPostDataImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Implementation of CefPostDataElement
|
|
|
|
class CefPostDataElementImpl : public CefPostDataElement {
|
|
|
|
public:
|
|
|
|
CefPostDataElementImpl();
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefPostDataElementImpl() override;
|
|
|
|
|
|
|
|
bool IsReadOnly() override;
|
|
|
|
void SetToEmpty() override;
|
|
|
|
void SetToFile(const CefString& fileName) override;
|
|
|
|
void SetToBytes(size_t size, const void* bytes) override;
|
|
|
|
Type GetType() override;
|
|
|
|
CefString GetFile() override;
|
|
|
|
size_t GetBytesCount() override;
|
|
|
|
size_t GetBytes(size_t size, void* bytes) override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
void* GetBytes() { return data_.bytes.bytes; }
|
|
|
|
|
2012-08-29 00:26:35 +02:00
|
|
|
void Set(const net::UploadElement& element);
|
2012-11-30 20:08:20 +01:00
|
|
|
void Set(const net::UploadElementReader& element_reader);
|
2012-08-29 00:26:35 +02:00
|
|
|
void Get(net::UploadElement& element);
|
2013-01-14 20:21:17 +01:00
|
|
|
net::UploadElementReader* Get();
|
2013-11-08 22:28:56 +01:00
|
|
|
void Set(const blink::WebHTTPBody::Element& element);
|
|
|
|
void Get(blink::WebHTTPBody::Element& element);
|
2012-06-19 18:29:49 +02:00
|
|
|
|
|
|
|
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_;
|
|
|
|
|
2014-07-15 00:18:51 +02:00
|
|
|
base::Lock lock_;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(CefPostDataElementImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_COMMON_REQUEST_IMPL_H_
|