mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Add CefURLRequest support (issue #517).
- Add CefBrowserProcessHandler interface (issue #650). - Internally re-register supported schemes with CefCookieManager after changing the storage path (issue #651). - Add CefResourceHandler callbacks for blocking cookie loading and saving (issue #652). - Allow custom scheme handlers for requests that do not originate from browser content (issue #653). - Use 'int' instead of 'RequestFlags' for CefRequest::GetFlags and SetFlags (issue #654). - Rename cef_request.h CreateObject methods to Create (issue #655). - Add #ifdef guards to cef_tuple.h to allow the use of both cef_runnable.h and base/bind.h in the same unit test source file. - Retrieve cookieable schemes as part of ClientApp::RegisterCustomSchemes and register with the global cookie manager. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@697 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
7
cef.gyp
7
cef.gyp
@ -244,6 +244,7 @@
|
||||
'tests/unittests/test_util.cc',
|
||||
'tests/unittests/test_util.h',
|
||||
'tests/unittests/url_unittest.cc',
|
||||
'tests/unittests/urlrequest_unittest.cc',
|
||||
'tests/unittests/v8_unittest.cc',
|
||||
'tests/unittests/values_unittest.cc',
|
||||
'tests/unittests/xml_reader_unittest.cc',
|
||||
@ -755,6 +756,8 @@
|
||||
'libcef/browser/browser_message_loop.h',
|
||||
'libcef/browser/browser_settings.cc',
|
||||
'libcef/browser/browser_settings.h',
|
||||
'libcef/browser/browser_urlrequest_impl.cc',
|
||||
'libcef/browser/browser_urlrequest_impl.h',
|
||||
'libcef/browser/content_browser_client.cc',
|
||||
'libcef/browser/content_browser_client.h',
|
||||
'libcef/browser/context.cc',
|
||||
@ -837,6 +840,7 @@
|
||||
'libcef/common/tracker.cc',
|
||||
'libcef/common/tracker.h',
|
||||
'libcef/common/url_impl.cc',
|
||||
'libcef/common/urlrequest_impl.cc',
|
||||
'libcef/common/value_base.cc',
|
||||
'libcef/common/value_base.h',
|
||||
'libcef/common/values_impl.cc',
|
||||
@ -857,6 +861,8 @@
|
||||
'libcef/renderer/frame_impl.h',
|
||||
'libcef/renderer/render_process_observer.cc',
|
||||
'libcef/renderer/render_process_observer.h',
|
||||
'libcef/renderer/render_urlrequest_impl.cc',
|
||||
'libcef/renderer/render_urlrequest_impl.h',
|
||||
'libcef/renderer/thread_util.h',
|
||||
'libcef/renderer/v8_impl.cc',
|
||||
'libcef/renderer/v8_impl.h',
|
||||
@ -1059,6 +1065,7 @@
|
||||
'tests/unittests/dom_unittest.cc',
|
||||
'tests/unittests/process_message_unittest.cc',
|
||||
'tests/unittests/scheme_handler_unittest.cc',
|
||||
'tests/unittests/urlrequest_unittest.cc',
|
||||
'tests/unittests/test_handler.cc',
|
||||
'tests/unittests/test_handler.h',
|
||||
'tests/unittests/test_suite.cc',
|
||||
|
@ -14,6 +14,7 @@
|
||||
'autogen_cpp_includes': [
|
||||
'include/cef_app.h',
|
||||
'include/cef_browser.h',
|
||||
'include/cef_browser_process_handler.h',
|
||||
'include/cef_callback.h',
|
||||
'include/cef_client.h',
|
||||
'include/cef_command_line.h',
|
||||
@ -43,6 +44,7 @@
|
||||
'include/cef_string_visitor.h',
|
||||
'include/cef_task.h',
|
||||
'include/cef_url.h',
|
||||
'include/cef_urlrequest.h',
|
||||
'include/cef_v8.h',
|
||||
'include/cef_values.h',
|
||||
'include/cef_web_plugin.h',
|
||||
@ -52,6 +54,7 @@
|
||||
'autogen_capi_includes': [
|
||||
'include/capi/cef_app_capi.h',
|
||||
'include/capi/cef_browser_capi.h',
|
||||
'include/capi/cef_browser_process_handler_capi.h',
|
||||
'include/capi/cef_callback_capi.h',
|
||||
'include/capi/cef_client_capi.h',
|
||||
'include/capi/cef_command_line_capi.h',
|
||||
@ -81,6 +84,7 @@
|
||||
'include/capi/cef_string_visitor_capi.h',
|
||||
'include/capi/cef_task_capi.h',
|
||||
'include/capi/cef_url_capi.h',
|
||||
'include/capi/cef_urlrequest_capi.h',
|
||||
'include/capi/cef_v8_capi.h',
|
||||
'include/capi/cef_values_capi.h',
|
||||
'include/capi/cef_web_plugin_capi.h',
|
||||
@ -98,6 +102,8 @@
|
||||
'libcef_dll/cpptoc/browser_cpptoc.h',
|
||||
'libcef_dll/cpptoc/browser_host_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/browser_host_cpptoc.h',
|
||||
'libcef_dll/ctocpp/browser_process_handler_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/browser_process_handler_ctocpp.h',
|
||||
'libcef_dll/cpptoc/callback_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/callback_cpptoc.h',
|
||||
'libcef_dll/ctocpp/client_ctocpp.cc',
|
||||
@ -182,6 +188,10 @@
|
||||
'libcef_dll/ctocpp/string_visitor_ctocpp.h',
|
||||
'libcef_dll/ctocpp/task_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/task_ctocpp.h',
|
||||
'libcef_dll/cpptoc/urlrequest_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/urlrequest_cpptoc.h',
|
||||
'libcef_dll/ctocpp/urlrequest_client_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/urlrequest_client_ctocpp.h',
|
||||
'libcef_dll/ctocpp/v8accessor_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/v8accessor_ctocpp.h',
|
||||
'libcef_dll/cpptoc/v8context_cpptoc.cc',
|
||||
@ -214,6 +224,8 @@
|
||||
'libcef_dll/ctocpp/browser_ctocpp.h',
|
||||
'libcef_dll/ctocpp/browser_host_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/browser_host_ctocpp.h',
|
||||
'libcef_dll/cpptoc/browser_process_handler_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/browser_process_handler_cpptoc.h',
|
||||
'libcef_dll/ctocpp/callback_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/callback_ctocpp.h',
|
||||
'libcef_dll/cpptoc/client_cpptoc.cc',
|
||||
@ -298,6 +310,10 @@
|
||||
'libcef_dll/cpptoc/string_visitor_cpptoc.h',
|
||||
'libcef_dll/cpptoc/task_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/task_cpptoc.h',
|
||||
'libcef_dll/ctocpp/urlrequest_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/urlrequest_ctocpp.h',
|
||||
'libcef_dll/cpptoc/urlrequest_client_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/urlrequest_client_cpptoc.h',
|
||||
'libcef_dll/cpptoc/v8accessor_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/v8accessor_cpptoc.h',
|
||||
'libcef_dll/ctocpp/v8context_ctocpp.cc',
|
||||
|
@ -134,30 +134,28 @@ typedef struct _cef_app_t {
|
||||
void (CEF_CALLBACK *on_register_custom_schemes)(struct _cef_app_t* self,
|
||||
struct _cef_scheme_registrar_t* registrar);
|
||||
|
||||
///
|
||||
// Return the handler for render process events. This function is called by
|
||||
// the render process main thread.
|
||||
///
|
||||
struct _cef_render_process_handler_t* (
|
||||
CEF_CALLBACK *get_render_process_handler)(struct _cef_app_t* self);
|
||||
|
||||
///
|
||||
// Return the handler for resource bundle events. If
|
||||
// CefSettings.pack_loading_disabled is true (1) a handler must be returned.
|
||||
// If no handler is returned resources will be loaded from pack files. This
|
||||
// function is called by the browser and rendere processes on multiple
|
||||
// threads.
|
||||
// function is called by the browser and render processes on multiple threads.
|
||||
///
|
||||
struct _cef_resource_bundle_handler_t* (
|
||||
CEF_CALLBACK *get_resource_bundle_handler)(struct _cef_app_t* self);
|
||||
|
||||
///
|
||||
// Return the handler for proxy events. If no handler is returned the default
|
||||
// system handler will be used. This function is called by the browser process
|
||||
// IO thread.
|
||||
// Return the handler for functionality specific to the browser process. This
|
||||
// function is called on multiple threads in the browser process.
|
||||
///
|
||||
struct _cef_proxy_handler_t* (CEF_CALLBACK *get_proxy_handler)(
|
||||
struct _cef_app_t* self);
|
||||
struct _cef_browser_process_handler_t* (
|
||||
CEF_CALLBACK *get_browser_process_handler)(struct _cef_app_t* self);
|
||||
|
||||
///
|
||||
// Return the handler for functionality specific to the render process. This
|
||||
// function is called on the render process main thread.
|
||||
///
|
||||
struct _cef_render_process_handler_t* (
|
||||
CEF_CALLBACK *get_render_process_handler)(struct _cef_app_t* self);
|
||||
} cef_app_t;
|
||||
|
||||
|
||||
|
80
include/capi/cef_browser_process_handler_capi.h
Normal file
80
include/capi/cef_browser_process_handler_capi.h
Normal file
@ -0,0 +1,80 @@
|
||||
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
|
||||
///
|
||||
// Structure used to implement browser process callbacks. The functions of this
|
||||
// structure will be called on the browser process main thread unless otherwise
|
||||
// indicated.
|
||||
///
|
||||
typedef struct _cef_browser_process_handler_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Return the handler for proxy events. If no handler is returned the default
|
||||
// system handler will be used. This function is called on the browser process
|
||||
// IO thread.
|
||||
///
|
||||
struct _cef_proxy_handler_t* (CEF_CALLBACK *get_proxy_handler)(
|
||||
struct _cef_browser_process_handler_t* self);
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread immediately after the CEF context
|
||||
// has been initialized.
|
||||
///
|
||||
void (CEF_CALLBACK *on_context_initialized)(
|
||||
struct _cef_browser_process_handler_t* self);
|
||||
} cef_browser_process_handler_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
@ -86,7 +86,7 @@ typedef struct _cef_load_handler_t {
|
||||
///
|
||||
void (CEF_CALLBACK *on_load_error)(struct _cef_load_handler_t* self,
|
||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||
enum cef_handler_errorcode_t errorCode, const cef_string_t* errorText,
|
||||
enum cef_errorcode_t errorCode, const cef_string_t* errorText,
|
||||
const cef_string_t* failedUrl);
|
||||
} cef_load_handler_t;
|
||||
|
||||
|
@ -55,6 +55,11 @@ typedef struct _cef_request_t {
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is read-only.
|
||||
///
|
||||
int (CEF_CALLBACK *is_read_only)(struct _cef_request_t* self);
|
||||
|
||||
///
|
||||
// Get the fully qualified URL.
|
||||
///
|
||||
@ -112,20 +117,20 @@ typedef struct _cef_request_t {
|
||||
cef_string_multimap_t headerMap);
|
||||
|
||||
///
|
||||
// Get the flags used in combination with CefWebURLRequest.
|
||||
// Get the flags used in combination with cef_urlrequest_t. See
|
||||
// cef_urlrequest_flags_t for supported values.
|
||||
///
|
||||
enum cef_weburlrequest_flags_t (CEF_CALLBACK *get_flags)(
|
||||
struct _cef_request_t* self);
|
||||
int (CEF_CALLBACK *get_flags)(struct _cef_request_t* self);
|
||||
|
||||
///
|
||||
// Set the flags used in combination with CefWebURLRequest.
|
||||
// Set the flags used in combination with cef_urlrequest_t. See
|
||||
// cef_urlrequest_flags_t for supported values.
|
||||
///
|
||||
void (CEF_CALLBACK *set_flags)(struct _cef_request_t* self,
|
||||
enum cef_weburlrequest_flags_t flags);
|
||||
void (CEF_CALLBACK *set_flags)(struct _cef_request_t* self, int flags);
|
||||
|
||||
///
|
||||
// Set the URL to the first party for cookies used in combination with
|
||||
// CefWebURLRequest.
|
||||
// cef_urlrequest_t.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_first_party_for_cookies)(
|
||||
@ -133,7 +138,7 @@ typedef struct _cef_request_t {
|
||||
|
||||
///
|
||||
// Get the URL to the first party for cookies used in combination with
|
||||
// CefWebURLRequest.
|
||||
// cef_urlrequest_t.
|
||||
///
|
||||
void (CEF_CALLBACK *set_first_party_for_cookies)(struct _cef_request_t* self,
|
||||
const cef_string_t* url);
|
||||
@ -156,6 +161,11 @@ typedef struct _cef_post_data_t {
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is read-only.
|
||||
///
|
||||
int (CEF_CALLBACK *is_read_only)(struct _cef_post_data_t* self);
|
||||
|
||||
///
|
||||
// Returns the number of existing post data elements.
|
||||
///
|
||||
@ -203,6 +213,11 @@ typedef struct _cef_post_data_element_t {
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is read-only.
|
||||
///
|
||||
int (CEF_CALLBACK *is_read_only)(struct _cef_post_data_element_t* self);
|
||||
|
||||
///
|
||||
// Remove all contents from the post data element.
|
||||
///
|
||||
|
@ -90,6 +90,21 @@ typedef struct _cef_resource_handler_t {
|
||||
void* data_out, int bytes_to_read, int* bytes_read,
|
||||
struct _cef_callback_t* callback);
|
||||
|
||||
///
|
||||
// Return true (1) if the specified cookie can be sent with the request or
|
||||
// false (0) otherwise. If false (0) is returned for any cookie then no
|
||||
// cookies will be sent with the request.
|
||||
///
|
||||
int (CEF_CALLBACK *can_get_cookie)(struct _cef_resource_handler_t* self,
|
||||
const struct _cef_cookie_t* cookie);
|
||||
|
||||
///
|
||||
// Return true (1) if the specified cookie returned with the response can be
|
||||
// set or false (0) otherwise.
|
||||
///
|
||||
int (CEF_CALLBACK *can_set_cookie)(struct _cef_resource_handler_t* self,
|
||||
const struct _cef_cookie_t* cookie);
|
||||
|
||||
///
|
||||
// Request processing has been canceled.
|
||||
///
|
||||
|
@ -55,6 +55,11 @@ typedef struct _cef_response_t {
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is read-only.
|
||||
///
|
||||
int (CEF_CALLBACK *is_read_only)(struct _cef_response_t* self);
|
||||
|
||||
///
|
||||
// Get the response status code.
|
||||
///
|
||||
@ -112,6 +117,12 @@ typedef struct _cef_response_t {
|
||||
} cef_response_t;
|
||||
|
||||
|
||||
///
|
||||
// Create a new cef_response_t object.
|
||||
///
|
||||
CEF_EXPORT cef_response_t* cef_response_create();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -140,10 +140,11 @@ typedef struct _cef_scheme_handler_factory_t {
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Return a new resource handler instance to handle the request. |browser|
|
||||
// will be the browser window that initiated the request. If the request was
|
||||
// initiated using the CefWebURLRequest API |browser| will be NULL. The
|
||||
// |request| object passed to this function will not contain cookie data.
|
||||
// Return a new resource handler instance to handle the request. |browser| and
|
||||
// |frame| will be the browser window and frame respectively that originated
|
||||
// the request or NULL if the request did not originate from a browser window
|
||||
// (for example, if the request came from cef_urlrequest_t). The |request|
|
||||
// object passed to this function will not contain cookie data.
|
||||
///
|
||||
struct _cef_resource_handler_t* (CEF_CALLBACK *create)(
|
||||
struct _cef_scheme_handler_factory_t* self,
|
||||
|
164
include/capi/cef_urlrequest_capi.h
Normal file
164
include/capi/cef_urlrequest_capi.h
Normal file
@ -0,0 +1,164 @@
|
||||
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
|
||||
///
|
||||
// Structure used to make a URL request. URL requests are not associated with a
|
||||
// browser instance so no cef_client_t callbacks will be executed. URL requests
|
||||
// can be created on any valid CEF thread in either the browser or render
|
||||
// process. Once created the functions of the URL request object must be
|
||||
// accessed on the same thread that created it.
|
||||
///
|
||||
typedef struct _cef_urlrequest_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns the request object used to create this URL request. The returned
|
||||
// object is read-only and should not be modified.
|
||||
///
|
||||
struct _cef_request_t* (CEF_CALLBACK *get_request)(
|
||||
struct _cef_urlrequest_t* self);
|
||||
|
||||
///
|
||||
// Returns the client.
|
||||
///
|
||||
struct _cef_urlrequest_client_t* (CEF_CALLBACK *get_client)(
|
||||
struct _cef_urlrequest_t* self);
|
||||
|
||||
///
|
||||
// Returns the request status.
|
||||
///
|
||||
enum cef_urlrequest_status_t (CEF_CALLBACK *get_request_status)(
|
||||
struct _cef_urlrequest_t* self);
|
||||
|
||||
///
|
||||
// Returns the request error if status is UR_CANCELED or UR_FAILED, or 0
|
||||
// otherwise.
|
||||
///
|
||||
enum cef_errorcode_t (CEF_CALLBACK *get_request_error)(
|
||||
struct _cef_urlrequest_t* self);
|
||||
|
||||
///
|
||||
// Returns the response, or NULL if no response information is available.
|
||||
// Response information will only be available after the upload has completed.
|
||||
// The returned object is read-only and should not be modified.
|
||||
///
|
||||
struct _cef_response_t* (CEF_CALLBACK *get_response)(
|
||||
struct _cef_urlrequest_t* self);
|
||||
|
||||
///
|
||||
// Cancel the request.
|
||||
///
|
||||
void (CEF_CALLBACK *cancel)(struct _cef_urlrequest_t* self);
|
||||
} cef_urlrequest_t;
|
||||
|
||||
|
||||
///
|
||||
// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request
|
||||
// functions are supported. The |request| object will be marked as read-only
|
||||
// after calling this function.
|
||||
///
|
||||
CEF_EXPORT cef_urlrequest_t* cef_urlrequest_create(
|
||||
struct _cef_request_t* request, struct _cef_urlrequest_client_t* client);
|
||||
|
||||
|
||||
///
|
||||
// Structure that should be implemented by the cef_urlrequest_t client. The
|
||||
// functions of this structure will be called on the same thread that created
|
||||
// the request.
|
||||
///
|
||||
typedef struct _cef_urlrequest_client_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Notifies the client that the request has completed. Use the
|
||||
// cef_urlrequest_t::GetRequestStatus function to determine if the request was
|
||||
// successful or not.
|
||||
///
|
||||
void (CEF_CALLBACK *on_request_complete)(
|
||||
struct _cef_urlrequest_client_t* self,
|
||||
struct _cef_urlrequest_t* request);
|
||||
|
||||
///
|
||||
// Notifies the client of upload progress. |current| denotes the number of
|
||||
// bytes sent so far and |total| is the total size of uploading data (or -1 if
|
||||
// chunked upload is enabled). This function will only be called if the
|
||||
// UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request.
|
||||
///
|
||||
void (CEF_CALLBACK *on_upload_progress)(struct _cef_urlrequest_client_t* self,
|
||||
struct _cef_urlrequest_t* request, uint64 current, uint64 total);
|
||||
|
||||
///
|
||||
// Notifies the client of download progress. |current| denotes the number of
|
||||
// bytes received up to the call and |total| is the expected total size of the
|
||||
// response (or -1 if not determined).
|
||||
///
|
||||
void (CEF_CALLBACK *on_download_progress)(
|
||||
struct _cef_urlrequest_client_t* self, struct _cef_urlrequest_t* request,
|
||||
uint64 current, uint64 total);
|
||||
|
||||
///
|
||||
// Called when some part of the response is read. |data| contains the current
|
||||
// bytes received since the last call. This function will not be called if the
|
||||
// UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request.
|
||||
///
|
||||
void (CEF_CALLBACK *on_download_data)(struct _cef_urlrequest_client_t* self,
|
||||
struct _cef_urlrequest_t* request, const void* data,
|
||||
size_t data_length);
|
||||
} cef_urlrequest_client_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_
|
@ -40,8 +40,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser_process_handler.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/cef_proxy_handler.h"
|
||||
#include "include/cef_render_process_handler.h"
|
||||
#include "include/cef_resource_bundle_handler.h"
|
||||
#include "include/cef_scheme.h"
|
||||
@ -142,20 +142,11 @@ class CefApp : public virtual CefBase {
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
}
|
||||
|
||||
///
|
||||
// Return the handler for render process events. This method is called by the
|
||||
// render process main thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
///
|
||||
// Return the handler for resource bundle events. If
|
||||
// CefSettings.pack_loading_disabled is true a handler must be returned. If no
|
||||
// handler is returned resources will be loaded from pack files. This method
|
||||
// is called by the browser and rendere processes on multiple threads.
|
||||
// is called by the browser and render processes on multiple threads.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() {
|
||||
@ -163,12 +154,20 @@ class CefApp : public virtual CefBase {
|
||||
}
|
||||
|
||||
///
|
||||
// Return the handler for proxy events. If no handler is returned the default
|
||||
// system handler will be used. This method is called by the browser process
|
||||
// IO thread.
|
||||
// Return the handler for functionality specific to the browser process. This
|
||||
// method is called on multiple threads in the browser process.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() {
|
||||
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
///
|
||||
// Return the handler for functionality specific to the render process. This
|
||||
// method is called on the render process main thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() {
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
69
include/cef_browser_process_handler.h
Normal file
69
include/cef_browser_process_handler.h
Normal file
@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// The contents of this file must follow a specific format in order to
|
||||
// support the CEF translator tool. See the translator.README.txt file in the
|
||||
// tools directory for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_
|
||||
#define CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_proxy_handler.h"
|
||||
|
||||
///
|
||||
// Class used to implement browser process callbacks. The methods of this class
|
||||
// will be called on the browser process main thread unless otherwise indicated.
|
||||
///
|
||||
/*--cef(source=client)--*/
|
||||
class CefBrowserProcessHandler : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Return the handler for proxy events. If no handler is returned the default
|
||||
// system handler will be used. This method is called on the browser process
|
||||
// IO thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread immediately after the CEF context
|
||||
// has been initialized.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnContextInitialized() {}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_
|
@ -49,7 +49,7 @@
|
||||
/*--cef(source=client)--*/
|
||||
class CefLoadHandler : public virtual CefBase {
|
||||
public:
|
||||
typedef cef_handler_errorcode_t ErrorCode;
|
||||
typedef cef_errorcode_t ErrorCode;
|
||||
|
||||
///
|
||||
// Called when the browser begins loading a frame. The |frame| value will
|
||||
|
@ -49,23 +49,29 @@ class CefPostDataElement;
|
||||
// Class used to represent a web request. The methods of this class may be
|
||||
// called on any thread.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
/*--cef(source=library,no_debugct_check)--*/
|
||||
class CefRequest : public virtual CefBase {
|
||||
public:
|
||||
typedef std::multimap<CefString, CefString> HeaderMap;
|
||||
typedef cef_weburlrequest_flags_t RequestFlags;
|
||||
|
||||
///
|
||||
// Create a new CefRequest object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefRequest> CreateRequest();
|
||||
static CefRefPtr<CefRequest> Create();
|
||||
|
||||
///
|
||||
// Returns true if this object is read-only.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsReadOnly() =0;
|
||||
|
||||
///
|
||||
// Get the fully qualified URL.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetURL() =0;
|
||||
|
||||
///
|
||||
// Set the fully qualified URL.
|
||||
///
|
||||
@ -78,6 +84,7 @@ class CefRequest : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetMethod() =0;
|
||||
|
||||
///
|
||||
// Set the request method type.
|
||||
///
|
||||
@ -89,6 +96,7 @@ class CefRequest : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefPostData> GetPostData() =0;
|
||||
|
||||
///
|
||||
// Set the post data.
|
||||
///
|
||||
@ -100,6 +108,7 @@ class CefRequest : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetHeaderMap(HeaderMap& headerMap) =0;
|
||||
|
||||
///
|
||||
// Set the header values.
|
||||
///
|
||||
@ -116,25 +125,29 @@ class CefRequest : public virtual CefBase {
|
||||
const HeaderMap& headerMap) =0;
|
||||
|
||||
///
|
||||
// Get the flags used in combination with CefWebURLRequest.
|
||||
// Get the flags used in combination with CefURLRequest. See
|
||||
// cef_urlrequest_flags_t for supported values.
|
||||
///
|
||||
/*--cef(default_retval=WUR_FLAG_NONE)--*/
|
||||
virtual RequestFlags GetFlags() =0;
|
||||
/*--cef(default_retval=UR_FLAG_NONE)--*/
|
||||
virtual int GetFlags() =0;
|
||||
|
||||
///
|
||||
// Set the flags used in combination with CefWebURLRequest.
|
||||
// Set the flags used in combination with CefURLRequest. See
|
||||
// cef_urlrequest_flags_t for supported values.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetFlags(RequestFlags flags) =0;
|
||||
virtual void SetFlags(int flags) =0;
|
||||
|
||||
///
|
||||
// Set the URL to the first party for cookies used in combination with
|
||||
// CefWebURLRequest.
|
||||
// CefURLRequest.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetFirstPartyForCookies() =0;
|
||||
|
||||
///
|
||||
// Get the URL to the first party for cookies used in combination with
|
||||
// CefWebURLRequest.
|
||||
// CefURLRequest.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetFirstPartyForCookies(const CefString& url) =0;
|
||||
@ -145,7 +158,7 @@ class CefRequest : public virtual CefBase {
|
||||
// Class used to represent post data for a web request. The methods of this
|
||||
// class may be called on any thread.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
/*--cef(source=library,no_debugct_check)--*/
|
||||
class CefPostData : public virtual CefBase {
|
||||
public:
|
||||
typedef std::vector<CefRefPtr<CefPostDataElement> > ElementVector;
|
||||
@ -154,7 +167,13 @@ class CefPostData : public virtual CefBase {
|
||||
// Create a new CefPostData object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefPostData> CreatePostData();
|
||||
static CefRefPtr<CefPostData> Create();
|
||||
|
||||
///
|
||||
// Returns true if this object is read-only.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsReadOnly() =0;
|
||||
|
||||
///
|
||||
// Returns the number of existing post data elements.
|
||||
@ -193,7 +212,7 @@ class CefPostData : public virtual CefBase {
|
||||
// Class used to represent a single element in the request post data. The
|
||||
// methods of this class may be called on any thread.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
/*--cef(source=library,no_debugct_check)--*/
|
||||
class CefPostDataElement : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
@ -205,7 +224,13 @@ class CefPostDataElement : public virtual CefBase {
|
||||
// Create a new CefPostDataElement object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefPostDataElement> CreatePostDataElement();
|
||||
static CefRefPtr<CefPostDataElement> Create();
|
||||
|
||||
///
|
||||
// Returns true if this object is read-only.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsReadOnly() =0;
|
||||
|
||||
///
|
||||
// Remove all contents from the post data element.
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_callback.h"
|
||||
#include "include/cef_cookie.h"
|
||||
#include "include/cef_request.h"
|
||||
#include "include/cef_response.h"
|
||||
|
||||
@ -90,6 +91,21 @@ class CefResourceHandler : public virtual CefBase {
|
||||
int& bytes_read,
|
||||
CefRefPtr<CefCallback> callback) =0;
|
||||
|
||||
///
|
||||
// Return true if the specified cookie can be sent with the request or false
|
||||
// otherwise. If false is returned for any cookie then no cookies will be sent
|
||||
// with the request.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool CanGetCookie(const CefCookie& cookie) { return true; }
|
||||
|
||||
///
|
||||
// Return true if the specified cookie returned with the response can be set
|
||||
// or false otherwise.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool CanSetCookie(const CefCookie& cookie) { return true; }
|
||||
|
||||
///
|
||||
// Request processing has been canceled.
|
||||
///
|
||||
|
@ -45,16 +45,29 @@
|
||||
// Class used to represent a web response. The methods of this class may be
|
||||
// called on any thread.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
/*--cef(source=library,no_debugct_check)--*/
|
||||
class CefResponse : public virtual CefBase {
|
||||
public:
|
||||
typedef std::multimap<CefString, CefString> HeaderMap;
|
||||
|
||||
///
|
||||
// Create a new CefResponse object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefResponse> Create();
|
||||
|
||||
///
|
||||
// Returns true if this object is read-only.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsReadOnly() =0;
|
||||
|
||||
///
|
||||
// Get the response status code.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual int GetStatus() =0;
|
||||
|
||||
///
|
||||
// Set the response status code.
|
||||
///
|
||||
@ -66,6 +79,7 @@ class CefResponse : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetStatusText() =0;
|
||||
|
||||
///
|
||||
// Set the response status text.
|
||||
///
|
||||
@ -77,6 +91,7 @@ class CefResponse : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetMimeType() = 0;
|
||||
|
||||
///
|
||||
// Set the response mime type.
|
||||
///
|
||||
@ -94,6 +109,7 @@ class CefResponse : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetHeaderMap(HeaderMap& headerMap) =0;
|
||||
|
||||
///
|
||||
// Set all response header fields.
|
||||
///
|
||||
|
@ -143,11 +143,12 @@ class CefSchemeHandlerFactory : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Return a new resource handler instance to handle the request. |browser|
|
||||
// will be the browser window that initiated the request. If the request was
|
||||
// initiated using the CefWebURLRequest API |browser| will be NULL. The
|
||||
// and |frame| will be the browser window and frame respectively that
|
||||
// originated the request or NULL if the request did not originate from a
|
||||
// browser window (for example, if the request came from CefURLRequest). The
|
||||
// |request| object passed to this method will not contain cookie data.
|
||||
///
|
||||
/*--cef()--*/
|
||||
/*--cef(optional_param=browser,optional_param=frame)--*/
|
||||
virtual CefRefPtr<CefResourceHandler> Create(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
|
159
include/cef_urlrequest.h
Normal file
159
include/cef_urlrequest.h
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// The contents of this file must follow a specific format in order to
|
||||
// support the CEF translator tool. See the translator.README.txt file in the
|
||||
// tools directory for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CEF_URLREQUEST_H_
|
||||
#define CEF_INCLUDE_CEF_URLREQUEST_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_request.h"
|
||||
#include "include/cef_response.h"
|
||||
|
||||
class CefURLRequestClient;
|
||||
|
||||
///
|
||||
// Class used to make a URL request. URL requests are not associated with a
|
||||
// browser instance so no CefClient callbacks will be executed. URL requests
|
||||
// can be created on any valid CEF thread in either the browser or render
|
||||
// process. Once created the methods of the URL request object must be accessed
|
||||
// on the same thread that created it.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefURLRequest : public virtual CefBase {
|
||||
public:
|
||||
typedef cef_urlrequest_status_t Status;
|
||||
typedef cef_errorcode_t ErrorCode;
|
||||
|
||||
///
|
||||
// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request
|
||||
// methods are supported. The |request| object will be marked as read-only
|
||||
// after calling this method.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefURLRequest> Create(
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client);
|
||||
|
||||
///
|
||||
// Returns the request object used to create this URL request. The returned
|
||||
// object is read-only and should not be modified.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefRequest> GetRequest() =0;
|
||||
|
||||
///
|
||||
// Returns the client.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefURLRequestClient> GetClient() =0;
|
||||
|
||||
///
|
||||
// Returns the request status.
|
||||
///
|
||||
/*--cef(default_retval=UR_UNKNOWN)--*/
|
||||
virtual Status GetRequestStatus() =0;
|
||||
|
||||
///
|
||||
// Returns the request error if status is UR_CANCELED or UR_FAILED, or 0
|
||||
// otherwise.
|
||||
///
|
||||
/*--cef(default_retval=ERR_NONE)--*/
|
||||
virtual ErrorCode GetRequestError() =0;
|
||||
|
||||
///
|
||||
// Returns the response, or NULL if no response information is available.
|
||||
// Response information will only be available after the upload has completed.
|
||||
// The returned object is read-only and should not be modified.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefResponse> GetResponse() =0;
|
||||
|
||||
///
|
||||
// Cancel the request.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void Cancel() =0;
|
||||
};
|
||||
|
||||
///
|
||||
// Interface that should be implemented by the CefURLRequest client. The
|
||||
// methods of this class will be called on the same thread that created the
|
||||
// request.
|
||||
///
|
||||
/*--cef(source=client)--*/
|
||||
class CefURLRequestClient : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Notifies the client that the request has completed. Use the
|
||||
// CefURLRequest::GetRequestStatus method to determine if the request was
|
||||
// successful or not.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnRequestComplete(CefRefPtr<CefURLRequest> request) =0;
|
||||
|
||||
///
|
||||
// Notifies the client of upload progress. |current| denotes the number of
|
||||
// bytes sent so far and |total| is the total size of uploading data (or -1 if
|
||||
// chunked upload is enabled). This method will only be called if the
|
||||
// UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnUploadProgress(CefRefPtr<CefURLRequest> request,
|
||||
uint64 current,
|
||||
uint64 total) =0;
|
||||
|
||||
///
|
||||
// Notifies the client of download progress. |current| denotes the number of
|
||||
// bytes received up to the call and |total| is the expected total size of the
|
||||
// response (or -1 if not determined).
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnDownloadProgress(CefRefPtr<CefURLRequest> request,
|
||||
uint64 current,
|
||||
uint64 total) =0;
|
||||
|
||||
///
|
||||
// Called when some part of the response is read. |data| contains the current
|
||||
// bytes received since the last call. This method will not be called if the
|
||||
// UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnDownloadData(CefRefPtr<CefURLRequest> request,
|
||||
const void* data,
|
||||
size_t data_length) =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_URLREQUEST_H_
|
@ -57,6 +57,10 @@
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_
|
||||
#pragma once
|
||||
|
||||
// If base/tuple.h is included first then exclude this file. This is to
|
||||
// facilitate the use of both base/bind.h and cef_runnable.h in unit tests.
|
||||
#ifndef BASE_TUPLE_H__
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
// To troubleshoot crosbug.com/7327.
|
||||
#include "base/logging.h"
|
||||
@ -1079,4 +1083,6 @@ inline void DispatchToMethod(ObjT* obj, Method method,
|
||||
&out->a, &out->b, &out->c, &out->d, &out->e);
|
||||
}
|
||||
|
||||
#endif // BASE_TUPLE_H__
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_
|
||||
|
@ -565,7 +565,8 @@ enum cef_storage_type_t {
|
||||
// Supported error code values. See net\base\net_error_list.h for complete
|
||||
// descriptions of the error codes.
|
||||
///
|
||||
enum cef_handler_errorcode_t {
|
||||
enum cef_errorcode_t {
|
||||
ERR_NONE = 0,
|
||||
ERR_FAILED = -2,
|
||||
ERR_ABORTED = -3,
|
||||
ERR_INVALID_ARGUMENT = -4,
|
||||
@ -646,14 +647,95 @@ enum cef_postdataelement_type_t {
|
||||
PDE_TYPE_FILE,
|
||||
};
|
||||
|
||||
enum cef_weburlrequest_flags_t {
|
||||
WUR_FLAG_NONE = 0,
|
||||
WUR_FLAG_SKIP_CACHE = 0x1,
|
||||
WUR_FLAG_ALLOW_CACHED_CREDENTIALS = 0x2,
|
||||
WUR_FLAG_ALLOW_COOKIES = 0x4,
|
||||
WUR_FLAG_REPORT_UPLOAD_PROGRESS = 0x8,
|
||||
WUR_FLAG_REPORT_LOAD_TIMING = 0x10,
|
||||
WUR_FLAG_REPORT_RAW_HEADERS = 0x20
|
||||
///
|
||||
// Flags used to customize the behavior of CefURLRequest.
|
||||
///
|
||||
enum cef_urlrequest_flags_t {
|
||||
///
|
||||
// Default behavior.
|
||||
///
|
||||
UR_FLAG_NONE = 0,
|
||||
|
||||
///
|
||||
// If set the cache will be skipped when handling the request.
|
||||
///
|
||||
UR_FLAG_SKIP_CACHE = 1 << 0,
|
||||
|
||||
///
|
||||
// If set user name, password, and cookies may be sent with the request.
|
||||
///
|
||||
UR_FLAG_ALLOW_CACHED_CREDENTIALS = 1 << 1,
|
||||
|
||||
///
|
||||
// If set cookies may be sent with the request and saved from the response.
|
||||
// UR_FLAG_ALLOW_CACHED_CREDENTIALS must also be set.
|
||||
///
|
||||
UR_FLAG_ALLOW_COOKIES = 1 << 2,
|
||||
|
||||
///
|
||||
// If set upload progress events will be generated when a request has a body.
|
||||
///
|
||||
UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 3,
|
||||
|
||||
///
|
||||
// If set load timing info will be collected for the request.
|
||||
///
|
||||
UR_FLAG_REPORT_LOAD_TIMING = 1 << 4,
|
||||
|
||||
///
|
||||
// If set the headers sent and received for the request will be recorded.
|
||||
///
|
||||
UR_FLAG_REPORT_RAW_HEADERS = 1 << 5,
|
||||
|
||||
///
|
||||
// If set the CefURLRequestClient::OnDownloadData method will not be called.
|
||||
///
|
||||
UR_FLAG_NO_DOWNLOAD_DATA = 1 << 6,
|
||||
|
||||
///
|
||||
// If set 5XX redirect errors will be propagated to the observer instead of
|
||||
// automatically re-tried. This currently only applies for requests
|
||||
// originated in the browser process.
|
||||
///
|
||||
UR_FLAG_NO_RETRY_ON_5XX = 1 << 7,
|
||||
};
|
||||
|
||||
///
|
||||
// Flags that represent CefURLRequest status.
|
||||
///
|
||||
enum cef_urlrequest_status_t {
|
||||
///
|
||||
// Unknown status.
|
||||
///
|
||||
UR_UNKNOWN = 0,
|
||||
|
||||
///
|
||||
// Request succeeded.
|
||||
///
|
||||
UR_SUCCESS,
|
||||
|
||||
///
|
||||
// An IO request is pending, and the caller will be informed when it is
|
||||
// completed.
|
||||
///
|
||||
UR_IO_PENDING,
|
||||
|
||||
///
|
||||
// Request was successful but was handled by an external program, so there
|
||||
// is no response data. This usually means the current page should not be
|
||||
// navigated, but no error should be displayed.
|
||||
///
|
||||
UR_HANDLED_EXTERNALLY,
|
||||
|
||||
///
|
||||
// Request was canceled programatically.
|
||||
///
|
||||
UR_CANCELED,
|
||||
|
||||
///
|
||||
// Request failed for some reason.
|
||||
///
|
||||
UR_FAILED,
|
||||
};
|
||||
|
||||
///
|
||||
|
@ -1462,7 +1462,7 @@ void CefBrowserHostImpl::OnLoadError(CefRefPtr<CefFrame> frame,
|
||||
if (handler.get()) {
|
||||
// Notify the handler that loading has failed.
|
||||
handler->OnLoadError(this, frame,
|
||||
static_cast<cef_handler_errorcode_t>(error_code),
|
||||
static_cast<cef_errorcode_t>(error_code),
|
||||
CefString(error_description),
|
||||
url.spec());
|
||||
}
|
||||
|
442
libcef/browser/browser_urlrequest_impl.cc
Normal file
442
libcef/browser/browser_urlrequest_impl.cc
Normal file
@ -0,0 +1,442 @@
|
||||
// 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.
|
||||
|
||||
#include "libcef/browser/browser_urlrequest_impl.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/http_header_utils.h"
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/common/response_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/string_util.h"
|
||||
#include "content/public/common/url_fetcher.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/url_request/url_fetcher_delegate.h"
|
||||
#include "net/url_request/url_request_status.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
class CefURLFetcherDelegate : public net::URLFetcherDelegate {
|
||||
public:
|
||||
CefURLFetcherDelegate(CefBrowserURLRequest::Context* context,
|
||||
int request_flags);
|
||||
virtual ~CefURLFetcherDelegate();
|
||||
|
||||
// net::URLFetcherDelegate methods.
|
||||
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
|
||||
virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source,
|
||||
int64 current, int64 total) OVERRIDE;
|
||||
virtual void OnURLFetchDownloadData(const net::URLFetcher* source,
|
||||
scoped_ptr<std::string> download_data)
|
||||
OVERRIDE;
|
||||
virtual bool ShouldSendDownloadData() OVERRIDE;
|
||||
virtual void OnURLFetchUploadProgress(const net::URLFetcher* source,
|
||||
int64 current, int64 total) OVERRIDE;
|
||||
|
||||
private:
|
||||
// The context_ pointer will outlive this object.
|
||||
CefBrowserURLRequest::Context* context_;
|
||||
int request_flags_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
// CefBrowserURLRequest::Context ----------------------------------------------
|
||||
|
||||
class CefBrowserURLRequest::Context
|
||||
: public base::RefCountedThreadSafe<CefBrowserURLRequest::Context> {
|
||||
public:
|
||||
Context(CefRefPtr<CefBrowserURLRequest> url_request,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client)
|
||||
: url_request_(url_request),
|
||||
request_(request),
|
||||
client_(client),
|
||||
message_loop_proxy_(MessageLoop::current()->message_loop_proxy()),
|
||||
status_(UR_IO_PENDING),
|
||||
error_code_(ERR_NONE),
|
||||
upload_data_size_(0),
|
||||
got_upload_progress_complete_(false) {
|
||||
// Mark the request as read-only.
|
||||
static_cast<CefRequestImpl*>(request_.get())->SetReadOnly(true);
|
||||
}
|
||||
|
||||
virtual ~Context() {
|
||||
if (fetcher_.get()) {
|
||||
// Delete the fetcher object on the thread that created it.
|
||||
message_loop_proxy_->DeleteSoon(FROM_HERE, fetcher_.release());
|
||||
}
|
||||
}
|
||||
|
||||
inline bool CalledOnValidThread() {
|
||||
return message_loop_proxy_->BelongsToCurrentThread();
|
||||
}
|
||||
|
||||
bool Start() {
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
GURL url = GURL(request_->GetURL().ToString());
|
||||
if (!url.is_valid())
|
||||
return false;
|
||||
|
||||
std::string method = request_->GetMethod();
|
||||
StringToLowerASCII(&method);
|
||||
net::URLFetcher::RequestType request_type = net::URLFetcher::GET;
|
||||
if (LowerCaseEqualsASCII(method, "get")) {
|
||||
} else if (LowerCaseEqualsASCII(method, "post")) {
|
||||
request_type = net::URLFetcher::POST;
|
||||
} else if (LowerCaseEqualsASCII(method, "head")) {
|
||||
request_type = net::URLFetcher::HEAD;
|
||||
} else if (LowerCaseEqualsASCII(method, "delete")) {
|
||||
request_type = net::URLFetcher::DELETE_REQUEST;
|
||||
} else if (LowerCaseEqualsASCII(method, "put")) {
|
||||
request_type = net::URLFetcher::PUT;
|
||||
} else {
|
||||
NOTREACHED() << "invalid request type";
|
||||
return false;
|
||||
}
|
||||
|
||||
fetcher_delegate_.reset(
|
||||
new CefURLFetcherDelegate(this, request_->GetFlags()));
|
||||
|
||||
fetcher_.reset(content::URLFetcher::Create(url, request_type,
|
||||
fetcher_delegate_.get()));
|
||||
fetcher_->SetRequestContext(
|
||||
_Context->browser_context()->GetRequestContext());
|
||||
|
||||
CefRequest::HeaderMap headerMap;
|
||||
request_->GetHeaderMap(headerMap);
|
||||
|
||||
// Extract the Referer header value.
|
||||
{
|
||||
CefString referrerStr;
|
||||
referrerStr.FromASCII(net::HttpRequestHeaders::kReferer);
|
||||
CefRequest::HeaderMap::iterator it = headerMap.find(referrerStr);
|
||||
if (it == headerMap.end()) {
|
||||
fetcher_->SetReferrer("");
|
||||
} else {
|
||||
fetcher_->SetReferrer(it->second);
|
||||
headerMap.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
std::string content_type;
|
||||
|
||||
// Extract the Content-Type header value.
|
||||
{
|
||||
CefString contentTypeStr;
|
||||
contentTypeStr.FromASCII(net::HttpRequestHeaders::kContentType);
|
||||
CefRequest::HeaderMap::iterator it = headerMap.find(contentTypeStr);
|
||||
if (it != headerMap.end()) {
|
||||
content_type = it->second;
|
||||
headerMap.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
int64 upload_data_size = 0;
|
||||
|
||||
CefRefPtr<CefPostData> post_data = request_->GetPostData();
|
||||
if (post_data.get()) {
|
||||
CefPostData::ElementVector elements;
|
||||
post_data->GetElements(elements);
|
||||
if (elements.size() == 1 && elements[0]->GetType() == PDE_TYPE_BYTES) {
|
||||
CefPostDataElementImpl* impl =
|
||||
static_cast<CefPostDataElementImpl*>(elements[0].get());
|
||||
|
||||
// Default to URL encoding if not specified.
|
||||
if (content_type.empty())
|
||||
content_type = "application/x-www-form-urlencoded";
|
||||
|
||||
upload_data_size = impl->GetBytesCount();
|
||||
fetcher_->SetUploadData(content_type,
|
||||
std::string(static_cast<char*>(impl->GetBytes()),
|
||||
upload_data_size));
|
||||
} else {
|
||||
NOTIMPLEMENTED() << "multi-part form data is not supported";
|
||||
}
|
||||
}
|
||||
|
||||
std::string first_party_for_cookies = request_->GetFirstPartyForCookies();
|
||||
if (!first_party_for_cookies.empty())
|
||||
fetcher_->SetFirstPartyForCookies(GURL(first_party_for_cookies));
|
||||
|
||||
int cef_flags = request_->GetFlags();
|
||||
|
||||
if (cef_flags & UR_FLAG_NO_RETRY_ON_5XX)
|
||||
fetcher_->SetAutomaticallyRetryOn5xx(false);
|
||||
|
||||
int load_flags = 0;
|
||||
|
||||
if (cef_flags & UR_FLAG_SKIP_CACHE)
|
||||
load_flags |= net::LOAD_BYPASS_CACHE;
|
||||
|
||||
if (cef_flags & UR_FLAG_ALLOW_CACHED_CREDENTIALS) {
|
||||
if (!(cef_flags & UR_FLAG_ALLOW_COOKIES)) {
|
||||
load_flags |= net::LOAD_DO_NOT_SEND_COOKIES;
|
||||
load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES;
|
||||
}
|
||||
} else {
|
||||
load_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA;
|
||||
load_flags |= net::LOAD_DO_NOT_SEND_COOKIES;
|
||||
load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES;
|
||||
}
|
||||
|
||||
if (cef_flags & UR_FLAG_REPORT_UPLOAD_PROGRESS) {
|
||||
load_flags |= net::LOAD_ENABLE_UPLOAD_PROGRESS;
|
||||
upload_data_size_ = upload_data_size;
|
||||
}
|
||||
|
||||
if (cef_flags & UR_FLAG_REPORT_LOAD_TIMING)
|
||||
load_flags |= net::LOAD_ENABLE_LOAD_TIMING;
|
||||
|
||||
if (cef_flags & UR_FLAG_REPORT_RAW_HEADERS)
|
||||
load_flags |= net::LOAD_REPORT_RAW_HEADERS;
|
||||
|
||||
fetcher_->SetLoadFlags(load_flags);
|
||||
|
||||
fetcher_->SetExtraRequestHeaders(
|
||||
HttpHeaderUtils::GenerateHeaders(headerMap));
|
||||
|
||||
fetcher_->Start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Cancel() {
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
// The request may already be complete.
|
||||
if (!fetcher_.get())
|
||||
return;
|
||||
|
||||
// Cancel the fetch by deleting the fetcher.
|
||||
fetcher_.reset(NULL);
|
||||
|
||||
status_ = UR_CANCELED;
|
||||
error_code_ = ERR_ABORTED;
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
void OnComplete() {
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
if (fetcher_.get()) {
|
||||
const net::URLRequestStatus& status = fetcher_->GetStatus();
|
||||
|
||||
if (status.is_success())
|
||||
NotifyUploadProgressIfNecessary();
|
||||
|
||||
switch (status.status()) {
|
||||
case net::URLRequestStatus::SUCCESS:
|
||||
status_ = UR_SUCCESS;
|
||||
break;
|
||||
case net::URLRequestStatus::IO_PENDING:
|
||||
status_ = UR_IO_PENDING;
|
||||
break;
|
||||
case net::URLRequestStatus::HANDLED_EXTERNALLY:
|
||||
status_ = UR_HANDLED_EXTERNALLY;
|
||||
break;
|
||||
case net::URLRequestStatus::CANCELED:
|
||||
status_ = UR_CANCELED;
|
||||
break;
|
||||
case net::URLRequestStatus::FAILED:
|
||||
status_ = UR_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
error_code_ = static_cast<CefURLRequest::ErrorCode>(status.error());
|
||||
|
||||
response_ = new CefResponseImpl();
|
||||
CefResponseImpl* responseImpl =
|
||||
static_cast<CefResponseImpl*>(response_.get());
|
||||
|
||||
net::HttpResponseHeaders* headers = fetcher_->GetResponseHeaders();
|
||||
if (headers)
|
||||
responseImpl->SetResponseHeaders(*headers);
|
||||
|
||||
responseImpl->SetReadOnly(true);
|
||||
}
|
||||
|
||||
DCHECK(url_request_.get());
|
||||
client_->OnRequestComplete(url_request_.get());
|
||||
|
||||
if (fetcher_.get())
|
||||
fetcher_.reset(NULL);
|
||||
|
||||
// This may result in the Context object being deleted.
|
||||
url_request_ = NULL;
|
||||
}
|
||||
|
||||
void OnDownloadProgress(int64 current, int64 total) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK(url_request_.get());
|
||||
|
||||
NotifyUploadProgressIfNecessary();
|
||||
|
||||
client_->OnDownloadProgress(url_request_.get(), current, total);
|
||||
}
|
||||
|
||||
void OnDownloadData(scoped_ptr<std::string> download_data) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK(url_request_.get());
|
||||
client_->OnDownloadData(url_request_.get(), download_data->c_str(),
|
||||
download_data->length());
|
||||
}
|
||||
|
||||
void OnUploadProgress(int64 current, int64 total) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK(url_request_.get());
|
||||
if (current == total)
|
||||
got_upload_progress_complete_ = true;
|
||||
client_->OnUploadProgress(url_request_.get(), current, total);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> request() { return request_; }
|
||||
CefRefPtr<CefURLRequestClient> client() { return client_; }
|
||||
CefURLRequest::Status status() { return status_; }
|
||||
CefURLRequest::ErrorCode error_code() { return error_code_; }
|
||||
CefRefPtr<CefResponse> response() { return response_; }
|
||||
|
||||
private:
|
||||
void NotifyUploadProgressIfNecessary() {
|
||||
if (!got_upload_progress_complete_ && upload_data_size_ > 0) {
|
||||
// URLFetcher sends upload notifications using a timer and will not send
|
||||
// a notification if the request completes too quickly. We therefore
|
||||
// send the notification here if necessary.
|
||||
client_->OnUploadProgress(url_request_.get(), upload_data_size_,
|
||||
upload_data_size_);
|
||||
got_upload_progress_complete_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Members only accessed on the initialization thread.
|
||||
CefRefPtr<CefBrowserURLRequest> url_request_;
|
||||
CefRefPtr<CefRequest> request_;
|
||||
CefRefPtr<CefURLRequestClient> client_;
|
||||
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
|
||||
scoped_ptr<net::URLFetcher> fetcher_;
|
||||
scoped_ptr<CefURLFetcherDelegate> fetcher_delegate_;
|
||||
CefURLRequest::Status status_;
|
||||
CefURLRequest::ErrorCode error_code_;
|
||||
CefRefPtr<CefResponse> response_;
|
||||
int64 upload_data_size_;
|
||||
bool got_upload_progress_complete_;
|
||||
};
|
||||
|
||||
|
||||
// CefURLFetcherDelegate ------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
|
||||
CefURLFetcherDelegate::CefURLFetcherDelegate(
|
||||
CefBrowserURLRequest::Context* context, int request_flags)
|
||||
: context_(context),
|
||||
request_flags_(request_flags) {
|
||||
}
|
||||
|
||||
CefURLFetcherDelegate::~CefURLFetcherDelegate() {
|
||||
}
|
||||
|
||||
void CefURLFetcherDelegate::OnURLFetchComplete(
|
||||
const net::URLFetcher* source) {
|
||||
context_->OnComplete();
|
||||
}
|
||||
|
||||
void CefURLFetcherDelegate::OnURLFetchDownloadProgress(
|
||||
const net::URLFetcher* source,
|
||||
int64 current, int64 total) {
|
||||
context_->OnDownloadProgress(current, total);
|
||||
}
|
||||
|
||||
void CefURLFetcherDelegate::OnURLFetchDownloadData(
|
||||
const net::URLFetcher* source,
|
||||
scoped_ptr<std::string> download_data) {
|
||||
context_->OnDownloadData(download_data.Pass());
|
||||
}
|
||||
|
||||
bool CefURLFetcherDelegate::ShouldSendDownloadData() {
|
||||
return !(request_flags_ & UR_FLAG_NO_DOWNLOAD_DATA);
|
||||
}
|
||||
|
||||
void CefURLFetcherDelegate::OnURLFetchUploadProgress(
|
||||
const net::URLFetcher* source,
|
||||
int64 current, int64 total) {
|
||||
if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS)
|
||||
context_->OnUploadProgress(current, total);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
// CefBrowserURLRequest -------------------------------------------------------
|
||||
|
||||
CefBrowserURLRequest::CefBrowserURLRequest(
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client) {
|
||||
context_ = new Context(this, request, client);
|
||||
}
|
||||
|
||||
CefBrowserURLRequest::~CefBrowserURLRequest() {
|
||||
}
|
||||
|
||||
bool CefBrowserURLRequest::Start() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
return context_->Start();
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> CefBrowserURLRequest::GetRequest() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
return context_->request();
|
||||
}
|
||||
|
||||
CefRefPtr<CefURLRequestClient> CefBrowserURLRequest::GetClient() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
return context_->client();
|
||||
}
|
||||
|
||||
CefURLRequest::Status CefBrowserURLRequest::GetRequestStatus() {
|
||||
if (!VerifyContext())
|
||||
return UR_UNKNOWN;
|
||||
return context_->status();
|
||||
}
|
||||
|
||||
CefURLRequest::ErrorCode CefBrowserURLRequest::GetRequestError() {
|
||||
if (!VerifyContext())
|
||||
return ERR_NONE;
|
||||
return context_->error_code();
|
||||
}
|
||||
|
||||
CefRefPtr<CefResponse> CefBrowserURLRequest::GetResponse() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
return context_->response();
|
||||
}
|
||||
|
||||
void CefBrowserURLRequest::Cancel() {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
return context_->Cancel();
|
||||
}
|
||||
|
||||
bool CefBrowserURLRequest::VerifyContext() {
|
||||
DCHECK(context_.get());
|
||||
if (!context_->CalledOnValidThread()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
37
libcef/browser/browser_urlrequest_impl.h
Normal file
37
libcef/browser/browser_urlrequest_impl.h
Normal file
@ -0,0 +1,37 @@
|
||||
// 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_BROWSER_BROWSER_URLREQUEST_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_BROWSER_URLREQUEST_IMPL_H_
|
||||
|
||||
#include "include/cef_urlrequest.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
|
||||
class CefBrowserURLRequest : public CefURLRequest {
|
||||
public:
|
||||
class Context;
|
||||
|
||||
CefBrowserURLRequest(CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client);
|
||||
virtual ~CefBrowserURLRequest();
|
||||
|
||||
bool Start();
|
||||
|
||||
// CefURLRequest methods.
|
||||
virtual CefRefPtr<CefRequest> GetRequest() OVERRIDE;
|
||||
virtual CefRefPtr<CefURLRequestClient> GetClient() OVERRIDE;
|
||||
virtual Status GetRequestStatus() OVERRIDE;
|
||||
virtual ErrorCode GetRequestError() OVERRIDE;
|
||||
virtual CefRefPtr<CefResponse> GetResponse() OVERRIDE;
|
||||
virtual void Cancel() OVERRIDE;
|
||||
|
||||
private:
|
||||
bool VerifyContext();
|
||||
|
||||
scoped_refptr<Context> context_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefBrowserURLRequest);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_BROWSER_URLREQUEST_IMPL_H_
|
@ -216,14 +216,14 @@ bool CefContext::Initialize(const CefMainArgs& args,
|
||||
if (exit_code >= 0)
|
||||
return false;
|
||||
|
||||
// Run the process. Results in a call to CefMainDelegate::RunKnownProcess()
|
||||
// which will create the browser runner and message loop without blocking.
|
||||
// Run the process. Results in a call to CefMainDelegate::RunProcess() which
|
||||
// will create the browser runner and message loop without blocking.
|
||||
exit_code = main_runner_->Run();
|
||||
|
||||
initialized_ = true;
|
||||
|
||||
// Perform DevTools scheme registration when CEF initialization is complete.
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(&RegisterDevToolsSchemeHandler));
|
||||
// Continue initialization on the UI thread.
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(&CefContext::OnContextInitialized, this));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -346,6 +346,22 @@ CefDevToolsDelegate* CefContext::devtools_delegate() const {
|
||||
devtools_delegate();
|
||||
}
|
||||
|
||||
void CefContext::OnContextInitialized() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// Perform DevTools scheme registration.
|
||||
RegisterDevToolsSchemeHandler();
|
||||
|
||||
// Notify the handler.
|
||||
CefRefPtr<CefApp> app = application();
|
||||
if (app.get()) {
|
||||
CefRefPtr<CefBrowserProcessHandler> handler =
|
||||
app->GetBrowserProcessHandler();
|
||||
if (handler.get())
|
||||
handler->OnContextInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
void CefContext::FinishShutdownOnUIThread(
|
||||
base::WaitableEvent* uithread_shutdown_event) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
@ -69,6 +69,8 @@ class CefContext : public CefBase {
|
||||
CefDevToolsDelegate* devtools_delegate() const;
|
||||
|
||||
private:
|
||||
void OnContextInitialized();
|
||||
|
||||
// Performs shutdown actions that need to occur on the UI thread before any
|
||||
// threads are destroyed.
|
||||
void FinishShutdownOnUIThread(base::WaitableEvent* uithread_shutdown_event);
|
||||
|
@ -14,10 +14,12 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/file_util.h"
|
||||
#include "base/format_macros.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "chrome/browser/net/sqlite_persistent_cookie_store.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "net/cookies/cookie_util.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
|
||||
namespace {
|
||||
@ -40,18 +42,7 @@ class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
|
||||
for (; it != list.end(); ++it, ++count) {
|
||||
CefCookie cookie;
|
||||
const net::CookieMonster::CanonicalCookie& cc = *(it);
|
||||
|
||||
CefString(&cookie.name).FromString(cc.Name());
|
||||
CefString(&cookie.value).FromString(cc.Value());
|
||||
CefString(&cookie.domain).FromString(cc.Domain());
|
||||
CefString(&cookie.path).FromString(cc.Path());
|
||||
cookie.secure = cc.IsSecure();
|
||||
cookie.httponly = cc.IsHttpOnly();
|
||||
cef_time_from_basetime(cc.CreationDate(), cookie.creation);
|
||||
cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access);
|
||||
cookie.has_expires = cc.DoesExpire();
|
||||
if (cookie.has_expires)
|
||||
cef_time_from_basetime(cc.ExpiryDate(), cookie.expires);
|
||||
CefCookieManagerImpl::GetCefCookie(cc, cookie);
|
||||
|
||||
bool deleteCookie = false;
|
||||
bool keepLooping = visitor_->Visit(cookie, count, total, deleteCookie);
|
||||
@ -69,6 +60,80 @@ class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
|
||||
CefRefPtr<CefCookieVisitor> visitor_;
|
||||
};
|
||||
|
||||
|
||||
// Methods extracted from net/cookies/cookie_monster.cc
|
||||
|
||||
// Determine the cookie domain to use for setting the specified cookie.
|
||||
bool GetCookieDomain(const GURL& url,
|
||||
const net::CookieMonster::ParsedCookie& pc,
|
||||
std::string* result) {
|
||||
std::string domain_string;
|
||||
if (pc.HasDomain())
|
||||
domain_string = pc.Domain();
|
||||
return net::cookie_util::GetCookieDomainWithString(url, domain_string,
|
||||
result);
|
||||
}
|
||||
|
||||
std::string CanonPathWithString(const GURL& url,
|
||||
const std::string& path_string) {
|
||||
// The RFC says the path should be a prefix of the current URL path.
|
||||
// However, Mozilla allows you to set any path for compatibility with
|
||||
// broken websites. We unfortunately will mimic this behavior. We try
|
||||
// to be generous and accept cookies with an invalid path attribute, and
|
||||
// default the path to something reasonable.
|
||||
|
||||
// The path was supplied in the cookie, we'll take it.
|
||||
if (!path_string.empty() && path_string[0] == '/')
|
||||
return path_string;
|
||||
|
||||
// The path was not supplied in the cookie or invalid, we will default
|
||||
// to the current URL path.
|
||||
// """Defaults to the path of the request URL that generated the
|
||||
// Set-Cookie response, up to, but not including, the
|
||||
// right-most /."""
|
||||
// How would this work for a cookie on /? We will include it then.
|
||||
const std::string& url_path = url.path();
|
||||
|
||||
size_t idx = url_path.find_last_of('/');
|
||||
|
||||
// The cookie path was invalid or a single '/'.
|
||||
if (idx == 0 || idx == std::string::npos)
|
||||
return std::string("/");
|
||||
|
||||
// Return up to the rightmost '/'.
|
||||
return url_path.substr(0, idx);
|
||||
}
|
||||
|
||||
std::string CanonPath(const GURL& url,
|
||||
const net::CookieMonster::ParsedCookie& pc) {
|
||||
std::string path_string;
|
||||
if (pc.HasPath())
|
||||
path_string = pc.Path();
|
||||
return CanonPathWithString(url, path_string);
|
||||
}
|
||||
|
||||
base::Time CanonExpiration(const net::CookieMonster::ParsedCookie& pc,
|
||||
const base::Time& current) {
|
||||
// First, try the Max-Age attribute.
|
||||
uint64 max_age = 0;
|
||||
if (pc.HasMaxAge() &&
|
||||
#ifdef COMPILER_MSVC
|
||||
sscanf_s(
|
||||
#else
|
||||
sscanf(
|
||||
#endif
|
||||
pc.MaxAge().c_str(), " %" PRIu64, &max_age) == 1) {
|
||||
return current + base::TimeDelta::FromSeconds(max_age);
|
||||
}
|
||||
|
||||
// Try the Expires attribute.
|
||||
if (pc.HasExpires())
|
||||
return net::CookieMonster::ParseCookieTime(pc.Expires());
|
||||
|
||||
// Invalid or no expiration, persistent cookie.
|
||||
return base::Time();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@ -89,12 +154,34 @@ void CefCookieManagerImpl::Initialize(const CefString& path) {
|
||||
void CefCookieManagerImpl::SetSupportedSchemes(
|
||||
const std::vector<CefString>& schemes) {
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
if (schemes.empty())
|
||||
if (!cookie_monster_)
|
||||
return;
|
||||
|
||||
if (is_global_) {
|
||||
// Global changes are handled by the request context.
|
||||
CefURLRequestContextGetter* getter =
|
||||
static_cast<CefURLRequestContextGetter*>(
|
||||
_Context->browser_context()->GetRequestContext());
|
||||
|
||||
std::vector<std::string> scheme_vec;
|
||||
std::vector<CefString>::const_iterator it = schemes.begin();
|
||||
for (; it != schemes.end(); ++it)
|
||||
scheme_vec.push_back(it->ToString());
|
||||
|
||||
getter->SetCookieSupportedSchemes(scheme_vec);
|
||||
return;
|
||||
}
|
||||
|
||||
supported_schemes_ = schemes;
|
||||
|
||||
if (supported_schemes_.empty()) {
|
||||
supported_schemes_.push_back("http");
|
||||
supported_schemes_.push_back("https");
|
||||
}
|
||||
|
||||
std::set<std::string> scheme_set;
|
||||
std::vector<CefString>::const_iterator it = schemes.begin();
|
||||
for (; it != schemes.end(); ++it)
|
||||
std::vector<CefString>::const_iterator it = supported_schemes_.begin();
|
||||
for (; it != supported_schemes_.end(); ++it)
|
||||
scheme_set.insert(*it);
|
||||
|
||||
const char** arr = new const char*[scheme_set.size()];
|
||||
@ -116,6 +203,9 @@ void CefCookieManagerImpl::SetSupportedSchemes(
|
||||
bool CefCookieManagerImpl::VisitAllCookies(
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
if (!cookie_monster_)
|
||||
return false;
|
||||
|
||||
scoped_refptr<VisitCookiesCallback> callback(
|
||||
new VisitCookiesCallback(cookie_monster_, visitor));
|
||||
|
||||
@ -135,6 +225,9 @@ bool CefCookieManagerImpl::VisitUrlCookies(
|
||||
const CefString& url, bool includeHttpOnly,
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
if (!cookie_monster_)
|
||||
return false;
|
||||
|
||||
net::CookieOptions options;
|
||||
if (includeHttpOnly)
|
||||
options.set_include_httponly();
|
||||
@ -159,6 +252,9 @@ bool CefCookieManagerImpl::SetCookie(const CefString& url,
|
||||
const CefCookie& cookie) {
|
||||
CEF_REQUIRE_IOT_RETURN(false);
|
||||
|
||||
if (!cookie_monster_)
|
||||
return false;
|
||||
|
||||
GURL gurl = GURL(url.ToString());
|
||||
if (!gurl.is_valid())
|
||||
return false;
|
||||
@ -182,6 +278,9 @@ bool CefCookieManagerImpl::DeleteCookies(const CefString& url,
|
||||
const CefString& cookie_name) {
|
||||
CEF_REQUIRE_IOT_RETURN(false);
|
||||
|
||||
if (!cookie_monster_)
|
||||
return false;
|
||||
|
||||
if (url.empty()) {
|
||||
// Delete all cookies.
|
||||
cookie_monster_->DeleteAllAsync(net::CookieMonster::DeleteCallback());
|
||||
@ -246,6 +345,9 @@ bool CefCookieManagerImpl::SetStoragePath(const CefString& path) {
|
||||
// longer referenced.
|
||||
cookie_monster_ = new net::CookieMonster(persistent_store.get(), NULL);
|
||||
storage_path_ = new_path;
|
||||
|
||||
// Restore the previously supported schemes.
|
||||
SetSupportedSchemes(supported_schemes_);
|
||||
} else {
|
||||
// Execute on the IO thread.
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
@ -258,15 +360,68 @@ bool CefCookieManagerImpl::SetStoragePath(const CefString& path) {
|
||||
|
||||
void CefCookieManagerImpl::SetGlobal() {
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
cookie_monster_ = _Context->browser_context()->GetRequestContext()->
|
||||
GetURLRequestContext()->cookie_store()->GetCookieMonster();
|
||||
DCHECK(cookie_monster_);
|
||||
if (_Context->browser_context()) {
|
||||
cookie_monster_ = _Context->browser_context()->GetRequestContext()->
|
||||
GetURLRequestContext()->cookie_store()->GetCookieMonster();
|
||||
DCHECK(cookie_monster_);
|
||||
}
|
||||
} else {
|
||||
// Execute on the IO thread.
|
||||
CEF_POST_TASK(CEF_IOT, base::Bind(&CefCookieManagerImpl::SetGlobal, this));
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
bool CefCookieManagerImpl::GetCefCookie(
|
||||
const net::CookieMonster::CanonicalCookie& cc,
|
||||
CefCookie& cookie) {
|
||||
CefString(&cookie.name).FromString(cc.Name());
|
||||
CefString(&cookie.value).FromString(cc.Value());
|
||||
CefString(&cookie.domain).FromString(cc.Domain());
|
||||
CefString(&cookie.path).FromString(cc.Path());
|
||||
cookie.secure = cc.IsSecure();
|
||||
cookie.httponly = cc.IsHttpOnly();
|
||||
cef_time_from_basetime(cc.CreationDate(), cookie.creation);
|
||||
cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access);
|
||||
cookie.has_expires = cc.DoesExpire();
|
||||
if (cookie.has_expires)
|
||||
cef_time_from_basetime(cc.ExpiryDate(), cookie.expires);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
bool CefCookieManagerImpl::GetCefCookie(const GURL& url,
|
||||
const std::string& cookie_line,
|
||||
CefCookie& cookie) {
|
||||
// Parse the cookie.
|
||||
net::CookieMonster::ParsedCookie pc(cookie_line);
|
||||
if (!pc.IsValid())
|
||||
return false;
|
||||
|
||||
std::string cookie_domain;
|
||||
if (!GetCookieDomain(url, pc, &cookie_domain))
|
||||
return false;
|
||||
|
||||
std::string cookie_path = CanonPath(url, pc);
|
||||
base::Time creation_time = base::Time::Now();
|
||||
base::Time cookie_expires = CanonExpiration(pc, creation_time);
|
||||
|
||||
CefString(&cookie.name).FromString(pc.Name());
|
||||
CefString(&cookie.value).FromString(pc.Value());
|
||||
CefString(&cookie.domain).FromString(cookie_domain);
|
||||
CefString(&cookie.path).FromString(cookie_path);
|
||||
cookie.secure = pc.IsSecure();
|
||||
cookie.httponly = pc.IsHttpOnly();
|
||||
cef_time_from_basetime(creation_time, cookie.creation);
|
||||
cef_time_from_basetime(creation_time, cookie.last_access);
|
||||
cookie.has_expires = !cookie_expires.is_null();
|
||||
if (cookie.has_expires)
|
||||
cef_time_from_basetime(cookie_expires, cookie.expires);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// CefCookieManager methods ----------------------------------------------------
|
||||
|
||||
|
@ -32,12 +32,18 @@ class CefCookieManagerImpl : public CefCookieManager {
|
||||
|
||||
net::CookieMonster* cookie_monster() { return cookie_monster_; }
|
||||
|
||||
static bool GetCefCookie(const net::CookieMonster::CanonicalCookie& cc,
|
||||
CefCookie& cookie);
|
||||
static bool GetCefCookie(const GURL& url, const std::string& cookie_line,
|
||||
CefCookie& cookie);
|
||||
|
||||
private:
|
||||
void SetGlobal();
|
||||
|
||||
scoped_refptr<net::CookieMonster> cookie_monster_;
|
||||
bool is_global_;
|
||||
FilePath storage_path_;
|
||||
std::vector<CefString> supported_schemes_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefCookieManagerImpl);
|
||||
};
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_callback.h"
|
||||
#include "libcef/browser/cookie_manager_impl.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/common/response_impl.h"
|
||||
@ -138,7 +139,7 @@ CefResourceRequestJob::~CefResourceRequestJob() {
|
||||
void CefResourceRequestJob::Start() {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
cef_request_ = CefRequest::CreateRequest();
|
||||
cef_request_ = CefRequest::Create();
|
||||
|
||||
// Populate the request data.
|
||||
static_cast<CefRequestImpl*>(cef_request_.get())->Set(request_);
|
||||
@ -255,6 +256,15 @@ void CefResourceRequestJob::GetResponseInfo(net::HttpResponseInfo* info) {
|
||||
info->headers = GetResponseHeaders();
|
||||
}
|
||||
|
||||
bool CefResourceRequestJob::GetResponseCookies(
|
||||
std::vector<std::string>* cookies) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
cookies->clear();
|
||||
FetchResponseCookies(cookies);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefResourceRequestJob::IsRedirectResponse(GURL* location,
|
||||
int* http_status_code) {
|
||||
CEF_REQUIRE_IOT();
|
||||
@ -360,7 +370,20 @@ void CefResourceRequestJob::DoLoadCookies() {
|
||||
|
||||
void CefResourceRequestJob::CheckCookiePolicyAndLoad(
|
||||
const net::CookieList& cookie_list) {
|
||||
if (CanGetCookies(cookie_list))
|
||||
bool can_get_cookies = CanGetCookies(cookie_list);
|
||||
if (can_get_cookies) {
|
||||
net::CookieList::const_iterator it = cookie_list.begin();
|
||||
for (; it != cookie_list.end(); ++it) {
|
||||
CefCookie cookie;
|
||||
if (!CefCookieManagerImpl::GetCefCookie(*it, cookie) ||
|
||||
!handler_->CanGetCookie(cookie)) {
|
||||
can_get_cookies = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (can_get_cookies)
|
||||
DoLoadCookies();
|
||||
else
|
||||
DoStartTransaction();
|
||||
@ -446,8 +469,19 @@ void CefResourceRequestJob::SaveNextCookie() {
|
||||
|
||||
net::CookieOptions options;
|
||||
options.set_include_httponly();
|
||||
if (CanSetCookie(
|
||||
response_cookies_[response_cookies_save_index_], &options)) {
|
||||
bool can_set_cookie = CanSetCookie(
|
||||
response_cookies_[response_cookies_save_index_], &options);
|
||||
if (can_set_cookie) {
|
||||
CefCookie cookie;
|
||||
if (CefCookieManagerImpl::GetCefCookie(request_->url(),
|
||||
response_cookies_[response_cookies_save_index_], cookie)) {
|
||||
can_set_cookie = handler_->CanSetCookie(cookie);
|
||||
} else {
|
||||
can_set_cookie = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (can_set_cookie) {
|
||||
request_->context()->cookie_store()->SetCookieWithOptionsAsync(
|
||||
request_->url(), response_cookies_[response_cookies_save_index_],
|
||||
options, base::Bind(&CefResourceRequestJob::OnCookieSaved,
|
||||
|
@ -35,6 +35,7 @@ class CefResourceRequestJob : public net::URLRequestJob {
|
||||
virtual bool ReadRawData(net::IOBuffer* dest, int dest_size, int* bytes_read)
|
||||
OVERRIDE;
|
||||
virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE;
|
||||
virtual bool GetResponseCookies(std::vector<std::string>* cookies) OVERRIDE;
|
||||
virtual bool IsRedirectResponse(GURL* location, int* http_status_code)
|
||||
OVERRIDE;
|
||||
virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
|
||||
|
@ -45,10 +45,6 @@ using net::URLRequestStatus;
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsInternalScheme(const std::string& scheme) {
|
||||
return (scheme == kChromeDevToolsScheme);
|
||||
}
|
||||
|
||||
bool IsStandardScheme(const std::string& scheme) {
|
||||
url_parse::Component scheme_comp(0, scheme.length());
|
||||
return url_util::IsStandard(scheme.c_str(), scheme_comp);
|
||||
@ -231,21 +227,19 @@ class CefUrlRequestManager {
|
||||
if (factory) {
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::GetBrowserForRequest(request);
|
||||
if (browser.get() || IsInternalScheme(request->url().scheme())) {
|
||||
// Populate the request data.
|
||||
CefRefPtr<CefRequestImpl> requestPtr(new CefRequestImpl());
|
||||
requestPtr->Set(request);
|
||||
CefRefPtr<CefFrame> frame;
|
||||
if (browser.get())
|
||||
frame = browser->GetFrameForRequest(request);
|
||||
|
||||
CefRefPtr<CefFrame> frame;
|
||||
if (browser.get())
|
||||
frame = browser->GetFrameForRequest(request);
|
||||
// Populate the request data.
|
||||
CefRefPtr<CefRequestImpl> requestPtr(new CefRequestImpl());
|
||||
requestPtr->Set(request);
|
||||
|
||||
// Call the handler factory to create the handler for the request.
|
||||
CefRefPtr<CefResourceHandler> handler =
|
||||
factory->Create(browser.get(), frame, scheme, requestPtr.get());
|
||||
if (handler.get())
|
||||
job = new CefResourceRequestJob(request, handler);
|
||||
}
|
||||
// Call the handler factory to create the handler for the request.
|
||||
CefRefPtr<CefResourceHandler> handler =
|
||||
factory->Create(browser.get(), frame, scheme, requestPtr.get());
|
||||
if (handler.get())
|
||||
job = new CefResourceRequestJob(request, handler);
|
||||
}
|
||||
|
||||
if (!job && IsBuiltinScheme(scheme)) {
|
||||
|
@ -169,14 +169,18 @@ net::URLRequestContext* CefURLRequestContextGetter::GetURLRequestContext() {
|
||||
|
||||
CefRefPtr<CefApp> app = _Context->application();
|
||||
if (app.get()) {
|
||||
CefRefPtr<CefProxyHandler> handler = app->GetProxyHandler();
|
||||
if (handler) {
|
||||
// The client will provide proxy resolution.
|
||||
CreateProxyConfigService();
|
||||
storage_->set_proxy_service(
|
||||
new net::ProxyService(proxy_config_service_.release(),
|
||||
new CefProxyResolver(handler), NULL));
|
||||
proxy_service_set = true;
|
||||
CefRefPtr<CefBrowserProcessHandler> handler =
|
||||
app->GetBrowserProcessHandler();
|
||||
if (handler.get()) {
|
||||
CefRefPtr<CefProxyHandler> proxy_handler = handler->GetProxyHandler();
|
||||
if (proxy_handler.get()) {
|
||||
// The client will provide proxy resolution.
|
||||
CreateProxyConfigService();
|
||||
storage_->set_proxy_service(
|
||||
new net::ProxyService(proxy_config_service_.release(),
|
||||
new CefProxyResolver(proxy_handler), NULL));
|
||||
proxy_service_set = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,6 +319,37 @@ void CefURLRequestContextGetter::SetCookieStoragePath(const FilePath& path) {
|
||||
storage_->set_cookie_store(
|
||||
new net::CookieMonster(persistent_store.get(), NULL));
|
||||
cookie_store_path_ = path;
|
||||
|
||||
// Restore the previously supported schemes.
|
||||
SetCookieSupportedSchemes(cookie_supported_schemes_);
|
||||
}
|
||||
|
||||
void CefURLRequestContextGetter::SetCookieSupportedSchemes(
|
||||
const std::vector<std::string>& schemes) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
cookie_supported_schemes_ = schemes;
|
||||
|
||||
if (cookie_supported_schemes_.empty()) {
|
||||
cookie_supported_schemes_.push_back("http");
|
||||
cookie_supported_schemes_.push_back("https");
|
||||
}
|
||||
|
||||
std::set<std::string> scheme_set;
|
||||
std::vector<std::string>::const_iterator it =
|
||||
cookie_supported_schemes_.begin();
|
||||
for (; it != cookie_supported_schemes_.end(); ++it)
|
||||
scheme_set.insert(*it);
|
||||
|
||||
const char** arr = new const char*[scheme_set.size()];
|
||||
std::set<std::string>::const_iterator it2 = scheme_set.begin();
|
||||
for (int i = 0; it2 != scheme_set.end(); ++it2, ++i)
|
||||
arr[i] = it2->c_str();
|
||||
|
||||
url_request_context_->cookie_store()->GetCookieMonster()->
|
||||
SetCookieableSchemes(arr, scheme_set.size());
|
||||
|
||||
delete [] arr;
|
||||
}
|
||||
|
||||
void CefURLRequestContextGetter::CreateProxyConfigService() {
|
||||
|
@ -6,6 +6,9 @@
|
||||
#define CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/file_path.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
@ -39,6 +42,7 @@ class CefURLRequestContextGetter : public net::URLRequestContextGetter {
|
||||
net::HostResolver* host_resolver();
|
||||
|
||||
void SetCookieStoragePath(const FilePath& path);
|
||||
void SetCookieSupportedSchemes(const std::vector<std::string>& schemes);
|
||||
|
||||
private:
|
||||
void CreateProxyConfigService();
|
||||
@ -54,6 +58,7 @@ class CefURLRequestContextGetter : public net::URLRequestContextGetter {
|
||||
scoped_ptr<net::URLSecurityManager> url_security_manager_;
|
||||
|
||||
FilePath cookie_store_path_;
|
||||
std::vector<std::string> cookie_supported_schemes_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetter);
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ net::URLRequestJob* CefRequestInterceptor::MaybeIntercept(
|
||||
CefRefPtr<CefFrame> frame = browser->GetFrameForRequest(request);
|
||||
|
||||
// Populate the request data.
|
||||
CefRefPtr<CefRequest> req(CefRequest::CreateRequest());
|
||||
CefRefPtr<CefRequest> req(CefRequest::Create());
|
||||
static_cast<CefRequestImpl*>(req.get())->Set(request);
|
||||
|
||||
// Give the client an opportunity to replace the request.
|
||||
|
@ -109,8 +109,7 @@ class CefUIThread : public base::Thread {
|
||||
// Use our own browser process runner.
|
||||
browser_runner_.reset(content::BrowserMainRunner::Create());
|
||||
|
||||
// Initialize browser process state. Results in a call to
|
||||
// CefBrowserMain::GetMainMessageLoop().
|
||||
// Initialize browser process state. Uses the current thread's mesage loop.
|
||||
int exit_code = browser_runner_->Initialize(main_function_params_);
|
||||
CHECK_EQ(exit_code, -1);
|
||||
}
|
||||
@ -257,7 +256,8 @@ int CefMainDelegate::RunProcess(
|
||||
browser_runner_.reset(content::BrowserMainRunner::Create());
|
||||
|
||||
// Initialize browser process state. Results in a call to
|
||||
// CefBrowserMain::GetMainMessageLoop().
|
||||
// CefBrowserMain::PreMainMessageLoopStart() which creates the UI message
|
||||
// loop.
|
||||
int exit_code = browser_runner_->Initialize(main_function_params);
|
||||
if (exit_code >= 0)
|
||||
return exit_code;
|
||||
|
@ -10,15 +10,46 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeaderVisitor.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h"
|
||||
|
||||
CefRefPtr<CefRequest> CefRequest::CreateRequest() {
|
||||
|
||||
#define CHECK_READONLY_RETURN(val) \
|
||||
if (read_only_) { \
|
||||
NOTREACHED() << "object is read only"; \
|
||||
return val; \
|
||||
}
|
||||
|
||||
#define CHECK_READONLY_RETURN_VOID() \
|
||||
if (read_only_) { \
|
||||
NOTREACHED() << "object is read only"; \
|
||||
return; \
|
||||
}
|
||||
|
||||
|
||||
// CefRequest -----------------------------------------------------------------
|
||||
|
||||
// static
|
||||
CefRefPtr<CefRequest> CefRequest::Create() {
|
||||
CefRefPtr<CefRequest> request(new CefRequestImpl());
|
||||
return request;
|
||||
}
|
||||
|
||||
|
||||
// CefRequestImpl -------------------------------------------------------------
|
||||
|
||||
CefRequestImpl::CefRequestImpl()
|
||||
: method_("GET"),
|
||||
flags_(WUR_FLAG_NONE) {
|
||||
flags_(UR_FLAG_NONE),
|
||||
read_only_(false) {
|
||||
}
|
||||
|
||||
bool CefRequestImpl::IsReadOnly() {
|
||||
AutoLock lock_scope(this);
|
||||
return read_only_;
|
||||
}
|
||||
|
||||
CefString CefRequestImpl::GetURL() {
|
||||
@ -28,6 +59,7 @@ CefString CefRequestImpl::GetURL() {
|
||||
|
||||
void CefRequestImpl::SetURL(const CefString& url) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
url_ = url;
|
||||
}
|
||||
|
||||
@ -38,6 +70,7 @@ CefString CefRequestImpl::GetMethod() {
|
||||
|
||||
void CefRequestImpl::SetMethod(const CefString& method) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
method_ = method;
|
||||
}
|
||||
|
||||
@ -48,6 +81,7 @@ CefRefPtr<CefPostData> CefRequestImpl::GetPostData() {
|
||||
|
||||
void CefRequestImpl::SetPostData(CefRefPtr<CefPostData> postData) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
postdata_ = postData;
|
||||
}
|
||||
|
||||
@ -58,6 +92,7 @@ void CefRequestImpl::GetHeaderMap(HeaderMap& headerMap) {
|
||||
|
||||
void CefRequestImpl::SetHeaderMap(const HeaderMap& headerMap) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
headermap_ = headerMap;
|
||||
}
|
||||
|
||||
@ -66,21 +101,20 @@ void CefRequestImpl::Set(const CefString& url,
|
||||
CefRefPtr<CefPostData> postData,
|
||||
const HeaderMap& headerMap) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
url_ = url;
|
||||
method_ = method;
|
||||
postdata_ = postData;
|
||||
headermap_ = headerMap;
|
||||
}
|
||||
|
||||
#define SETBOOLFLAG(obj, flags, method, FLAG) \
|
||||
obj.method((flags & (FLAG)) == (FLAG))
|
||||
|
||||
CefRequest::RequestFlags CefRequestImpl::GetFlags() {
|
||||
int CefRequestImpl::GetFlags() {
|
||||
AutoLock lock_scope(this);
|
||||
return flags_;
|
||||
}
|
||||
void CefRequestImpl::SetFlags(RequestFlags flags) {
|
||||
void CefRequestImpl::SetFlags(int flags) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
flags_ = flags;
|
||||
}
|
||||
|
||||
@ -90,11 +124,13 @@ CefString CefRequestImpl::GetFirstPartyForCookies() {
|
||||
}
|
||||
void CefRequestImpl::SetFirstPartyForCookies(const CefString& url) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
first_party_for_cookies_ = url;
|
||||
}
|
||||
|
||||
void CefRequestImpl::Set(net::URLRequest* request) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
url_ = request->url().spec();
|
||||
method_ = request->method();
|
||||
@ -121,7 +157,7 @@ void CefRequestImpl::Set(net::URLRequest* request) {
|
||||
// Transfer post data, if any
|
||||
net::UploadData* data = request->get_upload();
|
||||
if (data) {
|
||||
postdata_ = CefPostData::CreatePostData();
|
||||
postdata_ = CefPostData::Create();
|
||||
static_cast<CefPostDataImpl*>(postdata_.get())->Set(*data);
|
||||
} else if (postdata_.get()) {
|
||||
postdata_ = NULL;
|
||||
@ -160,6 +196,98 @@ void CefRequestImpl::Get(net::URLRequest* request) {
|
||||
}
|
||||
}
|
||||
|
||||
void CefRequestImpl::Set(const WebKit::WebURLRequest& request) {
|
||||
DCHECK(!request.isNull());
|
||||
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
url_ = request.url().spec().utf16();
|
||||
method_ = request.httpMethod();
|
||||
|
||||
const WebKit::WebHTTPBody& body = request.httpBody();
|
||||
if (!body.isNull()) {
|
||||
postdata_ = new CefPostDataImpl();
|
||||
static_cast<CefPostDataImpl*>(postdata_.get())->Set(body);
|
||||
} else if (postdata_.get()) {
|
||||
postdata_ = NULL;
|
||||
}
|
||||
|
||||
headermap_.clear();
|
||||
GetHeaderMap(request, headermap_);
|
||||
|
||||
flags_ = UR_FLAG_NONE;
|
||||
if (request.cachePolicy() == WebKit::WebURLRequest::ReloadIgnoringCacheData)
|
||||
flags_ |= UR_FLAG_SKIP_CACHE;
|
||||
if (request.allowStoredCredentials())
|
||||
flags_ |= UR_FLAG_ALLOW_CACHED_CREDENTIALS;
|
||||
if (request.allowCookies())
|
||||
flags_ |= UR_FLAG_ALLOW_COOKIES;
|
||||
if (request.reportUploadProgress())
|
||||
flags_ |= UR_FLAG_REPORT_UPLOAD_PROGRESS;
|
||||
if (request.reportLoadTiming())
|
||||
flags_ |= UR_FLAG_REPORT_LOAD_TIMING;
|
||||
if (request.reportRawHeaders())
|
||||
flags_ |= UR_FLAG_REPORT_RAW_HEADERS;
|
||||
|
||||
first_party_for_cookies_ = request.firstPartyForCookies().spec().utf16();
|
||||
}
|
||||
|
||||
void CefRequestImpl::Get(WebKit::WebURLRequest& request) {
|
||||
request.initialize();
|
||||
AutoLock lock_scope(this);
|
||||
|
||||
GURL gurl = GURL(url_.ToString());
|
||||
request.setURL(WebKit::WebURL(gurl));
|
||||
|
||||
std::string method(method_);
|
||||
request.setHTTPMethod(WebKit::WebString::fromUTF8(method.c_str()));
|
||||
request.setTargetType(WebKit::WebURLRequest::TargetIsMainFrame);
|
||||
|
||||
WebKit::WebHTTPBody body;
|
||||
if (postdata_.get()) {
|
||||
body.initialize();
|
||||
static_cast<CefPostDataImpl*>(postdata_.get())->Get(body);
|
||||
request.setHTTPBody(body);
|
||||
}
|
||||
|
||||
SetHeaderMap(headermap_, request);
|
||||
|
||||
request.setCachePolicy((flags_ & UR_FLAG_SKIP_CACHE) ?
|
||||
WebKit::WebURLRequest::ReloadIgnoringCacheData :
|
||||
WebKit::WebURLRequest::UseProtocolCachePolicy);
|
||||
|
||||
#define SETBOOLFLAG(obj, flags, method, FLAG) \
|
||||
obj.method((flags & (FLAG)) == (FLAG))
|
||||
|
||||
SETBOOLFLAG(request, flags_, setAllowStoredCredentials,
|
||||
UR_FLAG_ALLOW_CACHED_CREDENTIALS);
|
||||
SETBOOLFLAG(request, flags_, setAllowCookies,
|
||||
UR_FLAG_ALLOW_COOKIES);
|
||||
SETBOOLFLAG(request, flags_, setReportUploadProgress,
|
||||
UR_FLAG_REPORT_UPLOAD_PROGRESS);
|
||||
SETBOOLFLAG(request, flags_, setReportLoadTiming,
|
||||
UR_FLAG_REPORT_LOAD_TIMING);
|
||||
SETBOOLFLAG(request, flags_, setReportRawHeaders,
|
||||
UR_FLAG_REPORT_RAW_HEADERS);
|
||||
|
||||
if (!first_party_for_cookies_.empty()) {
|
||||
GURL gurl = GURL(first_party_for_cookies_.ToString());
|
||||
request.setFirstPartyForCookies(WebKit::WebURL(gurl));
|
||||
}
|
||||
}
|
||||
|
||||
void CefRequestImpl::SetReadOnly(bool read_only) {
|
||||
AutoLock lock_scope(this);
|
||||
if (read_only_ == read_only)
|
||||
return;
|
||||
|
||||
read_only_ = read_only;
|
||||
|
||||
if (postdata_.get())
|
||||
static_cast<CefPostDataImpl*>(postdata_.get())->SetReadOnly(read_only);
|
||||
}
|
||||
|
||||
// static
|
||||
void CefRequestImpl::GetHeaderMap(const net::HttpRequestHeaders& headers,
|
||||
HeaderMap& map) {
|
||||
@ -172,12 +300,53 @@ void CefRequestImpl::GetHeaderMap(const net::HttpRequestHeaders& headers,
|
||||
} while (it.GetNext());
|
||||
}
|
||||
|
||||
CefRefPtr<CefPostData> CefPostData::CreatePostData() {
|
||||
|
||||
// static
|
||||
void CefRequestImpl::GetHeaderMap(const WebKit::WebURLRequest& request,
|
||||
HeaderMap& map) {
|
||||
class HeaderVisitor : public WebKit::WebHTTPHeaderVisitor {
|
||||
public:
|
||||
explicit HeaderVisitor(HeaderMap* map) : map_(map) {}
|
||||
|
||||
virtual void visitHeader(const WebKit::WebString& name,
|
||||
const WebKit::WebString& value) {
|
||||
map_->insert(std::make_pair(string16(name), string16(value)));
|
||||
}
|
||||
|
||||
private:
|
||||
HeaderMap* map_;
|
||||
};
|
||||
|
||||
HeaderVisitor visitor(&map);
|
||||
request.visitHTTPHeaderFields(&visitor);
|
||||
}
|
||||
|
||||
// static
|
||||
void CefRequestImpl::SetHeaderMap(const HeaderMap& map,
|
||||
WebKit::WebURLRequest& request) {
|
||||
HeaderMap::const_iterator it = map.begin();
|
||||
for (; it != map.end(); ++it)
|
||||
request.setHTTPHeaderField(string16(it->first), string16(it->second));
|
||||
}
|
||||
|
||||
// CefPostData ----------------------------------------------------------------
|
||||
|
||||
// static
|
||||
CefRefPtr<CefPostData> CefPostData::Create() {
|
||||
CefRefPtr<CefPostData> postdata(new CefPostDataImpl());
|
||||
return postdata;
|
||||
}
|
||||
|
||||
CefPostDataImpl::CefPostDataImpl() {
|
||||
|
||||
// CefPostDataImpl ------------------------------------------------------------
|
||||
|
||||
CefPostDataImpl::CefPostDataImpl()
|
||||
: read_only_(false) {
|
||||
}
|
||||
|
||||
bool CefPostDataImpl::IsReadOnly() {
|
||||
AutoLock lock_scope(this);
|
||||
return read_only_;
|
||||
}
|
||||
|
||||
size_t CefPostDataImpl::GetElementCount() {
|
||||
@ -192,6 +361,7 @@ void CefPostDataImpl::GetElements(ElementVector& elements) {
|
||||
|
||||
bool CefPostDataImpl::RemoveElement(CefRefPtr<CefPostDataElement> element) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN(false);
|
||||
|
||||
ElementVector::iterator it = elements_.begin();
|
||||
for (; it != elements_.end(); ++it) {
|
||||
@ -208,6 +378,7 @@ bool CefPostDataImpl::AddElement(CefRefPtr<CefPostDataElement> element) {
|
||||
bool found = false;
|
||||
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN(false);
|
||||
|
||||
// check that the element isn't already in the list before adding
|
||||
ElementVector::const_iterator it = elements_.begin();
|
||||
@ -226,18 +397,20 @@ bool CefPostDataImpl::AddElement(CefRefPtr<CefPostDataElement> element) {
|
||||
|
||||
void CefPostDataImpl::RemoveElements() {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
elements_.clear();
|
||||
}
|
||||
|
||||
void CefPostDataImpl::Set(net::UploadData& data) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
CefRefPtr<CefPostDataElement> postelem;
|
||||
|
||||
std::vector<net::UploadData::Element>* elements = data.elements();
|
||||
std::vector<net::UploadData::Element>::const_iterator it = elements->begin();
|
||||
for (; it != elements->end(); ++it) {
|
||||
postelem = CefPostDataElement::CreatePostDataElement();
|
||||
postelem = CefPostDataElement::Create();
|
||||
static_cast<CefPostDataElementImpl*>(postelem.get())->Set(*it);
|
||||
AddElement(postelem);
|
||||
}
|
||||
@ -248,7 +421,7 @@ void CefPostDataImpl::Get(net::UploadData& data) {
|
||||
|
||||
net::UploadData::Element element;
|
||||
std::vector<net::UploadData::Element> data_elements;
|
||||
ElementVector::iterator it = elements_.begin();
|
||||
ElementVector::const_iterator it = elements_.begin();
|
||||
for (; it != elements_.end(); ++it) {
|
||||
static_cast<CefPostDataElementImpl*>(it->get())->Get(element);
|
||||
data_elements.push_back(element);
|
||||
@ -256,32 +429,89 @@ void CefPostDataImpl::Get(net::UploadData& data) {
|
||||
data.SetElements(data_elements);
|
||||
}
|
||||
|
||||
CefRefPtr<CefPostDataElement> CefPostDataElement::CreatePostDataElement() {
|
||||
void CefPostDataImpl::Set(const WebKit::WebHTTPBody& data) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
CefRefPtr<CefPostDataElement> postelem;
|
||||
WebKit::WebHTTPBody::Element element;
|
||||
size_t size = data.elementCount();
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (data.elementAt(i, element)) {
|
||||
postelem = CefPostDataElement::Create();
|
||||
static_cast<CefPostDataElementImpl*>(postelem.get())->Set(element);
|
||||
AddElement(postelem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefPostDataImpl::Get(WebKit::WebHTTPBody& data) {
|
||||
AutoLock lock_scope(this);
|
||||
|
||||
WebKit::WebHTTPBody::Element element;
|
||||
ElementVector::iterator it = elements_.begin();
|
||||
for (; it != elements_.end(); ++it) {
|
||||
static_cast<CefPostDataElementImpl*>(it->get())->Get(element);
|
||||
if (element.type == WebKit::WebHTTPBody::Element::TypeData) {
|
||||
data.appendData(element.data);
|
||||
} else if (element.type == WebKit::WebHTTPBody::Element::TypeFile) {
|
||||
data.appendFile(element.filePath);
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefPostDataImpl::SetReadOnly(bool read_only) {
|
||||
AutoLock lock_scope(this);
|
||||
if (read_only_ == read_only)
|
||||
return;
|
||||
|
||||
read_only_ = read_only;
|
||||
|
||||
ElementVector::const_iterator it = elements_.begin();
|
||||
for (; it != elements_.end(); ++it) {
|
||||
static_cast<CefPostDataElementImpl*>(it->get())->SetReadOnly(read_only);
|
||||
}
|
||||
}
|
||||
|
||||
// CefPostDataElement ---------------------------------------------------------
|
||||
|
||||
// static
|
||||
CefRefPtr<CefPostDataElement> CefPostDataElement::Create() {
|
||||
CefRefPtr<CefPostDataElement> element(new CefPostDataElementImpl());
|
||||
return element;
|
||||
}
|
||||
|
||||
CefPostDataElementImpl::CefPostDataElementImpl() {
|
||||
type_ = PDE_TYPE_EMPTY;
|
||||
|
||||
// CefPostDataElementImpl -----------------------------------------------------
|
||||
|
||||
CefPostDataElementImpl::CefPostDataElementImpl()
|
||||
: type_(PDE_TYPE_EMPTY),
|
||||
read_only_(false) {
|
||||
memset(&data_, 0, sizeof(data_));
|
||||
}
|
||||
|
||||
CefPostDataElementImpl::~CefPostDataElementImpl() {
|
||||
SetToEmpty();
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
bool CefPostDataElementImpl::IsReadOnly() {
|
||||
AutoLock lock_scope(this);
|
||||
return read_only_;
|
||||
}
|
||||
|
||||
void CefPostDataElementImpl::SetToEmpty() {
|
||||
AutoLock lock_scope(this);
|
||||
if (type_ == PDE_TYPE_BYTES)
|
||||
free(data_.bytes.bytes);
|
||||
else if (type_ == PDE_TYPE_FILE)
|
||||
cef_string_clear(&data_.filename);
|
||||
type_ = PDE_TYPE_EMPTY;
|
||||
memset(&data_, 0, sizeof(data_));
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
void CefPostDataElementImpl::SetToFile(const CefString& fileName) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
// Clear any data currently in the element
|
||||
SetToEmpty();
|
||||
|
||||
@ -292,6 +522,8 @@ void CefPostDataElementImpl::SetToFile(const CefString& fileName) {
|
||||
|
||||
void CefPostDataElementImpl::SetToBytes(size_t size, const void* bytes) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
// Clear any data currently in the element
|
||||
SetToEmpty();
|
||||
|
||||
@ -344,6 +576,7 @@ size_t CefPostDataElementImpl::GetBytes(size_t size, void* bytes) {
|
||||
|
||||
void CefPostDataElementImpl::Set(const net::UploadData::Element& element) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
if (element.type() == net::UploadData::TYPE_BYTES) {
|
||||
SetToBytes(element.bytes().size(),
|
||||
@ -369,3 +602,52 @@ void CefPostDataElementImpl::Get(net::UploadData::Element& element) {
|
||||
NOTREACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void CefPostDataElementImpl::Set(const WebKit::WebHTTPBody::Element& element) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
if (element.type == WebKit::WebHTTPBody::Element::TypeData) {
|
||||
SetToBytes(element.data.size(),
|
||||
static_cast<const void*>(element.data.data()));
|
||||
} else if (element.type == WebKit::WebHTTPBody::Element::TypeFile) {
|
||||
SetToFile(string16(element.filePath));
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void CefPostDataElementImpl::Get(WebKit::WebHTTPBody::Element& element) {
|
||||
AutoLock lock_scope(this);
|
||||
|
||||
if (type_ == PDE_TYPE_BYTES) {
|
||||
element.type = WebKit::WebHTTPBody::Element::TypeData;
|
||||
element.data.assign(
|
||||
static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
|
||||
} else if (type_ == PDE_TYPE_FILE) {
|
||||
element.type = WebKit::WebHTTPBody::Element::TypeFile;
|
||||
element.filePath.assign(string16(CefString(&data_.filename)));
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void CefPostDataElementImpl::SetReadOnly(bool read_only) {
|
||||
AutoLock lock_scope(this);
|
||||
if (read_only_ == read_only)
|
||||
return;
|
||||
|
||||
read_only_ = read_only;
|
||||
}
|
||||
|
||||
void CefPostDataElementImpl::Cleanup() {
|
||||
if (type_ == PDE_TYPE_EMPTY)
|
||||
return;
|
||||
|
||||
if (type_ == PDE_TYPE_BYTES)
|
||||
free(data_.bytes.bytes);
|
||||
else if (type_ == PDE_TYPE_FILE)
|
||||
cef_string_clear(&data_.filename);
|
||||
type_ = PDE_TYPE_EMPTY;
|
||||
memset(&data_, 0, sizeof(data_));
|
||||
}
|
||||
|
@ -9,17 +9,23 @@
|
||||
#include "include/cef_request.h"
|
||||
#include "net/base/upload_data.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h"
|
||||
|
||||
namespace net {
|
||||
class URLRequest;
|
||||
};
|
||||
|
||||
namespace WebKit {
|
||||
class WebURLRequest;
|
||||
}
|
||||
|
||||
// Implementation of CefRequest
|
||||
class CefRequestImpl : public CefRequest {
|
||||
public:
|
||||
CefRequestImpl();
|
||||
~CefRequestImpl() {}
|
||||
|
||||
virtual bool IsReadOnly() OVERRIDE;
|
||||
virtual CefString GetURL() OVERRIDE;
|
||||
virtual void SetURL(const CefString& url) OVERRIDE;
|
||||
virtual CefString GetMethod() OVERRIDE;
|
||||
@ -32,8 +38,8 @@ class CefRequestImpl : public CefRequest {
|
||||
const CefString& method,
|
||||
CefRefPtr<CefPostData> postData,
|
||||
const HeaderMap& headerMap) OVERRIDE;
|
||||
virtual RequestFlags GetFlags() OVERRIDE;
|
||||
virtual void SetFlags(RequestFlags flags) OVERRIDE;
|
||||
virtual int GetFlags() OVERRIDE;
|
||||
virtual void SetFlags(int flags) OVERRIDE;
|
||||
virtual CefString GetFirstPartyForCookies() OVERRIDE;
|
||||
virtual void SetFirstPartyForCookies(const CefString& url) OVERRIDE;
|
||||
|
||||
@ -43,8 +49,20 @@ class CefRequestImpl : public CefRequest {
|
||||
// Populate the URLRequest object from this object.
|
||||
void Get(net::URLRequest* request);
|
||||
|
||||
// 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);
|
||||
|
||||
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:
|
||||
CefString url_;
|
||||
@ -52,10 +70,13 @@ class CefRequestImpl : public CefRequest {
|
||||
CefRefPtr<CefPostData> postdata_;
|
||||
HeaderMap headermap_;
|
||||
|
||||
// The below methods are used by WebURLRequest.
|
||||
RequestFlags flags_;
|
||||
// The below members are used by CefURLRequest.
|
||||
int flags_;
|
||||
CefString first_party_for_cookies_;
|
||||
|
||||
// True if this object is read-only.
|
||||
bool read_only_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefRequestImpl);
|
||||
IMPLEMENT_LOCKING(CefRequestImpl);
|
||||
};
|
||||
@ -66,6 +87,7 @@ class CefPostDataImpl : public CefPostData {
|
||||
CefPostDataImpl();
|
||||
~CefPostDataImpl() {}
|
||||
|
||||
virtual bool IsReadOnly() OVERRIDE;
|
||||
virtual size_t GetElementCount() OVERRIDE;
|
||||
virtual void GetElements(ElementVector& elements) OVERRIDE;
|
||||
virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element) OVERRIDE;
|
||||
@ -74,10 +96,17 @@ class CefPostDataImpl : public CefPostData {
|
||||
|
||||
void Set(net::UploadData& data);
|
||||
void Get(net::UploadData& data);
|
||||
void Set(const WebKit::WebHTTPBody& data);
|
||||
void Get(WebKit::WebHTTPBody& data);
|
||||
|
||||
void SetReadOnly(bool read_only);
|
||||
|
||||
protected:
|
||||
ElementVector elements_;
|
||||
|
||||
// True if this object is read-only.
|
||||
bool read_only_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefPostDataImpl);
|
||||
IMPLEMENT_LOCKING(CefPostDataImpl);
|
||||
};
|
||||
@ -88,6 +117,7 @@ class CefPostDataElementImpl : public CefPostDataElement {
|
||||
CefPostDataElementImpl();
|
||||
~CefPostDataElementImpl();
|
||||
|
||||
virtual bool IsReadOnly() OVERRIDE;
|
||||
virtual void SetToEmpty() OVERRIDE;
|
||||
virtual void SetToFile(const CefString& fileName) OVERRIDE;
|
||||
virtual void SetToBytes(size_t size, const void* bytes) OVERRIDE;
|
||||
@ -100,8 +130,14 @@ class CefPostDataElementImpl : public CefPostDataElement {
|
||||
|
||||
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);
|
||||
|
||||
void SetReadOnly(bool read_only);
|
||||
|
||||
protected:
|
||||
void Cleanup();
|
||||
|
||||
Type type_;
|
||||
union {
|
||||
struct {
|
||||
@ -111,6 +147,9 @@ class CefPostDataElementImpl : public CefPostDataElement {
|
||||
cef_string_t filename;
|
||||
} data_;
|
||||
|
||||
// True if this object is read-only.
|
||||
bool read_only_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefPostDataElementImpl);
|
||||
IMPLEMENT_LOCKING(CefPostDataElementImpl);
|
||||
};
|
||||
|
@ -4,12 +4,43 @@
|
||||
|
||||
#include "libcef/common/response_impl.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/stringprintf.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeaderVisitor.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLResponse.h"
|
||||
|
||||
|
||||
#define CHECK_READONLY_RETURN_VOID() \
|
||||
if (read_only_) { \
|
||||
NOTREACHED() << "object is read only"; \
|
||||
return; \
|
||||
}
|
||||
|
||||
|
||||
// CefResponse ----------------------------------------------------------------
|
||||
|
||||
// static
|
||||
CefRefPtr<CefResponse> CefResponse::Create() {
|
||||
CefRefPtr<CefResponse> response(new CefResponseImpl());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
// CefResponseImpl ------------------------------------------------------------
|
||||
|
||||
CefResponseImpl::CefResponseImpl()
|
||||
: status_code_(0) {
|
||||
: status_code_(0),
|
||||
read_only_(false) {
|
||||
}
|
||||
|
||||
bool CefResponseImpl::IsReadOnly() {
|
||||
AutoLock lock_scope(this);
|
||||
return read_only_;
|
||||
}
|
||||
|
||||
int CefResponseImpl::GetStatus() {
|
||||
@ -19,6 +50,7 @@ int CefResponseImpl::GetStatus() {
|
||||
|
||||
void CefResponseImpl::SetStatus(int status) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
status_code_ = status;
|
||||
}
|
||||
|
||||
@ -29,6 +61,7 @@ CefString CefResponseImpl::GetStatusText() {
|
||||
|
||||
void CefResponseImpl::SetStatusText(const CefString& statusText) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
status_text_ = statusText;
|
||||
}
|
||||
|
||||
@ -39,6 +72,7 @@ CefString CefResponseImpl::GetMimeType() {
|
||||
|
||||
void CefResponseImpl::SetMimeType(const CefString& mimeType) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
mime_type_ = mimeType;
|
||||
}
|
||||
|
||||
@ -61,6 +95,7 @@ void CefResponseImpl::GetHeaderMap(HeaderMap& map) {
|
||||
|
||||
void CefResponseImpl::SetHeaderMap(const HeaderMap& headerMap) {
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
header_map_ = headerMap;
|
||||
}
|
||||
|
||||
@ -69,11 +104,12 @@ net::HttpResponseHeaders* CefResponseImpl::GetResponseHeaders() {
|
||||
|
||||
std::string response;
|
||||
std::string status_text;
|
||||
bool has_content_type_header = false;
|
||||
|
||||
if (status_text_.empty())
|
||||
status_text = (status_code_ == 200)?"OK":"ERROR";
|
||||
else
|
||||
if (!status_text_.empty())
|
||||
status_text = status_text_;
|
||||
else
|
||||
status_text = (status_code_ == 200)?"OK":"ERROR";
|
||||
|
||||
base::SStringPrintf(&response, "HTTP/1.1 %d %s", status_code_,
|
||||
status_text.c_str());
|
||||
@ -90,9 +126,79 @@ net::HttpResponseHeaders* CefResponseImpl::GetResponseHeaders() {
|
||||
std::string value_str(value);
|
||||
base::StringAppendF(&response, "%c%s: %s", '\0', key_str.c_str(),
|
||||
value_str.c_str());
|
||||
|
||||
if (!has_content_type_header &&
|
||||
key_str == net::HttpRequestHeaders::kContentType) {
|
||||
has_content_type_header = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_content_type_header) {
|
||||
std::string mime_type;
|
||||
if (!mime_type_.empty())
|
||||
mime_type = mime_type_;
|
||||
else
|
||||
mime_type = "text/html";
|
||||
|
||||
base::StringAppendF(&response, "%c%s: %s", '\0',
|
||||
net::HttpRequestHeaders::kContentType, mime_type.c_str());
|
||||
}
|
||||
|
||||
return new net::HttpResponseHeaders(response);
|
||||
}
|
||||
|
||||
void CefResponseImpl::SetResponseHeaders(
|
||||
const net::HttpResponseHeaders& headers) {
|
||||
AutoLock lock_scope(this);
|
||||
|
||||
header_map_.empty();
|
||||
|
||||
void* iter = NULL;
|
||||
std::string name, value;
|
||||
while (headers.EnumerateHeaderLines(&iter, &name, &value))
|
||||
header_map_.insert(std::make_pair(name, value));
|
||||
|
||||
status_code_ = headers.response_code();
|
||||
status_text_ = headers.GetStatusText();
|
||||
|
||||
std::string mime_type;
|
||||
if (headers.GetMimeType(&mime_type))
|
||||
mime_type_ = mime_type;
|
||||
}
|
||||
|
||||
void CefResponseImpl::Set(const WebKit::WebURLResponse& response) {
|
||||
DCHECK(!response.isNull());
|
||||
|
||||
AutoLock lock_scope(this);
|
||||
CHECK_READONLY_RETURN_VOID();
|
||||
|
||||
WebKit::WebString str;
|
||||
status_code_ = response.httpStatusCode();
|
||||
str = response.httpStatusText();
|
||||
status_text_ = CefString(str);
|
||||
str = response.mimeType();
|
||||
mime_type_ = CefString(str);
|
||||
|
||||
class HeaderVisitor : public WebKit::WebHTTPHeaderVisitor {
|
||||
public:
|
||||
explicit HeaderVisitor(HeaderMap* map) : map_(map) {}
|
||||
|
||||
virtual void visitHeader(const WebKit::WebString& name,
|
||||
const WebKit::WebString& value) {
|
||||
map_->insert(std::make_pair(string16(name), string16(value)));
|
||||
}
|
||||
|
||||
private:
|
||||
HeaderMap* map_;
|
||||
};
|
||||
|
||||
HeaderVisitor visitor(&header_map_);
|
||||
response.visitHTTPHeaderFields(&visitor);
|
||||
}
|
||||
|
||||
void CefResponseImpl::SetReadOnly(bool read_only) {
|
||||
AutoLock lock_scope(this);
|
||||
read_only_ = read_only;
|
||||
}
|
||||
|
@ -12,30 +12,41 @@ namespace net {
|
||||
class HttpResponseHeaders;
|
||||
}
|
||||
|
||||
namespace WebKit {
|
||||
class WebURLResponse;
|
||||
}
|
||||
|
||||
// Implementation of CefResponse.
|
||||
class CefResponseImpl : public CefResponse {
|
||||
public:
|
||||
CefResponseImpl();
|
||||
~CefResponseImpl() {}
|
||||
|
||||
// CefResponse API
|
||||
virtual int GetStatus();
|
||||
virtual void SetStatus(int status);
|
||||
virtual CefString GetStatusText();
|
||||
virtual void SetStatusText(const CefString& statusText);
|
||||
virtual CefString GetMimeType();
|
||||
virtual void SetMimeType(const CefString& mimeType);
|
||||
virtual CefString GetHeader(const CefString& name);
|
||||
virtual void GetHeaderMap(HeaderMap& headerMap);
|
||||
virtual void SetHeaderMap(const HeaderMap& headerMap);
|
||||
// CefResponse methods.
|
||||
virtual bool IsReadOnly() OVERRIDE;
|
||||
virtual int GetStatus() OVERRIDE;
|
||||
virtual void SetStatus(int status) OVERRIDE;
|
||||
virtual CefString GetStatusText() OVERRIDE;
|
||||
virtual void SetStatusText(const CefString& statusText) OVERRIDE;
|
||||
virtual CefString GetMimeType() OVERRIDE;
|
||||
virtual void SetMimeType(const CefString& mimeType) OVERRIDE;
|
||||
virtual CefString GetHeader(const CefString& name) OVERRIDE;
|
||||
virtual void GetHeaderMap(HeaderMap& headerMap) OVERRIDE;
|
||||
virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE;
|
||||
|
||||
net::HttpResponseHeaders* GetResponseHeaders();
|
||||
void SetResponseHeaders(const net::HttpResponseHeaders& headers);
|
||||
|
||||
void Set(const WebKit::WebURLResponse& response);
|
||||
|
||||
void SetReadOnly(bool read_only);
|
||||
|
||||
protected:
|
||||
int status_code_;
|
||||
CefString status_text_;
|
||||
CefString mime_type_;
|
||||
HeaderMap header_map_;
|
||||
bool read_only_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefResponseImpl);
|
||||
IMPLEMENT_LOCKING(CefResponseImpl);
|
||||
|
45
libcef/common/urlrequest_impl.cc
Normal file
45
libcef/common/urlrequest_impl.cc
Normal file
@ -0,0 +1,45 @@
|
||||
// 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.
|
||||
|
||||
#include "include/cef_urlrequest.h"
|
||||
#include "libcef/browser/browser_urlrequest_impl.h"
|
||||
#include "libcef/renderer/render_urlrequest_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
|
||||
// static
|
||||
CefRefPtr<CefURLRequest> CefURLRequest::Create(
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client) {
|
||||
if (!request.get() || !client.get()) {
|
||||
NOTREACHED() << "called with invalid parameters";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!MessageLoop::current()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (content::GetContentClient()->browser()) {
|
||||
// In the browser process.
|
||||
CefRefPtr<CefBrowserURLRequest> impl =
|
||||
new CefBrowserURLRequest(request, client);
|
||||
if (impl->Start())
|
||||
return impl.get();
|
||||
return NULL;
|
||||
} else if (content::GetContentClient()->renderer()) {
|
||||
// In the render process.
|
||||
CefRefPtr<CefRenderURLRequest> impl =
|
||||
new CefRenderURLRequest(request, client);
|
||||
if (impl->Start())
|
||||
return impl.get();
|
||||
return NULL;
|
||||
} else {
|
||||
NOTREACHED() << "called in unsupported process";
|
||||
return NULL;
|
||||
}
|
||||
}
|
375
libcef/renderer/render_urlrequest_impl.cc
Normal file
375
libcef/renderer/render_urlrequest_impl.cc
Normal file
@ -0,0 +1,375 @@
|
||||
// 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.
|
||||
|
||||
#include "libcef/renderer/render_urlrequest_impl.h"
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/common/response_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoaderClient.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLResponse.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
|
||||
|
||||
using WebKit::WebString;
|
||||
using WebKit::WebURL;
|
||||
using WebKit::WebURLError;
|
||||
using WebKit::WebURLLoader;
|
||||
using WebKit::WebURLRequest;
|
||||
using WebKit::WebURLResponse;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
class CefWebURLLoaderClient : public WebKit::WebURLLoaderClient {
|
||||
public:
|
||||
CefWebURLLoaderClient(CefRenderURLRequest::Context* context,
|
||||
int request_flags);
|
||||
virtual ~CefWebURLLoaderClient();
|
||||
|
||||
// WebKit::WebURLLoaderClient methods.
|
||||
virtual void willSendRequest(
|
||||
WebURLLoader* loader,
|
||||
WebURLRequest& newRequest,
|
||||
const WebURLResponse& redirectResponse) OVERRIDE;
|
||||
virtual void didSendData(
|
||||
WebURLLoader* loader,
|
||||
unsigned long long bytesSent,
|
||||
unsigned long long totalBytesToBeSent) OVERRIDE;
|
||||
virtual void didReceiveResponse(
|
||||
WebURLLoader* loader,
|
||||
const WebURLResponse& response) OVERRIDE;
|
||||
virtual void didDownloadData(WebURLLoader* loader,
|
||||
int dataLength) OVERRIDE;
|
||||
virtual void didReceiveData(WebURLLoader* loader,
|
||||
const char* data,
|
||||
int dataLength,
|
||||
int encodedDataLength) OVERRIDE;
|
||||
virtual void didReceiveCachedMetadata(WebURLLoader* loader,
|
||||
const char* data,
|
||||
int dataLength) OVERRIDE;
|
||||
virtual void didFinishLoading(WebURLLoader* loader,
|
||||
double finishTime) OVERRIDE;
|
||||
virtual void didFail(WebURLLoader* loader,
|
||||
const WebURLError& error) OVERRIDE;
|
||||
|
||||
protected:
|
||||
// The context_ pointer will outlive this object.
|
||||
CefRenderURLRequest::Context* context_;
|
||||
int request_flags_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
// CefRenderURLRequest::Context -----------------------------------------------
|
||||
|
||||
class CefRenderURLRequest::Context
|
||||
: public base::RefCountedThreadSafe<CefRenderURLRequest::Context> {
|
||||
public:
|
||||
Context(CefRefPtr<CefRenderURLRequest> url_request,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client)
|
||||
: url_request_(url_request),
|
||||
request_(request),
|
||||
client_(client),
|
||||
message_loop_proxy_(MessageLoop::current()->message_loop_proxy()),
|
||||
status_(UR_IO_PENDING),
|
||||
error_code_(ERR_NONE),
|
||||
upload_data_size_(0),
|
||||
got_upload_progress_complete_(false),
|
||||
download_data_received_(0),
|
||||
download_data_total_(-1) {
|
||||
// Mark the request as read-only.
|
||||
static_cast<CefRequestImpl*>(request_.get())->SetReadOnly(true);
|
||||
}
|
||||
|
||||
virtual ~Context() {
|
||||
}
|
||||
|
||||
inline bool CalledOnValidThread() {
|
||||
return message_loop_proxy_->BelongsToCurrentThread();
|
||||
}
|
||||
|
||||
bool Start() {
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
GURL url = GURL(request_->GetURL().ToString());
|
||||
if (!url.is_valid())
|
||||
return false;
|
||||
|
||||
loader_.reset(WebKit::webKitPlatformSupport()->createURLLoader());
|
||||
url_client_.reset(new CefWebURLLoaderClient(this, request_->GetFlags()));
|
||||
|
||||
WebURLRequest urlRequest;
|
||||
static_cast<CefRequestImpl*>(request_.get())->Get(urlRequest);
|
||||
|
||||
if (urlRequest.reportUploadProgress()) {
|
||||
// Attempt to determine the upload data size.
|
||||
CefRefPtr<CefPostData> post_data = request_->GetPostData();
|
||||
if (post_data.get()) {
|
||||
CefPostData::ElementVector elements;
|
||||
post_data->GetElements(elements);
|
||||
if (elements.size() == 1 && elements[0]->GetType() == PDE_TYPE_BYTES) {
|
||||
CefPostDataElementImpl* impl =
|
||||
static_cast<CefPostDataElementImpl*>(elements[0].get());
|
||||
upload_data_size_ = impl->GetBytesCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loader_->loadAsynchronously(urlRequest, url_client_.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Cancel() {
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
// The request may already be complete.
|
||||
if (!loader_.get() || status_ != UR_IO_PENDING)
|
||||
return;
|
||||
|
||||
status_ = UR_CANCELED;
|
||||
error_code_ = ERR_ABORTED;
|
||||
|
||||
// Will result in a call to OnError().
|
||||
loader_->cancel();
|
||||
}
|
||||
|
||||
void OnResponse(const WebURLResponse& response) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
response_ = CefResponse::Create();
|
||||
CefResponseImpl* responseImpl =
|
||||
static_cast<CefResponseImpl*>(response_.get());
|
||||
responseImpl->Set(response);
|
||||
responseImpl->SetReadOnly(true);
|
||||
|
||||
download_data_total_ = response.expectedContentLength();
|
||||
}
|
||||
|
||||
void OnError(const WebURLError& error) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
if (status_ == UR_IO_PENDING) {
|
||||
status_ = UR_FAILED;
|
||||
error_code_ = static_cast<CefURLRequest::ErrorCode>(error.reason);
|
||||
}
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
void OnComplete() {
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
if (status_ == UR_IO_PENDING) {
|
||||
status_ = UR_SUCCESS;
|
||||
NotifyUploadProgressIfNecessary();
|
||||
}
|
||||
|
||||
if (loader_.get())
|
||||
loader_.reset(NULL);
|
||||
|
||||
DCHECK(url_request_.get());
|
||||
client_->OnRequestComplete(url_request_.get());
|
||||
|
||||
// This may result in the Context object being deleted.
|
||||
url_request_ = NULL;
|
||||
}
|
||||
|
||||
void OnDownloadProgress(int64 current) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK(url_request_.get());
|
||||
|
||||
NotifyUploadProgressIfNecessary();
|
||||
|
||||
download_data_received_ += current;
|
||||
client_->OnDownloadProgress(url_request_.get(), download_data_received_,
|
||||
download_data_total_);
|
||||
}
|
||||
|
||||
void OnDownloadData(const char* data, int dataLength) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK(url_request_.get());
|
||||
client_->OnDownloadData(url_request_.get(), data, dataLength);
|
||||
}
|
||||
|
||||
void OnUploadProgress(int64 current, int64 total) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK(url_request_.get());
|
||||
if (current == total)
|
||||
got_upload_progress_complete_ = true;
|
||||
client_->OnUploadProgress(url_request_.get(), current, total);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> request() { return request_; }
|
||||
CefRefPtr<CefURLRequestClient> client() { return client_; }
|
||||
CefURLRequest::Status status() { return status_; }
|
||||
CefURLRequest::ErrorCode error_code() { return error_code_; }
|
||||
CefRefPtr<CefResponse> response() { return response_; }
|
||||
|
||||
private:
|
||||
void NotifyUploadProgressIfNecessary() {
|
||||
if (!got_upload_progress_complete_ && upload_data_size_ > 0) {
|
||||
// URLFetcher sends upload notifications using a timer and will not send
|
||||
// a notification if the request completes too quickly. We therefore
|
||||
// send the notification here if necessary.
|
||||
client_->OnUploadProgress(url_request_.get(), upload_data_size_,
|
||||
upload_data_size_);
|
||||
got_upload_progress_complete_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Members only accessed on the initialization thread.
|
||||
CefRefPtr<CefRenderURLRequest> url_request_;
|
||||
CefRefPtr<CefRequest> request_;
|
||||
CefRefPtr<CefURLRequestClient> client_;
|
||||
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
|
||||
CefURLRequest::Status status_;
|
||||
CefURLRequest::ErrorCode error_code_;
|
||||
CefRefPtr<CefResponse> response_;
|
||||
scoped_ptr<WebKit::WebURLLoader> loader_;
|
||||
scoped_ptr<CefWebURLLoaderClient> url_client_;
|
||||
int64 upload_data_size_;
|
||||
bool got_upload_progress_complete_;
|
||||
int64 download_data_received_;
|
||||
int64 download_data_total_;
|
||||
};
|
||||
|
||||
|
||||
// CefWebURLLoaderClient --------------------------------------------------
|
||||
|
||||
namespace {
|
||||
|
||||
CefWebURLLoaderClient::CefWebURLLoaderClient(
|
||||
CefRenderURLRequest::Context* context,
|
||||
int request_flags)
|
||||
: context_(context),
|
||||
request_flags_(request_flags) {
|
||||
}
|
||||
|
||||
CefWebURLLoaderClient::~CefWebURLLoaderClient() {
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::willSendRequest(
|
||||
WebURLLoader* loader,
|
||||
WebURLRequest& newRequest,
|
||||
const WebURLResponse& redirectResponse) {
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::didSendData(
|
||||
WebURLLoader* loader,
|
||||
unsigned long long bytesSent,
|
||||
unsigned long long totalBytesToBeSent) {
|
||||
if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS)
|
||||
context_->OnUploadProgress(bytesSent, totalBytesToBeSent);
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::didReceiveResponse(
|
||||
WebURLLoader* loader,
|
||||
const WebURLResponse& response) {
|
||||
context_->OnResponse(response);
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::didDownloadData(WebURLLoader* loader,
|
||||
int dataLength) {
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::didReceiveData(WebURLLoader* loader,
|
||||
const char* data,
|
||||
int dataLength,
|
||||
int encodedDataLength) {
|
||||
context_->OnDownloadProgress(dataLength);
|
||||
|
||||
if (!(request_flags_ & UR_FLAG_NO_DOWNLOAD_DATA))
|
||||
context_->OnDownloadData(data, dataLength);
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::didReceiveCachedMetadata(WebURLLoader* loader,
|
||||
const char* data,
|
||||
int dataLength) {
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::didFinishLoading(WebURLLoader* loader,
|
||||
double finishTime) {
|
||||
context_->OnComplete();
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::didFail(WebURLLoader* loader,
|
||||
const WebURLError& error) {
|
||||
context_->OnError(error);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
// CefRenderURLRequest --------------------------------------------------------
|
||||
|
||||
CefRenderURLRequest::CefRenderURLRequest(
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client) {
|
||||
context_ = new Context(this, request, client);
|
||||
}
|
||||
|
||||
CefRenderURLRequest::~CefRenderURLRequest() {
|
||||
}
|
||||
|
||||
bool CefRenderURLRequest::Start() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
return context_->Start();
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> CefRenderURLRequest::GetRequest() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
return context_->request();
|
||||
}
|
||||
|
||||
CefRefPtr<CefURLRequestClient> CefRenderURLRequest::GetClient() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
return context_->client();
|
||||
}
|
||||
|
||||
CefURLRequest::Status CefRenderURLRequest::GetRequestStatus() {
|
||||
if (!VerifyContext())
|
||||
return UR_UNKNOWN;
|
||||
return context_->status();
|
||||
}
|
||||
|
||||
CefURLRequest::ErrorCode CefRenderURLRequest::GetRequestError() {
|
||||
if (!VerifyContext())
|
||||
return ERR_NONE;
|
||||
return context_->error_code();
|
||||
}
|
||||
|
||||
CefRefPtr<CefResponse> CefRenderURLRequest::GetResponse() {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
return context_->response();
|
||||
}
|
||||
|
||||
void CefRenderURLRequest::Cancel() {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
return context_->Cancel();
|
||||
}
|
||||
|
||||
bool CefRenderURLRequest::VerifyContext() {
|
||||
DCHECK(context_.get());
|
||||
if (!context_->CalledOnValidThread()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
37
libcef/renderer/render_urlrequest_impl.h
Normal file
37
libcef/renderer/render_urlrequest_impl.h
Normal file
@ -0,0 +1,37 @@
|
||||
// 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_RENDERER_RENDER_URLREQUEST_IMPL_H_
|
||||
#define CEF_LIBCEF_RENDERER_RENDER_URLREQUEST_IMPL_H_
|
||||
|
||||
#include "include/cef_urlrequest.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
|
||||
class CefRenderURLRequest : public CefURLRequest {
|
||||
public:
|
||||
class Context;
|
||||
|
||||
CefRenderURLRequest(CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client);
|
||||
virtual ~CefRenderURLRequest();
|
||||
|
||||
bool Start();
|
||||
|
||||
// CefURLRequest methods.
|
||||
virtual CefRefPtr<CefRequest> GetRequest() OVERRIDE;
|
||||
virtual CefRefPtr<CefURLRequestClient> GetClient() OVERRIDE;
|
||||
virtual Status GetRequestStatus() OVERRIDE;
|
||||
virtual ErrorCode GetRequestError() OVERRIDE;
|
||||
virtual CefRefPtr<CefResponse> GetResponse() OVERRIDE;
|
||||
virtual void Cancel() OVERRIDE;
|
||||
|
||||
private:
|
||||
bool VerifyContext();
|
||||
|
||||
scoped_refptr<Context> context_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefBrowserURLRequest);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_RENDERER_RENDER_URLREQUEST_IMPL_H_
|
@ -11,7 +11,7 @@
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/app_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/proxy_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/render_process_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
|
||||
@ -57,22 +57,6 @@ void CEF_CALLBACK app_on_register_custom_schemes(struct _cef_app_t* self,
|
||||
CefSchemeRegistrarCToCpp::Wrap(registrar));
|
||||
}
|
||||
|
||||
struct _cef_render_process_handler_t* CEF_CALLBACK app_get_render_process_handler(
|
||||
struct _cef_app_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefRenderProcessHandler> _retval = CefAppCppToC::Get(
|
||||
self)->GetRenderProcessHandler();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRenderProcessHandlerCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_resource_bundle_handler_t* CEF_CALLBACK app_get_resource_bundle_handler(
|
||||
struct _cef_app_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -89,7 +73,7 @@ struct _cef_resource_bundle_handler_t* CEF_CALLBACK app_get_resource_bundle_hand
|
||||
return CefResourceBundleHandlerCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_proxy_handler_t* CEF_CALLBACK app_get_proxy_handler(
|
||||
struct _cef_browser_process_handler_t* CEF_CALLBACK app_get_browser_process_handler(
|
||||
struct _cef_app_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
@ -98,11 +82,27 @@ struct _cef_proxy_handler_t* CEF_CALLBACK app_get_proxy_handler(
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefProxyHandler> _retval = CefAppCppToC::Get(self)->GetProxyHandler(
|
||||
);
|
||||
CefRefPtr<CefBrowserProcessHandler> _retval = CefAppCppToC::Get(
|
||||
self)->GetBrowserProcessHandler();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefProxyHandlerCppToC::Wrap(_retval);
|
||||
return CefBrowserProcessHandlerCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_render_process_handler_t* CEF_CALLBACK app_get_render_process_handler(
|
||||
struct _cef_app_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefRenderProcessHandler> _retval = CefAppCppToC::Get(
|
||||
self)->GetRenderProcessHandler();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRenderProcessHandlerCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
@ -113,9 +113,9 @@ CefAppCppToC::CefAppCppToC(CefApp* cls)
|
||||
struct_.struct_.on_before_command_line_processing =
|
||||
app_on_before_command_line_processing;
|
||||
struct_.struct_.on_register_custom_schemes = app_on_register_custom_schemes;
|
||||
struct_.struct_.get_render_process_handler = app_get_render_process_handler;
|
||||
struct_.struct_.get_resource_bundle_handler = app_get_resource_bundle_handler;
|
||||
struct_.struct_.get_proxy_handler = app_get_proxy_handler;
|
||||
struct_.struct_.get_browser_process_handler = app_get_browser_process_handler;
|
||||
struct_.struct_.get_render_process_handler = app_get_render_process_handler;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
63
libcef_dll/cpptoc/browser_process_handler_cpptoc.cc
Normal file
63
libcef_dll/cpptoc/browser_process_handler_cpptoc.cc
Normal file
@ -0,0 +1,63 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/proxy_handler_cpptoc.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
struct _cef_proxy_handler_t* CEF_CALLBACK browser_process_handler_get_proxy_handler(
|
||||
struct _cef_browser_process_handler_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefProxyHandler> _retval = CefBrowserProcessHandlerCppToC::Get(
|
||||
self)->GetProxyHandler();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefProxyHandlerCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_process_handler_on_context_initialized(
|
||||
struct _cef_browser_process_handler_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefBrowserProcessHandlerCppToC::Get(self)->OnContextInitialized();
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC(
|
||||
CefBrowserProcessHandler* cls)
|
||||
: CefCppToC<CefBrowserProcessHandlerCppToC, CefBrowserProcessHandler,
|
||||
cef_browser_process_handler_t>(cls) {
|
||||
struct_.struct_.get_proxy_handler = browser_process_handler_get_proxy_handler;
|
||||
struct_.struct_.on_context_initialized =
|
||||
browser_process_handler_on_context_initialized;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefBrowserProcessHandlerCppToC,
|
||||
CefBrowserProcessHandler, cef_browser_process_handler_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
37
libcef_dll/cpptoc/browser_process_handler_cpptoc.h
Normal file
37
libcef_dll/cpptoc/browser_process_handler_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_BROWSER_PROCESS_HANDLER_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_BROWSER_PROCESS_HANDLER_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_browser_process_handler.h"
|
||||
#include "include/capi/cef_browser_process_handler_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefBrowserProcessHandlerCppToC
|
||||
: public CefCppToC<CefBrowserProcessHandlerCppToC, CefBrowserProcessHandler,
|
||||
cef_browser_process_handler_t> {
|
||||
public:
|
||||
explicit CefBrowserProcessHandlerCppToC(CefBrowserProcessHandler* cls);
|
||||
virtual ~CefBrowserProcessHandlerCppToC() {}
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_BROWSER_PROCESS_HANDLER_CPPTOC_H_
|
||||
|
@ -63,9 +63,8 @@ void CEF_CALLBACK load_handler_on_load_end(struct _cef_load_handler_t* self,
|
||||
}
|
||||
|
||||
void CEF_CALLBACK load_handler_on_load_error(struct _cef_load_handler_t* self,
|
||||
cef_browser_t* browser, cef_frame_t* frame,
|
||||
enum cef_handler_errorcode_t errorCode, const cef_string_t* errorText,
|
||||
const cef_string_t* failedUrl) {
|
||||
cef_browser_t* browser, cef_frame_t* frame, enum cef_errorcode_t errorCode,
|
||||
const cef_string_t* errorText, const cef_string_t* failedUrl) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
|
@ -20,7 +20,7 @@ CEF_EXPORT cef_post_data_t* cef_post_data_create() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefPostData> _retval = CefPostData::CreatePostData();
|
||||
CefRefPtr<CefPostData> _retval = CefPostData::Create();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefPostDataCppToC::Wrap(_retval);
|
||||
@ -29,6 +29,20 @@ CEF_EXPORT cef_post_data_t* cef_post_data_create() {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK post_data_is_read_only(struct _cef_post_data_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefPostDataCppToC::Get(self)->IsReadOnly();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
size_t CEF_CALLBACK post_data_get_element_count(struct _cef_post_data_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
@ -134,6 +148,7 @@ void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* self) {
|
||||
|
||||
CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls)
|
||||
: CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>(cls) {
|
||||
struct_.struct_.is_read_only = post_data_is_read_only;
|
||||
struct_.struct_.get_element_count = post_data_get_element_count;
|
||||
struct_.struct_.get_elements = post_data_get_elements;
|
||||
struct_.struct_.remove_element = post_data_remove_element;
|
||||
|
@ -19,8 +19,7 @@ CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefPostDataElement> _retval =
|
||||
CefPostDataElement::CreatePostDataElement();
|
||||
CefRefPtr<CefPostDataElement> _retval = CefPostDataElement::Create();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefPostDataElementCppToC::Wrap(_retval);
|
||||
@ -29,6 +28,21 @@ CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create() {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK post_data_element_is_read_only(
|
||||
struct _cef_post_data_element_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefPostDataElementCppToC::Get(self)->IsReadOnly();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
void CEF_CALLBACK post_data_element_set_to_empty(
|
||||
struct _cef_post_data_element_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -149,6 +163,7 @@ size_t CEF_CALLBACK post_data_element_get_bytes(
|
||||
CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls)
|
||||
: CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
|
||||
cef_post_data_element_t>(cls) {
|
||||
struct_.struct_.is_read_only = post_data_element_is_read_only;
|
||||
struct_.struct_.set_to_empty = post_data_element_set_to_empty;
|
||||
struct_.struct_.set_to_file = post_data_element_set_to_file;
|
||||
struct_.struct_.set_to_bytes = post_data_element_set_to_bytes;
|
||||
|
@ -21,7 +21,7 @@ CEF_EXPORT cef_request_t* cef_request_create() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefRequest> _retval = CefRequest::CreateRequest();
|
||||
CefRefPtr<CefRequest> _retval = CefRequest::Create();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRequestCppToC::Wrap(_retval);
|
||||
@ -30,6 +30,20 @@ CEF_EXPORT cef_request_t* cef_request_create() {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK request_is_read_only(struct _cef_request_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefRequestCppToC::Get(self)->IsReadOnly();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK request_get_url(
|
||||
struct _cef_request_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -206,23 +220,21 @@ void CEF_CALLBACK request_set(struct _cef_request_t* self,
|
||||
headerMapMultimap);
|
||||
}
|
||||
|
||||
enum cef_weburlrequest_flags_t CEF_CALLBACK request_get_flags(
|
||||
struct _cef_request_t* self) {
|
||||
int CEF_CALLBACK request_get_flags(struct _cef_request_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return WUR_FLAG_NONE;
|
||||
return UR_FLAG_NONE;
|
||||
|
||||
// Execute
|
||||
cef_weburlrequest_flags_t _retval = CefRequestCppToC::Get(self)->GetFlags();
|
||||
int _retval = CefRequestCppToC::Get(self)->GetFlags();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_set_flags(struct _cef_request_t* self,
|
||||
enum cef_weburlrequest_flags_t flags) {
|
||||
void CEF_CALLBACK request_set_flags(struct _cef_request_t* self, int flags) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
@ -271,6 +283,7 @@ void CEF_CALLBACK request_set_first_party_for_cookies(
|
||||
|
||||
CefRequestCppToC::CefRequestCppToC(CefRequest* cls)
|
||||
: CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>(cls) {
|
||||
struct_.struct_.is_read_only = request_is_read_only;
|
||||
struct_.struct_.get_url = request_get_url;
|
||||
struct_.struct_.set_url = request_set_url;
|
||||
struct_.struct_.get_method = request_get_method;
|
||||
|
@ -120,6 +120,56 @@ int CEF_CALLBACK resource_handler_read_response(
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK resource_handler_can_get_cookie(
|
||||
struct _cef_resource_handler_t* self, const struct _cef_cookie_t* cookie) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: cookie; type: struct_byref_const
|
||||
DCHECK(cookie);
|
||||
if (!cookie)
|
||||
return 0;
|
||||
|
||||
// Translate param: cookie; type: struct_byref_const
|
||||
CefCookie cookieObj;
|
||||
if (cookie)
|
||||
cookieObj.Set(*cookie, false);
|
||||
|
||||
// Execute
|
||||
bool _retval = CefResourceHandlerCppToC::Get(self)->CanGetCookie(
|
||||
cookieObj);
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK resource_handler_can_set_cookie(
|
||||
struct _cef_resource_handler_t* self, const struct _cef_cookie_t* cookie) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: cookie; type: struct_byref_const
|
||||
DCHECK(cookie);
|
||||
if (!cookie)
|
||||
return 0;
|
||||
|
||||
// Translate param: cookie; type: struct_byref_const
|
||||
CefCookie cookieObj;
|
||||
if (cookie)
|
||||
cookieObj.Set(*cookie, false);
|
||||
|
||||
// Execute
|
||||
bool _retval = CefResourceHandlerCppToC::Get(self)->CanSetCookie(
|
||||
cookieObj);
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
void CEF_CALLBACK resource_handler_cancel(
|
||||
struct _cef_resource_handler_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -141,6 +191,8 @@ CefResourceHandlerCppToC::CefResourceHandlerCppToC(CefResourceHandler* cls)
|
||||
struct_.struct_.process_request = resource_handler_process_request;
|
||||
struct_.struct_.get_response_headers = resource_handler_get_response_headers;
|
||||
struct_.struct_.read_response = resource_handler_read_response;
|
||||
struct_.struct_.can_get_cookie = resource_handler_can_get_cookie;
|
||||
struct_.struct_.can_set_cookie = resource_handler_can_set_cookie;
|
||||
struct_.struct_.cancel = resource_handler_cancel;
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,35 @@
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// GLOBAL FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
CEF_EXPORT cef_response_t* cef_response_create() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefResponse> _retval = CefResponse::Create();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefResponseCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK response_is_read_only(struct _cef_response_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefResponseCppToC::Get(self)->IsReadOnly();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK response_get_status(struct _cef_response_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
@ -178,6 +205,7 @@ void CEF_CALLBACK response_set_header_map(struct _cef_response_t* self,
|
||||
|
||||
CefResponseCppToC::CefResponseCppToC(CefResponse* cls)
|
||||
: CefCppToC<CefResponseCppToC, CefResponse, cef_response_t>(cls) {
|
||||
struct_.struct_.is_read_only = response_is_read_only;
|
||||
struct_.struct_.get_status = response_get_status;
|
||||
struct_.struct_.set_status = response_set_status;
|
||||
struct_.struct_.get_status_text = response_get_status_text;
|
||||
|
@ -28,14 +28,6 @@ cef_resource_handler_t* CEF_CALLBACK scheme_handler_factory_create(
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser)
|
||||
return NULL;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame);
|
||||
if (!frame)
|
||||
return NULL;
|
||||
// Verify param: scheme_name; type: string_byref_const
|
||||
DCHECK(scheme_name);
|
||||
if (!scheme_name)
|
||||
@ -44,6 +36,7 @@ cef_resource_handler_t* CEF_CALLBACK scheme_handler_factory_create(
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return NULL;
|
||||
// Unverified params: browser, frame
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefResourceHandler> _retval = CefSchemeHandlerFactoryCppToC::Get(
|
||||
|
116
libcef_dll/cpptoc/urlrequest_client_cpptoc.cc
Normal file
116
libcef_dll/cpptoc/urlrequest_client_cpptoc.cc
Normal file
@ -0,0 +1,116 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/urlrequest_client_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/urlrequest_ctocpp.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
void CEF_CALLBACK urlrequest_client_on_request_complete(
|
||||
struct _cef_urlrequest_client_t* self, cef_urlrequest_t* request) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefURLRequestClientCppToC::Get(self)->OnRequestComplete(
|
||||
CefURLRequestCToCpp::Wrap(request));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK urlrequest_client_on_upload_progress(
|
||||
struct _cef_urlrequest_client_t* self, cef_urlrequest_t* request,
|
||||
uint64 current, uint64 total) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefURLRequestClientCppToC::Get(self)->OnUploadProgress(
|
||||
CefURLRequestCToCpp::Wrap(request),
|
||||
current,
|
||||
total);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK urlrequest_client_on_download_progress(
|
||||
struct _cef_urlrequest_client_t* self, cef_urlrequest_t* request,
|
||||
uint64 current, uint64 total) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefURLRequestClientCppToC::Get(self)->OnDownloadProgress(
|
||||
CefURLRequestCToCpp::Wrap(request),
|
||||
current,
|
||||
total);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK urlrequest_client_on_download_data(
|
||||
struct _cef_urlrequest_client_t* self, cef_urlrequest_t* request,
|
||||
const void* data, size_t data_length) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return;
|
||||
// Verify param: data; type: simple_byaddr
|
||||
DCHECK(data);
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefURLRequestClientCppToC::Get(self)->OnDownloadData(
|
||||
CefURLRequestCToCpp::Wrap(request),
|
||||
data,
|
||||
data_length);
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefURLRequestClientCppToC::CefURLRequestClientCppToC(CefURLRequestClient* cls)
|
||||
: CefCppToC<CefURLRequestClientCppToC, CefURLRequestClient,
|
||||
cef_urlrequest_client_t>(cls) {
|
||||
struct_.struct_.on_request_complete = urlrequest_client_on_request_complete;
|
||||
struct_.struct_.on_upload_progress = urlrequest_client_on_upload_progress;
|
||||
struct_.struct_.on_download_progress = urlrequest_client_on_download_progress;
|
||||
struct_.struct_.on_download_data = urlrequest_client_on_download_data;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefURLRequestClientCppToC, CefURLRequestClient,
|
||||
cef_urlrequest_client_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
37
libcef_dll/cpptoc/urlrequest_client_cpptoc.h
Normal file
37
libcef_dll/cpptoc/urlrequest_client_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CLIENT_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CLIENT_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_urlrequest.h"
|
||||
#include "include/capi/cef_urlrequest_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefURLRequestClientCppToC
|
||||
: public CefCppToC<CefURLRequestClientCppToC, CefURLRequestClient,
|
||||
cef_urlrequest_client_t> {
|
||||
public:
|
||||
explicit CefURLRequestClientCppToC(CefURLRequestClient* cls);
|
||||
virtual ~CefURLRequestClientCppToC() {}
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CLIENT_CPPTOC_H_
|
||||
|
152
libcef_dll/cpptoc/urlrequest_cpptoc.cc
Normal file
152
libcef_dll/cpptoc/urlrequest_cpptoc.cc
Normal file
@ -0,0 +1,152 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/request_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/response_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/urlrequest_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/urlrequest_client_ctocpp.h"
|
||||
|
||||
|
||||
// GLOBAL FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
CEF_EXPORT cef_urlrequest_t* cef_urlrequest_create(cef_request_t* request,
|
||||
struct _cef_urlrequest_client_t* client) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: request; type: refptr_same
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return NULL;
|
||||
// Verify param: client; type: refptr_diff
|
||||
DCHECK(client);
|
||||
if (!client)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefURLRequest> _retval = CefURLRequest::Create(
|
||||
CefRequestCppToC::Unwrap(request),
|
||||
CefURLRequestClientCToCpp::Wrap(client));
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefURLRequestCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
cef_request_t* CEF_CALLBACK urlrequest_get_request(
|
||||
struct _cef_urlrequest_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefRequest> _retval = CefURLRequestCppToC::Get(self)->GetRequest();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRequestCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_urlrequest_client_t* CEF_CALLBACK urlrequest_get_client(
|
||||
struct _cef_urlrequest_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefURLRequestClient> _retval = CefURLRequestCppToC::Get(
|
||||
self)->GetClient();
|
||||
|
||||
// Return type: refptr_diff
|
||||
return CefURLRequestClientCToCpp::Unwrap(_retval);
|
||||
}
|
||||
|
||||
enum cef_urlrequest_status_t CEF_CALLBACK urlrequest_get_request_status(
|
||||
struct _cef_urlrequest_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return UR_UNKNOWN;
|
||||
|
||||
// Execute
|
||||
cef_urlrequest_status_t _retval = CefURLRequestCppToC::Get(
|
||||
self)->GetRequestStatus();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
enum cef_errorcode_t CEF_CALLBACK urlrequest_get_request_error(
|
||||
struct _cef_urlrequest_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return ERR_NONE;
|
||||
|
||||
// Execute
|
||||
cef_errorcode_t _retval = CefURLRequestCppToC::Get(self)->GetRequestError();
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_response_t* CEF_CALLBACK urlrequest_get_response(
|
||||
struct _cef_urlrequest_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefResponse> _retval = CefURLRequestCppToC::Get(self)->GetResponse(
|
||||
);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefResponseCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK urlrequest_cancel(struct _cef_urlrequest_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefURLRequestCppToC::Get(self)->Cancel();
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefURLRequestCppToC::CefURLRequestCppToC(CefURLRequest* cls)
|
||||
: CefCppToC<CefURLRequestCppToC, CefURLRequest, cef_urlrequest_t>(cls) {
|
||||
struct_.struct_.get_request = urlrequest_get_request;
|
||||
struct_.struct_.get_client = urlrequest_get_client;
|
||||
struct_.struct_.get_request_status = urlrequest_get_request_status;
|
||||
struct_.struct_.get_request_error = urlrequest_get_request_error;
|
||||
struct_.struct_.get_response = urlrequest_get_response;
|
||||
struct_.struct_.cancel = urlrequest_cancel;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefURLRequestCppToC, CefURLRequest,
|
||||
cef_urlrequest_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
36
libcef_dll/cpptoc/urlrequest_cpptoc.h
Normal file
36
libcef_dll/cpptoc/urlrequest_cpptoc.h
Normal file
@ -0,0 +1,36 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_urlrequest.h"
|
||||
#include "include/capi/cef_urlrequest_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefURLRequestCppToC
|
||||
: public CefCppToC<CefURLRequestCppToC, CefURLRequest, cef_urlrequest_t> {
|
||||
public:
|
||||
explicit CefURLRequestCppToC(CefURLRequest* cls);
|
||||
virtual ~CefURLRequestCppToC() {}
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CPPTOC_H_
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/app_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/proxy_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/render_process_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h"
|
||||
|
||||
@ -56,20 +56,6 @@ void CefAppCToCpp::OnRegisterCustomSchemes(
|
||||
CefSchemeRegistrarCppToC::Wrap(registrar));
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderProcessHandler> CefAppCToCpp::GetRenderProcessHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_render_process_handler))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_render_process_handler_t* _retval = struct_->get_render_process_handler(
|
||||
struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRenderProcessHandlerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefResourceBundleHandler> CefAppCToCpp::GetResourceBundleHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_resource_bundle_handler))
|
||||
return NULL;
|
||||
@ -84,17 +70,32 @@ CefRefPtr<CefResourceBundleHandler> CefAppCToCpp::GetResourceBundleHandler() {
|
||||
return CefResourceBundleHandlerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefProxyHandler> CefAppCToCpp::GetProxyHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_proxy_handler))
|
||||
CefRefPtr<CefBrowserProcessHandler> CefAppCToCpp::GetBrowserProcessHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_browser_process_handler))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_proxy_handler_t* _retval = struct_->get_proxy_handler(struct_);
|
||||
cef_browser_process_handler_t* _retval = struct_->get_browser_process_handler(
|
||||
struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefProxyHandlerCToCpp::Wrap(_retval);
|
||||
return CefBrowserProcessHandlerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderProcessHandler> CefAppCToCpp::GetRenderProcessHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_render_process_handler))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_render_process_handler_t* _retval = struct_->get_render_process_handler(
|
||||
struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRenderProcessHandlerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,10 +36,11 @@ class CefAppCToCpp
|
||||
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
||||
virtual void OnRegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) OVERRIDE;
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler(
|
||||
) OVERRIDE;
|
||||
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler(
|
||||
) OVERRIDE;
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
|
47
libcef_dll/ctocpp/browser_process_handler_ctocpp.cc
Normal file
47
libcef_dll/ctocpp/browser_process_handler_ctocpp.cc
Normal file
@ -0,0 +1,47 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/proxy_handler_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
CefRefPtr<CefProxyHandler> CefBrowserProcessHandlerCToCpp::GetProxyHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_proxy_handler))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_proxy_handler_t* _retval = struct_->get_proxy_handler(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefProxyHandlerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CefBrowserProcessHandlerCToCpp::OnContextInitialized() {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_context_initialized))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
struct_->on_context_initialized(struct_);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefBrowserProcessHandlerCToCpp,
|
||||
CefBrowserProcessHandler, cef_browser_process_handler_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
43
libcef_dll/ctocpp/browser_process_handler_ctocpp.h
Normal file
43
libcef_dll/ctocpp/browser_process_handler_ctocpp.h
Normal file
@ -0,0 +1,43 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_browser_process_handler.h"
|
||||
#include "include/capi/cef_browser_process_handler_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefBrowserProcessHandlerCToCpp
|
||||
: public CefCToCpp<CefBrowserProcessHandlerCToCpp, CefBrowserProcessHandler,
|
||||
cef_browser_process_handler_t> {
|
||||
public:
|
||||
explicit CefBrowserProcessHandlerCToCpp(cef_browser_process_handler_t* str)
|
||||
: CefCToCpp<CefBrowserProcessHandlerCToCpp, CefBrowserProcessHandler,
|
||||
cef_browser_process_handler_t>(str) {}
|
||||
virtual ~CefBrowserProcessHandlerCToCpp() {}
|
||||
|
||||
// CefBrowserProcessHandler methods
|
||||
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE;
|
||||
virtual void OnContextInitialized() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
// STATIC METHODS - Body may be edited by hand.
|
||||
|
||||
CefRefPtr<CefPostData> CefPostData::CreatePostData() {
|
||||
CefRefPtr<CefPostData> CefPostData::Create() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
@ -29,6 +29,19 @@ CefRefPtr<CefPostData> CefPostData::CreatePostData() {
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefPostDataCToCpp::IsReadOnly() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_read_only))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_read_only(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
size_t CefPostDataCToCpp::GetElementCount() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_element_count))
|
||||
return 0;
|
||||
|
@ -32,6 +32,7 @@ class CefPostDataCToCpp
|
||||
virtual ~CefPostDataCToCpp() {}
|
||||
|
||||
// CefPostData methods
|
||||
virtual bool IsReadOnly() OVERRIDE;
|
||||
virtual size_t GetElementCount() OVERRIDE;
|
||||
virtual void GetElements(ElementVector& elements) OVERRIDE;
|
||||
virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element) OVERRIDE;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
// STATIC METHODS - Body may be edited by hand.
|
||||
|
||||
CefRefPtr<CefPostDataElement> CefPostDataElement::CreatePostDataElement() {
|
||||
CefRefPtr<CefPostDataElement> CefPostDataElement::Create() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
@ -28,6 +28,19 @@ CefRefPtr<CefPostDataElement> CefPostDataElement::CreatePostDataElement() {
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefPostDataElementCToCpp::IsReadOnly() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_read_only))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_read_only(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
void CefPostDataElementCToCpp::SetToEmpty() {
|
||||
if (CEF_MEMBER_MISSING(struct_, set_to_empty))
|
||||
return;
|
||||
|
@ -34,6 +34,7 @@ class CefPostDataElementCToCpp
|
||||
virtual ~CefPostDataElementCToCpp() {}
|
||||
|
||||
// CefPostDataElement methods
|
||||
virtual bool IsReadOnly() OVERRIDE;
|
||||
virtual void SetToEmpty() OVERRIDE;
|
||||
virtual void SetToFile(const CefString& fileName) OVERRIDE;
|
||||
virtual void SetToBytes(size_t size, const void* bytes) OVERRIDE;
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
// STATIC METHODS - Body may be edited by hand.
|
||||
|
||||
CefRefPtr<CefRequest> CefRequest::CreateRequest() {
|
||||
CefRefPtr<CefRequest> CefRequest::Create() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
@ -30,6 +30,19 @@ CefRefPtr<CefRequest> CefRequest::CreateRequest() {
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefRequestCToCpp::IsReadOnly() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_read_only))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_read_only(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefString CefRequestCToCpp::GetURL() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_url))
|
||||
return CefString();
|
||||
@ -201,20 +214,20 @@ void CefRequestCToCpp::Set(const CefString& url, const CefString& method,
|
||||
cef_string_multimap_free(headerMapMultimap);
|
||||
}
|
||||
|
||||
CefRequest::RequestFlags CefRequestCToCpp::GetFlags() {
|
||||
int CefRequestCToCpp::GetFlags() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_flags))
|
||||
return WUR_FLAG_NONE;
|
||||
return UR_FLAG_NONE;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_weburlrequest_flags_t _retval = struct_->get_flags(struct_);
|
||||
int _retval = struct_->get_flags(struct_);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
void CefRequestCToCpp::SetFlags(RequestFlags flags) {
|
||||
void CefRequestCToCpp::SetFlags(int flags) {
|
||||
if (CEF_MEMBER_MISSING(struct_, set_flags))
|
||||
return;
|
||||
|
||||
|
@ -32,6 +32,7 @@ class CefRequestCToCpp
|
||||
virtual ~CefRequestCToCpp() {}
|
||||
|
||||
// CefRequest methods
|
||||
virtual bool IsReadOnly() OVERRIDE;
|
||||
virtual CefString GetURL() OVERRIDE;
|
||||
virtual void SetURL(const CefString& url) OVERRIDE;
|
||||
virtual CefString GetMethod() OVERRIDE;
|
||||
@ -42,8 +43,8 @@ class CefRequestCToCpp
|
||||
virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE;
|
||||
virtual void Set(const CefString& url, const CefString& method,
|
||||
CefRefPtr<CefPostData> postData, const HeaderMap& headerMap) OVERRIDE;
|
||||
virtual RequestFlags GetFlags() OVERRIDE;
|
||||
virtual void SetFlags(RequestFlags flags) OVERRIDE;
|
||||
virtual int GetFlags() OVERRIDE;
|
||||
virtual void SetFlags(int flags) OVERRIDE;
|
||||
virtual CefString GetFirstPartyForCookies() OVERRIDE;
|
||||
virtual void SetFirstPartyForCookies(const CefString& url) OVERRIDE;
|
||||
};
|
||||
|
@ -90,6 +90,34 @@ bool CefResourceHandlerCToCpp::ReadResponse(void* data_out, int bytes_to_read,
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefResourceHandlerCToCpp::CanGetCookie(const CefCookie& cookie) {
|
||||
if (CEF_MEMBER_MISSING(struct_, can_get_cookie))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->can_get_cookie(struct_,
|
||||
&cookie);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefResourceHandlerCToCpp::CanSetCookie(const CefCookie& cookie) {
|
||||
if (CEF_MEMBER_MISSING(struct_, can_set_cookie))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->can_set_cookie(struct_,
|
||||
&cookie);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
void CefResourceHandlerCToCpp::Cancel() {
|
||||
if (CEF_MEMBER_MISSING(struct_, cancel))
|
||||
return;
|
||||
|
@ -40,6 +40,8 @@ class CefResourceHandlerCToCpp
|
||||
int64& response_length, CefString& redirectUrl) OVERRIDE;
|
||||
virtual bool ReadResponse(void* data_out, int bytes_to_read, int& bytes_read,
|
||||
CefRefPtr<CefCallback> callback) OVERRIDE;
|
||||
virtual bool CanGetCookie(const CefCookie& cookie) OVERRIDE;
|
||||
virtual bool CanSetCookie(const CefCookie& cookie) OVERRIDE;
|
||||
virtual void Cancel() OVERRIDE;
|
||||
};
|
||||
|
||||
|
@ -14,8 +14,34 @@
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// STATIC METHODS - Body may be edited by hand.
|
||||
|
||||
CefRefPtr<CefResponse> CefResponse::Create() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_response_t* _retval = cef_response_create();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefResponseCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefResponseCToCpp::IsReadOnly() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_read_only))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_read_only(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
int CefResponseCToCpp::GetStatus() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_status))
|
||||
return 0;
|
||||
|
@ -32,6 +32,7 @@ class CefResponseCToCpp
|
||||
virtual ~CefResponseCToCpp() {}
|
||||
|
||||
// CefResponse methods
|
||||
virtual bool IsReadOnly() OVERRIDE;
|
||||
virtual int GetStatus() OVERRIDE;
|
||||
virtual void SetStatus(int status) OVERRIDE;
|
||||
virtual CefString GetStatusText() OVERRIDE;
|
||||
|
@ -27,14 +27,6 @@ CefRefPtr<CefResourceHandler> CefSchemeHandlerFactoryCToCpp::Create(
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return NULL;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame.get());
|
||||
if (!frame.get())
|
||||
return NULL;
|
||||
// Verify param: scheme_name; type: string_byref_const
|
||||
DCHECK(!scheme_name.empty());
|
||||
if (scheme_name.empty())
|
||||
@ -43,6 +35,7 @@ CefRefPtr<CefResourceHandler> CefSchemeHandlerFactoryCToCpp::Create(
|
||||
DCHECK(request.get());
|
||||
if (!request.get())
|
||||
return NULL;
|
||||
// Unverified params: browser, frame
|
||||
|
||||
// Execute
|
||||
cef_resource_handler_t* _retval = struct_->create(struct_,
|
||||
|
102
libcef_dll/ctocpp/urlrequest_client_ctocpp.cc
Normal file
102
libcef_dll/ctocpp/urlrequest_client_ctocpp.cc
Normal file
@ -0,0 +1,102 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/urlrequest_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/urlrequest_client_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
void CefURLRequestClientCToCpp::OnRequestComplete(
|
||||
CefRefPtr<CefURLRequest> request) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_request_complete))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request.get());
|
||||
if (!request.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->on_request_complete(struct_,
|
||||
CefURLRequestCppToC::Wrap(request));
|
||||
}
|
||||
|
||||
void CefURLRequestClientCToCpp::OnUploadProgress(
|
||||
CefRefPtr<CefURLRequest> request, uint64 current, uint64 total) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_upload_progress))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request.get());
|
||||
if (!request.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->on_upload_progress(struct_,
|
||||
CefURLRequestCppToC::Wrap(request),
|
||||
current,
|
||||
total);
|
||||
}
|
||||
|
||||
void CefURLRequestClientCToCpp::OnDownloadProgress(
|
||||
CefRefPtr<CefURLRequest> request, uint64 current, uint64 total) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_download_progress))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request.get());
|
||||
if (!request.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->on_download_progress(struct_,
|
||||
CefURLRequestCppToC::Wrap(request),
|
||||
current,
|
||||
total);
|
||||
}
|
||||
|
||||
void CefURLRequestClientCToCpp::OnDownloadData(CefRefPtr<CefURLRequest> request,
|
||||
const void* data, size_t data_length) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_download_data))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request.get());
|
||||
if (!request.get())
|
||||
return;
|
||||
// Verify param: data; type: simple_byaddr
|
||||
DCHECK(data);
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->on_download_data(struct_,
|
||||
CefURLRequestCppToC::Wrap(request),
|
||||
data,
|
||||
data_length);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefURLRequestClientCToCpp, CefURLRequestClient,
|
||||
cef_urlrequest_client_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
48
libcef_dll/ctocpp/urlrequest_client_ctocpp.h
Normal file
48
libcef_dll/ctocpp/urlrequest_client_ctocpp.h
Normal file
@ -0,0 +1,48 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CLIENT_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CLIENT_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_urlrequest.h"
|
||||
#include "include/capi/cef_urlrequest_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefURLRequestClientCToCpp
|
||||
: public CefCToCpp<CefURLRequestClientCToCpp, CefURLRequestClient,
|
||||
cef_urlrequest_client_t> {
|
||||
public:
|
||||
explicit CefURLRequestClientCToCpp(cef_urlrequest_client_t* str)
|
||||
: CefCToCpp<CefURLRequestClientCToCpp, CefURLRequestClient,
|
||||
cef_urlrequest_client_t>(str) {}
|
||||
virtual ~CefURLRequestClientCToCpp() {}
|
||||
|
||||
// CefURLRequestClient methods
|
||||
virtual void OnRequestComplete(CefRefPtr<CefURLRequest> request) OVERRIDE;
|
||||
virtual void OnUploadProgress(CefRefPtr<CefURLRequest> request,
|
||||
uint64 current, uint64 total) OVERRIDE;
|
||||
virtual void OnDownloadProgress(CefRefPtr<CefURLRequest> request,
|
||||
uint64 current, uint64 total) OVERRIDE;
|
||||
virtual void OnDownloadData(CefRefPtr<CefURLRequest> request,
|
||||
const void* data, size_t data_length) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CLIENT_CTOCPP_H_
|
||||
|
126
libcef_dll/ctocpp/urlrequest_ctocpp.cc
Normal file
126
libcef_dll/ctocpp/urlrequest_ctocpp.cc
Normal file
@ -0,0 +1,126 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/urlrequest_client_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/request_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/response_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/urlrequest_ctocpp.h"
|
||||
|
||||
|
||||
// STATIC METHODS - Body may be edited by hand.
|
||||
|
||||
CefRefPtr<CefURLRequest> CefURLRequest::Create(CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: request; type: refptr_same
|
||||
DCHECK(request.get());
|
||||
if (!request.get())
|
||||
return NULL;
|
||||
// Verify param: client; type: refptr_diff
|
||||
DCHECK(client.get());
|
||||
if (!client.get())
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
cef_urlrequest_t* _retval = cef_urlrequest_create(
|
||||
CefRequestCToCpp::Unwrap(request),
|
||||
CefURLRequestClientCppToC::Wrap(client));
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefURLRequestCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
CefRefPtr<CefRequest> CefURLRequestCToCpp::GetRequest() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_request))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_request_t* _retval = struct_->get_request(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRequestCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefURLRequestClient> CefURLRequestCToCpp::GetClient() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_client))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_urlrequest_client_t* _retval = struct_->get_client(struct_);
|
||||
|
||||
// Return type: refptr_diff
|
||||
return CefURLRequestClientCppToC::Unwrap(_retval);
|
||||
}
|
||||
|
||||
CefURLRequest::Status CefURLRequestCToCpp::GetRequestStatus() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_request_status))
|
||||
return UR_UNKNOWN;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_urlrequest_status_t _retval = struct_->get_request_status(struct_);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
CefURLRequest::ErrorCode CefURLRequestCToCpp::GetRequestError() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_request_error))
|
||||
return ERR_NONE;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_errorcode_t _retval = struct_->get_request_error(struct_);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
CefRefPtr<CefResponse> CefURLRequestCToCpp::GetResponse() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_response))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_response_t* _retval = struct_->get_response(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefResponseCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CefURLRequestCToCpp::Cancel() {
|
||||
if (CEF_MEMBER_MISSING(struct_, cancel))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
struct_->cancel(struct_);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefURLRequestCToCpp, CefURLRequest,
|
||||
cef_urlrequest_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
45
libcef_dll/ctocpp/urlrequest_ctocpp.h
Normal file
45
libcef_dll/ctocpp/urlrequest_ctocpp.h
Normal file
@ -0,0 +1,45 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_urlrequest.h"
|
||||
#include "include/capi/cef_urlrequest_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefURLRequestCToCpp
|
||||
: public CefCToCpp<CefURLRequestCToCpp, CefURLRequest, cef_urlrequest_t> {
|
||||
public:
|
||||
explicit CefURLRequestCToCpp(cef_urlrequest_t* str)
|
||||
: CefCToCpp<CefURLRequestCToCpp, CefURLRequest, cef_urlrequest_t>(str) {}
|
||||
virtual ~CefURLRequestCToCpp() {}
|
||||
|
||||
// CefURLRequest methods
|
||||
virtual CefRefPtr<CefRequest> GetRequest() OVERRIDE;
|
||||
virtual CefRefPtr<CefURLRequestClient> GetClient() OVERRIDE;
|
||||
virtual Status GetRequestStatus() OVERRIDE;
|
||||
virtual ErrorCode GetRequestError() OVERRIDE;
|
||||
virtual CefRefPtr<CefResponse> GetResponse() OVERRIDE;
|
||||
virtual void Cancel() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CTOCPP_H_
|
||||
|
@ -40,14 +40,11 @@
|
||||
#include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/menu_model_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/post_data_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/post_data_element_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/response_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/stream_writer_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/urlrequest_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8context_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8exception_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8value_cpptoc.h"
|
||||
@ -55,6 +52,7 @@
|
||||
#include "libcef_dll/cpptoc/xml_reader_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/zip_reader_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/app_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h"
|
||||
@ -75,6 +73,7 @@
|
||||
#include "libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/string_visitor_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/task_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/urlrequest_client_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/v8accessor_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/v8handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.h"
|
||||
@ -152,6 +151,7 @@ CEF_EXPORT void cef_shutdown() {
|
||||
DCHECK_EQ(CefBinaryValueCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefBrowserCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefBrowserHostCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefBrowserProcessHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefCallbackCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefContextMenuHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefContextMenuParamsCppToC::DebugObjCt, 0);
|
||||
@ -175,23 +175,21 @@ CEF_EXPORT void cef_shutdown() {
|
||||
DCHECK_EQ(CefListValueCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefLoadHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefMenuModelCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefPostDataCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefPostDataElementCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefProcessMessageCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefProxyHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefReadHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefRenderProcessHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefRequestCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefRequestHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefResourceBundleHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefResourceHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefResponseCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefSchemeHandlerFactoryCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefSchemeRegistrarCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStreamReaderCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStreamWriterCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStringVisitorCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefTaskCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefURLRequestClientCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefURLRequestCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefV8AccessorCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefV8ContextCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefV8ExceptionCppToC::DebugObjCt, 0);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "include/capi/cef_web_plugin_capi.h"
|
||||
#include "include/cef_version.h"
|
||||
#include "libcef_dll/cpptoc/app_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
|
||||
@ -46,6 +47,7 @@
|
||||
#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/string_visitor_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/task_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/urlrequest_client_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8accessor_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h"
|
||||
@ -66,14 +68,11 @@
|
||||
#include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/menu_model_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/post_data_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/post_data_element_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/process_message_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/request_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/response_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/stream_writer_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/urlrequest_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/v8context_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/v8exception_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
|
||||
@ -144,6 +143,7 @@ CEF_GLOBAL void CefShutdown() {
|
||||
DCHECK_EQ(CefBinaryValueCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefBrowserCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefBrowserHostCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefBrowserProcessHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefCallbackCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefContextMenuHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefContextMenuParamsCToCpp::DebugObjCt, 0);
|
||||
@ -167,23 +167,21 @@ CEF_GLOBAL void CefShutdown() {
|
||||
DCHECK_EQ(CefListValueCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefLoadHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefMenuModelCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefPostDataCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefPostDataElementCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefProcessMessageCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefProxyHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefReadHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefRenderProcessHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefRequestCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefRequestHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefResourceBundleHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefResourceHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefResponseCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefSchemeHandlerFactoryCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefSchemeRegistrarCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStreamReaderCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStreamWriterCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStringVisitorCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefTaskCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefURLRequestCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefURLRequestClientCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefV8AccessorCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefV8ContextCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefV8ExceptionCToCpp::DebugObjCt, 0);
|
||||
|
@ -262,18 +262,17 @@ void RunGetTextTest(CefRefPtr<CefBrowser> browser) {
|
||||
|
||||
void RunRequestTest(CefRefPtr<CefBrowser> browser) {
|
||||
// Create a new request
|
||||
CefRefPtr<CefRequest> request(CefRequest::CreateRequest());
|
||||
CefRefPtr<CefRequest> request(CefRequest::Create());
|
||||
|
||||
// Set the request URL
|
||||
request->SetURL("http://tests/request");
|
||||
|
||||
// Add post data to the request. The correct method and content-
|
||||
// type headers will be set by CEF.
|
||||
CefRefPtr<CefPostDataElement> postDataElement(
|
||||
CefPostDataElement::CreatePostDataElement());
|
||||
CefRefPtr<CefPostDataElement> postDataElement(CefPostDataElement::Create());
|
||||
std::string data = "arg1=val1&arg2=val2";
|
||||
postDataElement->SetToBytes(data.length(), data.c_str());
|
||||
CefRefPtr<CefPostData> postData(CefPostData::CreatePostData());
|
||||
CefRefPtr<CefPostData> postData(CefPostData::Create());
|
||||
postData->AddElement(postDataElement);
|
||||
request->SetPostData(postData);
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "include/cef_cookie.h"
|
||||
#include "include/cef_process_message.h"
|
||||
#include "include/cef_task.h"
|
||||
#include "include/cef_v8.h"
|
||||
@ -176,6 +177,10 @@ class ClientAppExtensionHandler : public CefV8Handler {
|
||||
ClientApp::ClientApp()
|
||||
: proxy_type_(PROXY_TYPE_DIRECT) {
|
||||
CreateRenderDelegates(render_delegates_);
|
||||
|
||||
// Default schemes that support cookies.
|
||||
cookieable_schemes_.push_back("http");
|
||||
cookieable_schemes_.push_back("https");
|
||||
}
|
||||
|
||||
void ClientApp::SetMessageCallback(const std::string& message_name,
|
||||
@ -203,6 +208,13 @@ bool ClientApp::RemoveMessageCallback(const std::string& message_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientApp::OnContextInitialized() {
|
||||
// Register cookieable schemes with the global cookie manager.
|
||||
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager();
|
||||
ASSERT(manager.get());
|
||||
manager->SetSupportedSchemes(cookieable_schemes_);
|
||||
}
|
||||
|
||||
void ClientApp::GetProxyForUrl(const CefString& url,
|
||||
CefProxyInfo& proxy_info) {
|
||||
proxy_info.proxyType = proxy_type_;
|
||||
|
@ -10,9 +10,11 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "include/cef_app.h"
|
||||
|
||||
class ClientApp : public CefApp,
|
||||
public CefBrowserProcessHandler,
|
||||
public CefProxyHandler,
|
||||
public CefRenderProcessHandler {
|
||||
public:
|
||||
@ -96,16 +98,22 @@ class ClientApp : public CefApp,
|
||||
static void CreateRenderDelegates(RenderDelegateSet& delegates);
|
||||
|
||||
// Registers custom schemes. Implemented in client_app_delegates.
|
||||
static void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar);
|
||||
static void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes);
|
||||
|
||||
// CefApp methods.
|
||||
virtual void OnRegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) OVERRIDE {
|
||||
RegisterCustomSchemes(registrar);
|
||||
RegisterCustomSchemes(registrar, cookieable_schemes_);
|
||||
}
|
||||
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
|
||||
OVERRIDE { return this; }
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
|
||||
OVERRIDE { return this; }
|
||||
|
||||
// CefBrowserProcessHandler methods.
|
||||
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE { return this; }
|
||||
virtual void OnContextInitialized();
|
||||
|
||||
// CefProxyHandler methods.
|
||||
virtual void GetProxyForUrl(const CefString& url,
|
||||
@ -140,6 +148,9 @@ class ClientApp : public CefApp,
|
||||
// Set of supported RenderDelegates.
|
||||
RenderDelegateSet render_delegates_;
|
||||
|
||||
// Schemes that will be registered with the global cookie manager.
|
||||
std::vector<CefString> cookieable_schemes_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(ClientApp);
|
||||
};
|
||||
|
||||
|
@ -14,6 +14,8 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
scheme_test::RegisterCustomSchemes(registrar);
|
||||
void ClientApp::RegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes) {
|
||||
scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes);
|
||||
}
|
||||
|
@ -165,7 +165,8 @@ class ClientSchemeHandlerFactory : public CefSchemeHandlerFactory {
|
||||
|
||||
} // namespace
|
||||
|
||||
void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes) {
|
||||
registrar->AddCustomScheme("client", true, false, false);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define CEF_TESTS_CEFCLIENT_SCHEME_TEST_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "include/cef_base.h"
|
||||
|
||||
class CefBrowser;
|
||||
@ -14,7 +15,8 @@ class CefSchemeRegistrar;
|
||||
namespace scheme_test {
|
||||
|
||||
// Register the scheme.
|
||||
void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar);
|
||||
void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes);
|
||||
|
||||
// Create the scheme handler.
|
||||
void InitTest();
|
||||
|
@ -18,17 +18,31 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
// Bring in the DOM tests.
|
||||
extern void CreateDOMRendererTests(RenderDelegateSet& delegates);
|
||||
CreateDOMRendererTests(delegates);
|
||||
|
||||
// Bring in the URLRequest tests.
|
||||
extern void CreateURLRequestRendererTests(RenderDelegateSet& delegates);
|
||||
CreateURLRequestRendererTests(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
void ClientApp::RegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes) {
|
||||
// Bring in the scheme handler tests.
|
||||
extern void RegisterSchemeHandlerCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar);
|
||||
RegisterSchemeHandlerCustomSchemes(registrar);
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes);
|
||||
RegisterSchemeHandlerCustomSchemes(registrar, cookiable_schemes);
|
||||
|
||||
// Bring in the cookie tests.
|
||||
extern void RegisterCookieCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar);
|
||||
RegisterCookieCustomSchemes(registrar);
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes);
|
||||
RegisterCookieCustomSchemes(registrar, cookiable_schemes);
|
||||
|
||||
// Bring in the URLRequest tests.
|
||||
extern void RegisterURLRequestCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes);
|
||||
RegisterURLRequestCustomSchemes(registrar, cookiable_schemes);
|
||||
}
|
||||
|
@ -952,9 +952,11 @@ TEST(CookieTest, GetCookieManagerCustom) {
|
||||
EXPECT_TRUE(handler->got_cookie3_);
|
||||
}
|
||||
|
||||
// Called to register custom schemes.
|
||||
// Entry point for registering custom schemes.
|
||||
// Called from client_app_delegates.cc.
|
||||
void RegisterCookieCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes) {
|
||||
// Used by GetCookieManagerCustom test.
|
||||
registrar->AddCustomScheme("ccustom", true, false, false);
|
||||
}
|
||||
|
@ -4,91 +4,13 @@
|
||||
|
||||
#include "include/cef_request.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// Verify that CefRequest::HeaderMap objects are equal
|
||||
// If |allowExtras| is true then additional header fields will be allowed in
|
||||
// |map2|.
|
||||
void VerifyMapEqual(CefRequest::HeaderMap &map1,
|
||||
CefRequest::HeaderMap &map2,
|
||||
bool allowExtras) {
|
||||
if (!allowExtras)
|
||||
ASSERT_EQ(map1.size(), map2.size());
|
||||
CefRequest::HeaderMap::const_iterator it1, it2;
|
||||
|
||||
for (it1 = map1.begin(); it1 != map1.end(); ++it1) {
|
||||
it2 = map2.find(it1->first);
|
||||
ASSERT_TRUE(it2 != map2.end());
|
||||
ASSERT_EQ(it1->second, it2->second);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that CefPostDataElement objects are equal
|
||||
void VerifyPostDataElementEqual(CefRefPtr<CefPostDataElement> elem1,
|
||||
CefRefPtr<CefPostDataElement> elem2) {
|
||||
ASSERT_EQ(elem1->GetType(), elem2->GetType());
|
||||
switch (elem1->GetType()) {
|
||||
case PDE_TYPE_BYTES: {
|
||||
ASSERT_EQ(elem1->GetBytesCount(), elem2->GetBytesCount());
|
||||
size_t bytesCt = elem1->GetBytesCount();
|
||||
char* buff1 = new char[bytesCt];
|
||||
char* buff2 = new char[bytesCt];
|
||||
elem1->GetBytes(bytesCt, buff1);
|
||||
elem2->GetBytes(bytesCt, buff2);
|
||||
ASSERT_TRUE(!memcmp(buff1, buff2, bytesCt));
|
||||
delete [] buff1;
|
||||
delete [] buff2;
|
||||
} break;
|
||||
case PDE_TYPE_FILE:
|
||||
ASSERT_EQ(elem1->GetFile(), elem2->GetFile());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that CefPostData objects are equal
|
||||
void VerifyPostDataEqual(CefRefPtr<CefPostData> postData1,
|
||||
CefRefPtr<CefPostData> postData2) {
|
||||
ASSERT_TRUE(!(postData1.get()) == !(postData2.get()));
|
||||
ASSERT_EQ(postData1->GetElementCount(), postData2->GetElementCount());
|
||||
|
||||
CefPostData::ElementVector ev1, ev2;
|
||||
postData1->GetElements(ev1);
|
||||
postData1->GetElements(ev2);
|
||||
ASSERT_EQ(ev1.size(), ev2.size());
|
||||
|
||||
CefPostData::ElementVector::const_iterator it1 = ev1.begin();
|
||||
CefPostData::ElementVector::const_iterator it2 = ev2.begin();
|
||||
for (; it1 != ev1.end() && it2 != ev2.end(); ++it1, ++it2)
|
||||
VerifyPostDataElementEqual((*it1), (*it2));
|
||||
}
|
||||
|
||||
// Verify that CefRequest objects are equal
|
||||
// If |allowExtras| is true then additional header fields will be allowed in
|
||||
// |request2|.
|
||||
void VerifyRequestEqual(CefRefPtr<CefRequest> request1,
|
||||
CefRefPtr<CefRequest> request2,
|
||||
bool allowExtras) {
|
||||
ASSERT_EQ(request1->GetURL(), request2->GetURL());
|
||||
ASSERT_EQ(request1->GetMethod(), request2->GetMethod());
|
||||
|
||||
CefRequest::HeaderMap headers1, headers2;
|
||||
request1->GetHeaderMap(headers1);
|
||||
request2->GetHeaderMap(headers2);
|
||||
VerifyMapEqual(headers1, headers2, allowExtras);
|
||||
|
||||
VerifyPostDataEqual(request1->GetPostData(), request2->GetPostData());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Verify Set/Get methods for CefRequest, CefPostData and CefPostDataElement.
|
||||
TEST(RequestTest, SetGet) {
|
||||
// CefRequest CreateRequest
|
||||
CefRefPtr<CefRequest> request(CefRequest::CreateRequest());
|
||||
CefRefPtr<CefRequest> request(CefRequest::Create());
|
||||
ASSERT_TRUE(request.get() != NULL);
|
||||
|
||||
CefString url = "http://tests/run.html";
|
||||
@ -98,15 +20,13 @@ TEST(RequestTest, SetGet) {
|
||||
setHeaders.insert(std::make_pair("HeaderB", "ValueB"));
|
||||
|
||||
// CefPostData CreatePostData
|
||||
CefRefPtr<CefPostData> postData(CefPostData::CreatePostData());
|
||||
CefRefPtr<CefPostData> postData(CefPostData::Create());
|
||||
ASSERT_TRUE(postData.get() != NULL);
|
||||
|
||||
// CefPostDataElement CreatePostDataElement
|
||||
CefRefPtr<CefPostDataElement> element1(
|
||||
CefPostDataElement::CreatePostDataElement());
|
||||
CefRefPtr<CefPostDataElement> element1(CefPostDataElement::Create());
|
||||
ASSERT_TRUE(element1.get() != NULL);
|
||||
CefRefPtr<CefPostDataElement> element2(
|
||||
CefPostDataElement::CreatePostDataElement());
|
||||
CefRefPtr<CefPostDataElement> element2(CefPostDataElement::Create());
|
||||
ASSERT_TRUE(element2.get() != NULL);
|
||||
|
||||
// CefPostDataElement SetToFile
|
||||
@ -145,9 +65,9 @@ TEST(RequestTest, SetGet) {
|
||||
CefPostData::ElementVector::const_iterator it = elements.begin();
|
||||
for (size_t i = 0; it != elements.end(); ++it, ++i) {
|
||||
if (i == 0)
|
||||
VerifyPostDataElementEqual(element1, (*it).get());
|
||||
TestPostDataElementEqual(element1, (*it).get());
|
||||
else if (i == 1)
|
||||
VerifyPostDataElementEqual(element2, (*it).get());
|
||||
TestPostDataElementEqual(element2, (*it).get());
|
||||
}
|
||||
|
||||
// CefRequest SetURL
|
||||
@ -161,14 +81,14 @@ TEST(RequestTest, SetGet) {
|
||||
// CefRequest SetHeaderMap
|
||||
request->SetHeaderMap(setHeaders);
|
||||
request->GetHeaderMap(getHeaders);
|
||||
VerifyMapEqual(setHeaders, getHeaders, false);
|
||||
TestMapEqual(setHeaders, getHeaders, false);
|
||||
getHeaders.clear();
|
||||
|
||||
// CefRequest SetPostData
|
||||
request->SetPostData(postData);
|
||||
VerifyPostDataEqual(postData, request->GetPostData());
|
||||
TestPostDataEqual(postData, request->GetPostData());
|
||||
|
||||
request = CefRequest::CreateRequest();
|
||||
request = CefRequest::Create();
|
||||
ASSERT_TRUE(request.get() != NULL);
|
||||
|
||||
// CefRequest Set
|
||||
@ -176,15 +96,15 @@ TEST(RequestTest, SetGet) {
|
||||
ASSERT_EQ(url, request->GetURL());
|
||||
ASSERT_EQ(method, request->GetMethod());
|
||||
request->GetHeaderMap(getHeaders);
|
||||
VerifyMapEqual(setHeaders, getHeaders, false);
|
||||
TestMapEqual(setHeaders, getHeaders, false);
|
||||
getHeaders.clear();
|
||||
VerifyPostDataEqual(postData, request->GetPostData());
|
||||
TestPostDataEqual(postData, request->GetPostData());
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void CreateRequest(CefRefPtr<CefRequest>& request) {
|
||||
request = CefRequest::CreateRequest();
|
||||
request = CefRequest::Create();
|
||||
ASSERT_TRUE(request.get() != NULL);
|
||||
|
||||
request->SetURL("http://tests/run.html");
|
||||
@ -195,11 +115,11 @@ void CreateRequest(CefRefPtr<CefRequest>& request) {
|
||||
headers.insert(std::make_pair("HeaderB", "ValueB"));
|
||||
request->SetHeaderMap(headers);
|
||||
|
||||
CefRefPtr<CefPostData> postData(CefPostData::CreatePostData());
|
||||
CefRefPtr<CefPostData> postData(CefPostData::Create());
|
||||
ASSERT_TRUE(postData.get() != NULL);
|
||||
|
||||
CefRefPtr<CefPostDataElement> element1(
|
||||
CefPostDataElement::CreatePostDataElement());
|
||||
CefPostDataElement::Create());
|
||||
ASSERT_TRUE(element1.get() != NULL);
|
||||
char bytes[] = "Test Bytes";
|
||||
element1->SetToBytes(sizeof(bytes), bytes);
|
||||
@ -231,7 +151,7 @@ class RequestSendRecvTestHandler : public TestHandler {
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) OVERRIDE {
|
||||
// Verify that the request is the same
|
||||
VerifyRequestEqual(request_, request, true);
|
||||
TestRequestEqual(request_, request, true);
|
||||
|
||||
got_before_resource_load_.yes();
|
||||
|
||||
@ -243,7 +163,7 @@ class RequestSendRecvTestHandler : public TestHandler {
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) OVERRIDE {
|
||||
// Verify that the request is the same
|
||||
VerifyRequestEqual(request_, request, true);
|
||||
TestRequestEqual(request_, request, true);
|
||||
|
||||
got_resource_handler_.yes();
|
||||
|
||||
|
@ -10,6 +10,9 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/threading/thread.h"
|
||||
|
||||
// Include after base/bind.h to avoid name collisions with cef_tuple.h.
|
||||
#include "include/cef_runnable.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// Thread used to run the test suite.
|
||||
@ -25,13 +28,7 @@ class CefTestThread : public base::Thread {
|
||||
retval_ = test_suite_->Run();
|
||||
|
||||
// Quit the CEF message loop.
|
||||
class QuitTask : public CefTask {
|
||||
public:
|
||||
QuitTask() {}
|
||||
virtual void Execute(CefThreadId threadId) { CefQuitMessageLoop(); }
|
||||
IMPLEMENT_REFCOUNTING(QuitTask);
|
||||
};
|
||||
CefPostTask(TID_UI, new QuitTask());
|
||||
CefPostTask(TID_UI, NewCefRunnableFunction(CefQuitMessageLoop));
|
||||
}
|
||||
|
||||
int retval() { return retval_; }
|
||||
@ -41,6 +38,13 @@ class CefTestThread : public base::Thread {
|
||||
int retval_;
|
||||
};
|
||||
|
||||
// Called on the UI thread.
|
||||
void RunTests(CefTestThread* thread) {
|
||||
// Run the test suite on the test thread.
|
||||
thread->message_loop()->PostTask(FROM_HERE,
|
||||
base::Bind(&CefTestThread::RunTests, base::Unretained(thread)));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@ -88,9 +92,9 @@ int main(int argc, char* argv[]) {
|
||||
if (!thread->Start())
|
||||
return 1;
|
||||
|
||||
// Run the test suite on the test thread.
|
||||
thread->message_loop()->PostTask(FROM_HERE,
|
||||
base::Bind(&CefTestThread::RunTests, base::Unretained(thread.get())));
|
||||
// Start the tests from the UI thread so that any pending UI tasks get a
|
||||
// chance to execute first.
|
||||
CefPostTask(TID_UI, NewCefRunnableFunction(RunTests, thread.get()));
|
||||
|
||||
// Run the CEF message loop.
|
||||
CefRunMessageLoop();
|
||||
|
@ -948,9 +948,11 @@ TEST(SchemeHandlerTest, HttpXSSDifferentOriginWithDomain) {
|
||||
ClearTestSchemes();
|
||||
}
|
||||
|
||||
// Called to register custom schemes.
|
||||
// Entry point for registering custom schemes.
|
||||
// Called from client_app_delegates.cc.
|
||||
void RegisterSchemeHandlerCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes) {
|
||||
// Add a custom standard scheme.
|
||||
registrar->AddCustomScheme("customstd", true, false, false);
|
||||
// Ad a custom non-standard scheme.
|
||||
|
@ -6,6 +6,107 @@
|
||||
#include "tests/unittests/test_util.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
void TestMapEqual(CefRequest::HeaderMap& map1,
|
||||
CefRequest::HeaderMap& map2,
|
||||
bool allowExtras) {
|
||||
if (!allowExtras)
|
||||
EXPECT_EQ(map1.size(), map2.size());
|
||||
CefRequest::HeaderMap::const_iterator it1, it2;
|
||||
|
||||
for (it1 = map1.begin(); it1 != map1.end(); ++it1) {
|
||||
it2 = map2.find(it1->first);
|
||||
EXPECT_TRUE(it2 != map2.end());
|
||||
if (it2 != map2.end()) {
|
||||
EXPECT_STREQ(it1->second.ToString().c_str(),
|
||||
it2->second.ToString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestPostDataElementEqual(CefRefPtr<CefPostDataElement> elem1,
|
||||
CefRefPtr<CefPostDataElement> elem2) {
|
||||
EXPECT_TRUE(elem1.get());
|
||||
EXPECT_TRUE(elem2.get());
|
||||
|
||||
EXPECT_EQ(elem1->GetType(), elem2->GetType());
|
||||
switch (elem1->GetType()) {
|
||||
case PDE_TYPE_BYTES: {
|
||||
EXPECT_EQ(elem1->GetBytesCount(), elem2->GetBytesCount());
|
||||
size_t bytesCt = elem1->GetBytesCount();
|
||||
char* buff1 = new char[bytesCt];
|
||||
char* buff2 = new char[bytesCt];
|
||||
elem1->GetBytes(bytesCt, buff1);
|
||||
elem2->GetBytes(bytesCt, buff2);
|
||||
EXPECT_TRUE(!memcmp(buff1, buff2, bytesCt));
|
||||
delete [] buff1;
|
||||
delete [] buff2;
|
||||
} break;
|
||||
case PDE_TYPE_FILE:
|
||||
EXPECT_EQ(elem1->GetFile(), elem2->GetFile());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TestPostDataEqual(CefRefPtr<CefPostData> postData1,
|
||||
CefRefPtr<CefPostData> postData2) {
|
||||
EXPECT_TRUE(postData1.get());
|
||||
EXPECT_TRUE(postData2.get());
|
||||
|
||||
EXPECT_EQ(postData1->GetElementCount(), postData2->GetElementCount());
|
||||
|
||||
CefPostData::ElementVector ev1, ev2;
|
||||
postData1->GetElements(ev1);
|
||||
postData1->GetElements(ev2);
|
||||
ASSERT_EQ(ev1.size(), ev2.size());
|
||||
|
||||
CefPostData::ElementVector::const_iterator it1 = ev1.begin();
|
||||
CefPostData::ElementVector::const_iterator it2 = ev2.begin();
|
||||
for (; it1 != ev1.end() && it2 != ev2.end(); ++it1, ++it2)
|
||||
TestPostDataElementEqual((*it1), (*it2));
|
||||
}
|
||||
|
||||
void TestRequestEqual(CefRefPtr<CefRequest> request1,
|
||||
CefRefPtr<CefRequest> request2,
|
||||
bool allowExtras) {
|
||||
EXPECT_TRUE(request1.get());
|
||||
EXPECT_TRUE(request2.get());
|
||||
|
||||
EXPECT_STREQ(request1->GetURL().ToString().c_str(),
|
||||
request2->GetURL().ToString().c_str());
|
||||
EXPECT_STREQ(request1->GetMethod().ToString().c_str(),
|
||||
request2->GetMethod().ToString().c_str());
|
||||
|
||||
CefRequest::HeaderMap headers1, headers2;
|
||||
request1->GetHeaderMap(headers1);
|
||||
request2->GetHeaderMap(headers2);
|
||||
TestMapEqual(headers1, headers2, allowExtras);
|
||||
|
||||
CefRefPtr<CefPostData> postData1 = request1->GetPostData();
|
||||
CefRefPtr<CefPostData> postData2 = request2->GetPostData();
|
||||
EXPECT_EQ(!!(postData1.get()), !!(postData2.get()));
|
||||
if (postData1.get() && postData2.get())
|
||||
TestPostDataEqual(postData1, postData2);
|
||||
}
|
||||
|
||||
void TestResponseEqual(CefRefPtr<CefResponse> response1,
|
||||
CefRefPtr<CefResponse> response2,
|
||||
bool allowExtras) {
|
||||
EXPECT_TRUE(response1.get());
|
||||
EXPECT_TRUE(response2.get());
|
||||
|
||||
EXPECT_EQ(response1->GetStatus(), response2->GetStatus());
|
||||
EXPECT_STREQ(response1->GetStatusText().ToString().c_str(),
|
||||
response2->GetStatusText().ToString().c_str());
|
||||
EXPECT_STREQ(response1->GetMimeType().ToString().c_str(),
|
||||
response2->GetMimeType().ToString().c_str());
|
||||
|
||||
CefRequest::HeaderMap headers1, headers2;
|
||||
response1->GetHeaderMap(headers1);
|
||||
response2->GetHeaderMap(headers2);
|
||||
TestMapEqual(headers1, headers2, allowExtras);
|
||||
}
|
||||
|
||||
void TestBinaryEqual(CefRefPtr<CefBinaryValue> val1,
|
||||
CefRefPtr<CefBinaryValue> val2) {
|
||||
|
@ -7,8 +7,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_process_message.h"
|
||||
#include "include/cef_request.h"
|
||||
#include "include/cef_response.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
// Test that CefRequest::HeaderMap objects are equal
|
||||
// If |allowExtras| is true then additional header fields will be allowed in
|
||||
// |map2|.
|
||||
void TestMapEqual(CefRequest::HeaderMap& map1,
|
||||
CefRequest::HeaderMap& map2,
|
||||
bool allowExtras);
|
||||
|
||||
// Test that CefPostDataElement objects are equal
|
||||
void TestPostDataElementEqual(CefRefPtr<CefPostDataElement> elem1,
|
||||
CefRefPtr<CefPostDataElement> elem2);
|
||||
|
||||
// Test that CefPostData objects are equal
|
||||
void TestPostDataEqual(CefRefPtr<CefPostData> postData1,
|
||||
CefRefPtr<CefPostData> postData2);
|
||||
|
||||
// Test that CefRequest objects are equal
|
||||
// If |allowExtras| is true then additional header fields will be allowed in
|
||||
// |request2|.
|
||||
void TestRequestEqual(CefRefPtr<CefRequest> request1,
|
||||
CefRefPtr<CefRequest> request2,
|
||||
bool allowExtras);
|
||||
|
||||
// Test that CefResponse objects are equal
|
||||
// If |allowExtras| is true then additional header fields will be allowed in
|
||||
// |response2|.
|
||||
void TestResponseEqual(CefRefPtr<CefResponse> response1,
|
||||
CefRefPtr<CefResponse> response2,
|
||||
bool allowExtras);
|
||||
|
||||
// Test if two binary values are equal.
|
||||
void TestBinaryEqual(CefRefPtr<CefBinaryValue> val1,
|
||||
CefRefPtr<CefBinaryValue> val2);
|
||||
|
1030
tests/unittests/urlrequest_unittest.cc
Normal file
1030
tests/unittests/urlrequest_unittest.cc
Normal file
File diff suppressed because it is too large
Load Diff
@ -1495,8 +1495,7 @@ class V8RendererTest : public ClientApp::RenderDelegate {
|
||||
// Browser side.
|
||||
class V8TestHandler : public TestHandler {
|
||||
public:
|
||||
explicit V8TestHandler(V8TestMode test_mode,
|
||||
const char* test_url)
|
||||
V8TestHandler(V8TestMode test_mode, const char* test_url)
|
||||
: test_mode_(test_mode),
|
||||
test_url_(test_url) {
|
||||
}
|
||||
|
Reference in New Issue
Block a user