mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Add download handling support via new CefDownloadHandler and CefDownloadItem interfaces (issue #516).
- Fix setting of CefKeyEvent.focus_on_editable_field when the underlying RenderViewHost changes. - Fix potential crash if URLRequest objects are still in-progress upon shutdown. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@715 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
4
cef.gyp
4
cef.gyp
@ -770,6 +770,8 @@
|
|||||||
'libcef/browser/devtools_delegate.h',
|
'libcef/browser/devtools_delegate.h',
|
||||||
'libcef/browser/devtools_scheme_handler.cc',
|
'libcef/browser/devtools_scheme_handler.cc',
|
||||||
'libcef/browser/devtools_scheme_handler.h',
|
'libcef/browser/devtools_scheme_handler.h',
|
||||||
|
'libcef/browser/download_item_impl.cc',
|
||||||
|
'libcef/browser/download_item_impl.h',
|
||||||
'libcef/browser/download_manager_delegate.cc',
|
'libcef/browser/download_manager_delegate.cc',
|
||||||
'libcef/browser/download_manager_delegate.h',
|
'libcef/browser/download_manager_delegate.h',
|
||||||
'libcef/browser/frame_host_impl.cc',
|
'libcef/browser/frame_host_impl.cc',
|
||||||
@ -804,6 +806,8 @@
|
|||||||
'libcef/browser/url_request_context_getter.h',
|
'libcef/browser/url_request_context_getter.h',
|
||||||
'libcef/browser/url_request_context_getter_proxy.cc',
|
'libcef/browser/url_request_context_getter_proxy.cc',
|
||||||
'libcef/browser/url_request_context_getter_proxy.h',
|
'libcef/browser/url_request_context_getter_proxy.h',
|
||||||
|
'libcef/browser/url_request_context_proxy.cc',
|
||||||
|
'libcef/browser/url_request_context_proxy.h',
|
||||||
'libcef/browser/url_request_interceptor.cc',
|
'libcef/browser/url_request_interceptor.cc',
|
||||||
'libcef/browser/url_request_interceptor.h',
|
'libcef/browser/url_request_interceptor.h',
|
||||||
'libcef/browser/web_plugin_impl.cc',
|
'libcef/browser/web_plugin_impl.cc',
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
'include/cef_cookie.h',
|
'include/cef_cookie.h',
|
||||||
'include/cef_display_handler.h',
|
'include/cef_display_handler.h',
|
||||||
'include/cef_dom.h',
|
'include/cef_dom.h',
|
||||||
|
'include/cef_download_handler.h',
|
||||||
|
'include/cef_download_item.h',
|
||||||
'include/cef_focus_handler.h',
|
'include/cef_focus_handler.h',
|
||||||
'include/cef_frame.h',
|
'include/cef_frame.h',
|
||||||
'include/cef_geolocation_handler.h',
|
'include/cef_geolocation_handler.h',
|
||||||
@ -64,6 +66,8 @@
|
|||||||
'include/capi/cef_cookie_capi.h',
|
'include/capi/cef_cookie_capi.h',
|
||||||
'include/capi/cef_display_handler_capi.h',
|
'include/capi/cef_display_handler_capi.h',
|
||||||
'include/capi/cef_dom_capi.h',
|
'include/capi/cef_dom_capi.h',
|
||||||
|
'include/capi/cef_download_handler_capi.h',
|
||||||
|
'include/capi/cef_download_item_capi.h',
|
||||||
'include/capi/cef_focus_handler_capi.h',
|
'include/capi/cef_focus_handler_capi.h',
|
||||||
'include/capi/cef_frame_capi.h',
|
'include/capi/cef_frame_capi.h',
|
||||||
'include/capi/cef_geolocation_handler_capi.h',
|
'include/capi/cef_geolocation_handler_capi.h',
|
||||||
@ -100,6 +104,8 @@
|
|||||||
'libcef_dll/ctocpp/app_ctocpp.h',
|
'libcef_dll/ctocpp/app_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/auth_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/auth_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/auth_callback_cpptoc.h',
|
'libcef_dll/cpptoc/auth_callback_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/before_download_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/before_download_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/binary_value_cpptoc.cc',
|
'libcef_dll/cpptoc/binary_value_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/binary_value_cpptoc.h',
|
'libcef_dll/cpptoc/binary_value_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/browser_cpptoc.cc',
|
'libcef_dll/cpptoc/browser_cpptoc.cc',
|
||||||
@ -136,6 +142,12 @@
|
|||||||
'libcef_dll/cpptoc/dictionary_value_cpptoc.h',
|
'libcef_dll/cpptoc/dictionary_value_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/display_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/display_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/display_handler_ctocpp.h',
|
'libcef_dll/ctocpp/display_handler_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/download_handler_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/download_handler_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/download_item_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/download_item_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/download_item_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/download_item_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/focus_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/focus_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
|
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/frame_cpptoc.cc',
|
'libcef_dll/cpptoc/frame_cpptoc.cc',
|
||||||
@ -222,6 +234,8 @@
|
|||||||
'libcef_dll/cpptoc/app_cpptoc.h',
|
'libcef_dll/cpptoc/app_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/auth_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/auth_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/auth_callback_ctocpp.h',
|
'libcef_dll/ctocpp/auth_callback_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/before_download_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/before_download_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/binary_value_ctocpp.cc',
|
'libcef_dll/ctocpp/binary_value_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/binary_value_ctocpp.h',
|
'libcef_dll/ctocpp/binary_value_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/browser_ctocpp.cc',
|
'libcef_dll/ctocpp/browser_ctocpp.cc',
|
||||||
@ -258,6 +272,12 @@
|
|||||||
'libcef_dll/ctocpp/dictionary_value_ctocpp.h',
|
'libcef_dll/ctocpp/dictionary_value_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/display_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/display_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/display_handler_cpptoc.h',
|
'libcef_dll/cpptoc/display_handler_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/download_handler_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/download_handler_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/download_item_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/download_item_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/download_item_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/download_item_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/focus_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/focus_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
|
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/frame_ctocpp.cc',
|
'libcef_dll/ctocpp/frame_ctocpp.cc',
|
||||||
|
@ -67,6 +67,13 @@ typedef struct _cef_client_t {
|
|||||||
struct _cef_display_handler_t* (CEF_CALLBACK *get_display_handler)(
|
struct _cef_display_handler_t* (CEF_CALLBACK *get_display_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the handler for download events. If no handler is returned downloads
|
||||||
|
// will not be allowed.
|
||||||
|
///
|
||||||
|
struct _cef_download_handler_t* (CEF_CALLBACK *get_download_handler)(
|
||||||
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for focus events.
|
// Return the handler for focus events.
|
||||||
///
|
///
|
||||||
|
124
include/capi/cef_download_handler_capi.h
Normal file
124
include/capi/cef_download_handler_capi.h
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
// 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_DOWNLOAD_HANDLER_CAPI_H_
|
||||||
|
#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "include/capi/cef_base_capi.h"
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback structure used to asynchronously continue a download.
|
||||||
|
///
|
||||||
|
typedef struct _cef_before_download_callback_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Call to continue the download. Set |download_path| to the full file path
|
||||||
|
// for the download including the file name or leave blank to use the
|
||||||
|
// suggested name and the default temp directory. Set |show_dialog| to true
|
||||||
|
// (1) if you do wish to show the default "Save As" dialog.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *cont)(struct _cef_before_download_callback_t* self,
|
||||||
|
const cef_string_t* download_path, int show_dialog);
|
||||||
|
} cef_before_download_callback_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback structure used to asynchronously cancel a download.
|
||||||
|
///
|
||||||
|
typedef struct _cef_download_item_callback_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Call to cancel the download.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *cancel)(struct _cef_download_item_callback_t* self);
|
||||||
|
} cef_download_item_callback_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Structure used to handle file downloads. The functions of this structure will
|
||||||
|
// called on the browser process UI thread.
|
||||||
|
///
|
||||||
|
typedef struct _cef_download_handler_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called before a download begins. |suggested_name| is the suggested name for
|
||||||
|
// the download file. By default the download will be canceled. Execute
|
||||||
|
// |callback| either asynchronously or in this function to continue the
|
||||||
|
// download if desired. Do not keep a reference to |download_item| outside of
|
||||||
|
// this function.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *on_before_download)(struct _cef_download_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
struct _cef_download_item_t* download_item,
|
||||||
|
const cef_string_t* suggested_name,
|
||||||
|
struct _cef_before_download_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called when a download's status or progress information has been updated.
|
||||||
|
// Execute |callback| either asynchronously or in this function to cancel the
|
||||||
|
// download if desired. Do not keep a reference to |download_item| outside of
|
||||||
|
// this function.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *on_download_updated)(struct _cef_download_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
struct _cef_download_item_t* download_item,
|
||||||
|
struct _cef_download_item_callback_t* callback);
|
||||||
|
} cef_download_handler_t;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
162
include/capi/cef_download_item_capi.h
Normal file
162
include/capi/cef_download_item_capi.h
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
// 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_DOWNLOAD_ITEM_CAPI_H_
|
||||||
|
#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "include/capi/cef_base_capi.h"
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Structure used to represent a download item.
|
||||||
|
///
|
||||||
|
typedef struct _cef_download_item_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if this object is valid. Do not call any other functions
|
||||||
|
// if this function returns false (0).
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_valid)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if the download is in progress.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_in_progress)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if the download is complete.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_complete)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if the download has been canceled or interrupted.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_canceled)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns a simple speed estimate in bytes/s.
|
||||||
|
///
|
||||||
|
int64 (CEF_CALLBACK *get_current_speed)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the rough percent complete or -1 if the receive total size is
|
||||||
|
// unknown.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *get_percent_complete)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the total number of bytes.
|
||||||
|
///
|
||||||
|
int64 (CEF_CALLBACK *get_total_bytes)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the number of received bytes.
|
||||||
|
///
|
||||||
|
int64 (CEF_CALLBACK *get_received_bytes)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the time that the download started.
|
||||||
|
///
|
||||||
|
cef_time_t (CEF_CALLBACK *get_start_time)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the time that the download ended.
|
||||||
|
///
|
||||||
|
cef_time_t (CEF_CALLBACK *get_end_time)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the full path to the downloaded or downloading file.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_full_path)(
|
||||||
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the unique identifier for this download.
|
||||||
|
///
|
||||||
|
int32 (CEF_CALLBACK *get_id)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the URL.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_url)(
|
||||||
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the suggested file name.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_suggested_file_name)(
|
||||||
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the content disposition.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_content_disposition)(
|
||||||
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the mime type.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_mime_type)(
|
||||||
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the referrer character set.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_referrer_charset)(
|
||||||
|
struct _cef_download_item_t* self);
|
||||||
|
} cef_download_item_t;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
|
@ -41,6 +41,7 @@
|
|||||||
#include "include/cef_base.h"
|
#include "include/cef_base.h"
|
||||||
#include "include/cef_context_menu_handler.h"
|
#include "include/cef_context_menu_handler.h"
|
||||||
#include "include/cef_display_handler.h"
|
#include "include/cef_display_handler.h"
|
||||||
|
#include "include/cef_download_handler.h"
|
||||||
#include "include/cef_focus_handler.h"
|
#include "include/cef_focus_handler.h"
|
||||||
#include "include/cef_geolocation_handler.h"
|
#include "include/cef_geolocation_handler.h"
|
||||||
#include "include/cef_jsdialog_handler.h"
|
#include "include/cef_jsdialog_handler.h"
|
||||||
@ -73,6 +74,15 @@ class CefClient : public virtual CefBase {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the handler for download events. If no handler is returned downloads
|
||||||
|
// will not be allowed.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for focus events.
|
// Return the handler for focus events.
|
||||||
///
|
///
|
||||||
|
111
include/cef_download_handler.h
Normal file
111
include/cef_download_handler.h
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// 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_DOWNLOAD_HANDLER_H_
|
||||||
|
#define CEF_INCLUDE_CEF_DOWNLOAD_HANDLER_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/cef_base.h"
|
||||||
|
#include "include/cef_browser.h"
|
||||||
|
#include "include/cef_download_item.h"
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback interface used to asynchronously continue a download.
|
||||||
|
///
|
||||||
|
/*--cef(source=library)--*/
|
||||||
|
class CefBeforeDownloadCallback : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Call to continue the download. Set |download_path| to the full file path
|
||||||
|
// for the download including the file name or leave blank to use the
|
||||||
|
// suggested name and the default temp directory. Set |show_dialog| to true
|
||||||
|
// if you do wish to show the default "Save As" dialog.
|
||||||
|
///
|
||||||
|
/*--cef(capi_name=cont)--*/
|
||||||
|
virtual void Continue(const CefString& download_path, bool show_dialog) =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback interface used to asynchronously cancel a download.
|
||||||
|
///
|
||||||
|
/*--cef(source=library)--*/
|
||||||
|
class CefDownloadItemCallback : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Call to cancel the download.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void Cancel() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Class used to handle file downloads. The methods of this class will called
|
||||||
|
// on the browser process UI thread.
|
||||||
|
///
|
||||||
|
/*--cef(source=client)--*/
|
||||||
|
class CefDownloadHandler : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Called before a download begins. |suggested_name| is the suggested name for
|
||||||
|
// the download file. By default the download will be canceled. Execute
|
||||||
|
// |callback| either asynchronously or in this method to continue the download
|
||||||
|
// if desired. Do not keep a reference to |download_item| outside of this
|
||||||
|
// method.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void OnBeforeDownload(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item,
|
||||||
|
const CefString& suggested_name,
|
||||||
|
CefRefPtr<CefBeforeDownloadCallback> callback) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called when a download's status or progress information has been updated.
|
||||||
|
// Execute |callback| either asynchronously or in this method to cancel the
|
||||||
|
// download if desired. Do not keep a reference to |download_item| outside of
|
||||||
|
// this method.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void OnDownloadUpdated(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item,
|
||||||
|
CefRefPtr<CefDownloadItemCallback> callback) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CEF_DOWNLOAD_HANDLER_H_
|
154
include/cef_download_item.h
Normal file
154
include/cef_download_item.h
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
// 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_DOWNLOAD_ITEM_H_
|
||||||
|
#define CEF_INCLUDE_CEF_DOWNLOAD_ITEM_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/cef_base.h"
|
||||||
|
|
||||||
|
///
|
||||||
|
// Class used to represent a download item.
|
||||||
|
///
|
||||||
|
/*--cef(source=library)--*/
|
||||||
|
class CefDownloadItem : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Returns true if this object is valid. Do not call any other methods if this
|
||||||
|
// function returns false.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool IsValid() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true if the download is in progress.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool IsInProgress() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true if the download is complete.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool IsComplete() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true if the download has been canceled or interrupted.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool IsCanceled() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns a simple speed estimate in bytes/s.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual int64 GetCurrentSpeed() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the rough percent complete or -1 if the receive total size is
|
||||||
|
// unknown.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual int GetPercentComplete() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the total number of bytes.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual int64 GetTotalBytes() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the number of received bytes.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual int64 GetReceivedBytes() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the time that the download started.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefTime GetStartTime() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the time that the download ended.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefTime GetEndTime() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the full path to the downloaded or downloading file.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefString GetFullPath() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the unique identifier for this download.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual int32 GetId() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the URL.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefString GetURL() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the suggested file name.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefString GetSuggestedFileName() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the content disposition.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefString GetContentDisposition() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the mime type.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefString GetMimeType() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the referrer character set.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefString GetReferrerCharset() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CEF_DOWNLOAD_ITEM_H_
|
@ -181,12 +181,14 @@ CefBrowserContext::CefBrowserContext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CefBrowserContext::~CefBrowserContext() {
|
CefBrowserContext::~CefBrowserContext() {
|
||||||
if (download_manager_.get())
|
// Clear the download manager delegate here because otherwise we'll crash
|
||||||
download_manager_->Shutdown();
|
// when it's accessed from the content::BrowserContext destructor.
|
||||||
|
if (download_manager_delegate_.get())
|
||||||
|
BrowserContext::GetDownloadManager(this)->SetDelegate(NULL);
|
||||||
|
|
||||||
if (resource_context_.get()) {
|
if (resource_context_.get()) {
|
||||||
BrowserThread::DeleteSoon(
|
BrowserThread::DeleteSoon(
|
||||||
BrowserThread::IO, FROM_HERE, resource_context_.release());
|
BrowserThread::IO, FROM_HERE, resource_context_.release());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +202,8 @@ bool CefBrowserContext::IsOffTheRecord() const {
|
|||||||
|
|
||||||
content::DownloadManagerDelegate*
|
content::DownloadManagerDelegate*
|
||||||
CefBrowserContext::GetDownloadManagerDelegate() {
|
CefBrowserContext::GetDownloadManagerDelegate() {
|
||||||
|
DCHECK(!download_manager_delegate_.get());
|
||||||
|
|
||||||
download_manager_delegate_ = new CefDownloadManagerDelegate();
|
download_manager_delegate_ = new CefDownloadManagerDelegate();
|
||||||
return download_manager_delegate_.get();
|
return download_manager_delegate_.get();
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class DownloadManagerDelegate;
|
class DownloadManagerDelegate;
|
||||||
class ResourceContext;
|
|
||||||
class SpeechRecognitionPreferences;
|
class SpeechRecognitionPreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CefDownloadManagerDelegate;
|
class CefDownloadManagerDelegate;
|
||||||
|
class CefResourceContext;
|
||||||
|
|
||||||
class CefBrowserContext : public content::BrowserContext {
|
class CefBrowserContext : public content::BrowserContext {
|
||||||
public:
|
public:
|
||||||
@ -43,9 +43,8 @@ class CefBrowserContext : public content::BrowserContext {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
scoped_ptr<content::ResourceContext> resource_context_;
|
scoped_ptr<CefResourceContext> resource_context_;
|
||||||
scoped_refptr<CefDownloadManagerDelegate> download_manager_delegate_;
|
scoped_refptr<CefDownloadManagerDelegate> download_manager_delegate_;
|
||||||
scoped_refptr<content::DownloadManager> download_manager_;
|
|
||||||
scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
|
scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
|
||||||
scoped_refptr<content::GeolocationPermissionContext>
|
scoped_refptr<content::GeolocationPermissionContext>
|
||||||
geolocation_permission_context_;
|
geolocation_permission_context_;
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "libcef/browser/devtools_delegate.h"
|
#include "libcef/browser/devtools_delegate.h"
|
||||||
#include "libcef/browser/navigate_params.h"
|
#include "libcef/browser/navigate_params.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
|
#include "libcef/browser/url_request_context_getter.h"
|
||||||
|
#include "libcef/browser/url_request_context_getter_proxy.h"
|
||||||
#include "libcef/common/cef_messages.h"
|
#include "libcef/common/cef_messages.h"
|
||||||
#include "libcef/common/http_header_utils.h"
|
#include "libcef/common/http_header_utils.h"
|
||||||
#include "libcef/common/main_delegate.h"
|
#include "libcef/common/main_delegate.h"
|
||||||
@ -600,7 +602,8 @@ net::URLRequestContextGetter* CefBrowserHostImpl::GetRequestContext() {
|
|||||||
if (!request_context_proxy_) {
|
if (!request_context_proxy_) {
|
||||||
request_context_proxy_ =
|
request_context_proxy_ =
|
||||||
new CefURLRequestContextGetterProxy(this,
|
new CefURLRequestContextGetterProxy(this,
|
||||||
_Context->browser_context()->GetRequestContext());
|
static_cast<CefURLRequestContextGetter*>(
|
||||||
|
_Context->browser_context()->GetRequestContext()));
|
||||||
}
|
}
|
||||||
return request_context_proxy_.get();
|
return request_context_proxy_.get();
|
||||||
}
|
}
|
||||||
@ -1128,19 +1131,13 @@ void CefBrowserHostImpl::RequestMediaAccessPermission(
|
|||||||
|
|
||||||
void CefBrowserHostImpl::RenderViewCreated(
|
void CefBrowserHostImpl::RenderViewCreated(
|
||||||
content::RenderViewHost* render_view_host) {
|
content::RenderViewHost* render_view_host) {
|
||||||
base::AutoLock lock_scope(state_lock_);
|
SetRenderViewHost(render_view_host);
|
||||||
|
}
|
||||||
|
|
||||||
render_view_id_ = render_view_host->GetRoutingID();
|
void CefBrowserHostImpl::RenderViewDeleted(
|
||||||
render_process_id_ = render_view_host->GetProcess()->GetID();
|
content::RenderViewHost* render_view_host) {
|
||||||
|
registrar_->Remove(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||||
// Update the DevTools URLs, if any.
|
content::Source<content::RenderViewHost>(render_view_host));
|
||||||
CefDevToolsDelegate* devtools_delegate = _Context->devtools_delegate();
|
|
||||||
if (devtools_delegate) {
|
|
||||||
devtools_url_http_ = devtools_delegate->GetDevToolsURL(render_view_host,
|
|
||||||
true);
|
|
||||||
devtools_url_chrome_ = devtools_delegate->GetDevToolsURL(render_view_host,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostImpl::RenderViewReady() {
|
void CefBrowserHostImpl::RenderViewReady() {
|
||||||
@ -1368,8 +1365,8 @@ CefBrowserHostImpl::CefBrowserHostImpl(const CefWindowInfo& window_info,
|
|||||||
settings_(settings),
|
settings_(settings),
|
||||||
client_(client),
|
client_(client),
|
||||||
opener_(opener),
|
opener_(opener),
|
||||||
render_process_id_(web_contents->GetRenderProcessHost()->GetID()),
|
render_process_id_(0),
|
||||||
render_view_id_(routing_id()),
|
render_view_id_(0),
|
||||||
unique_id_(0),
|
unique_id_(0),
|
||||||
received_page_title_(false),
|
received_page_title_(false),
|
||||||
is_loading_(false),
|
is_loading_(false),
|
||||||
@ -1387,21 +1384,35 @@ CefBrowserHostImpl::CefBrowserHostImpl(const CefWindowInfo& window_info,
|
|||||||
registrar_.reset(new content::NotificationRegistrar);
|
registrar_.reset(new content::NotificationRegistrar);
|
||||||
registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
|
registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
|
||||||
content::Source<content::WebContents>(web_contents));
|
content::Source<content::WebContents>(web_contents));
|
||||||
registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
|
||||||
content::Source<content::RenderViewHost>(
|
|
||||||
web_contents->GetRenderViewHost()));
|
|
||||||
response_manager_.reset(new CefResponseManager);
|
response_manager_.reset(new CefResponseManager);
|
||||||
|
|
||||||
placeholder_frame_ =
|
placeholder_frame_ =
|
||||||
new CefFrameHostImpl(this, CefFrameHostImpl::kInvalidFrameId, true);
|
new CefFrameHostImpl(this, CefFrameHostImpl::kInvalidFrameId, true);
|
||||||
|
|
||||||
// Retrieve the DevTools URLs, if any.
|
SetRenderViewHost(web_contents->GetRenderViewHost());
|
||||||
CefDevToolsDelegate* devtools_delegate = _Context->devtools_delegate();
|
}
|
||||||
if (devtools_delegate) {
|
|
||||||
devtools_url_http_ = devtools_delegate->GetDevToolsURL(
|
void CefBrowserHostImpl::SetRenderViewHost(content::RenderViewHost* rvh) {
|
||||||
web_contents->GetRenderViewHost(), true);
|
{
|
||||||
devtools_url_chrome_ = devtools_delegate->GetDevToolsURL(
|
base::AutoLock lock_scope(state_lock_);
|
||||||
web_contents->GetRenderViewHost(), false);
|
|
||||||
|
render_view_id_ = rvh->GetRoutingID();
|
||||||
|
render_process_id_ = rvh->GetProcess()->GetID();
|
||||||
|
|
||||||
|
// Update the DevTools URLs, if any.
|
||||||
|
CefDevToolsDelegate* devtools_delegate = _Context->devtools_delegate();
|
||||||
|
if (devtools_delegate) {
|
||||||
|
devtools_url_http_ = devtools_delegate->GetDevToolsURL(rvh, true);
|
||||||
|
devtools_url_chrome_ = devtools_delegate->GetDevToolsURL(rvh, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!registrar_->IsRegistered(
|
||||||
|
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||||
|
content::Source<content::RenderViewHost>(rvh))) {
|
||||||
|
registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||||
|
content::Source<content::RenderViewHost>(rvh));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "libcef/browser/frame_host_impl.h"
|
#include "libcef/browser/frame_host_impl.h"
|
||||||
#include "libcef/browser/javascript_dialog_creator.h"
|
#include "libcef/browser/javascript_dialog_creator.h"
|
||||||
#include "libcef/browser/menu_creator.h"
|
#include "libcef/browser/menu_creator.h"
|
||||||
#include "libcef/browser/url_request_context_getter_proxy.h"
|
|
||||||
#include "libcef/common/response_manager.h"
|
#include "libcef/common/response_manager.h"
|
||||||
|
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
@ -29,6 +28,7 @@
|
|||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
|
#include "net/url_request/url_request_context_getter.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
struct NativeWebKeyboardEvent;
|
struct NativeWebKeyboardEvent;
|
||||||
@ -239,8 +239,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
|||||||
const content::MediaResponseCallback& callback) OVERRIDE;
|
const content::MediaResponseCallback& callback) OVERRIDE;
|
||||||
|
|
||||||
// content::WebContentsObserver methods.
|
// content::WebContentsObserver methods.
|
||||||
virtual void RenderViewCreated(content::RenderViewHost* render_view_host)
|
virtual void RenderViewCreated(
|
||||||
OVERRIDE;
|
content::RenderViewHost* render_view_host) OVERRIDE;
|
||||||
|
virtual void RenderViewDeleted(
|
||||||
|
content::RenderViewHost* render_view_host) OVERRIDE;
|
||||||
virtual void RenderViewReady() OVERRIDE;
|
virtual void RenderViewReady() OVERRIDE;
|
||||||
virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
|
virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
|
||||||
virtual void DidCommitProvisionalLoadForFrame(
|
virtual void DidCommitProvisionalLoadForFrame(
|
||||||
@ -288,6 +290,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
|||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
CefWindowHandle opener);
|
CefWindowHandle opener);
|
||||||
|
|
||||||
|
// Initialize settings based on the specified RenderViewHost.
|
||||||
|
void SetRenderViewHost(content::RenderViewHost* rvh);
|
||||||
|
|
||||||
// Updates and returns an existing frame or creates a new frame. Pass
|
// Updates and returns an existing frame or creates a new frame. Pass
|
||||||
// CefFrameHostImpl::kUnspecifiedFrameId for |parent_frame_id| if unknown.
|
// CefFrameHostImpl::kUnspecifiedFrameId for |parent_frame_id| if unknown.
|
||||||
CefRefPtr<CefFrame> GetOrCreateFrame(int64 frame_id,
|
CefRefPtr<CefFrame> GetOrCreateFrame(int64 frame_id,
|
||||||
@ -404,7 +409,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
|||||||
scoped_ptr<content::NotificationRegistrar> registrar_;
|
scoped_ptr<content::NotificationRegistrar> registrar_;
|
||||||
|
|
||||||
// Used for proxying cookie requests.
|
// Used for proxying cookie requests.
|
||||||
scoped_refptr<CefURLRequestContextGetterProxy> request_context_proxy_;
|
scoped_refptr<net::URLRequestContextGetter> request_context_proxy_;
|
||||||
|
|
||||||
// Manages response registrations.
|
// Manages response registrations.
|
||||||
scoped_ptr<CefResponseManager> response_manager_;
|
scoped_ptr<CefResponseManager> response_manager_;
|
||||||
|
@ -54,18 +54,19 @@ void CefBrowserMainParts::PreMainMessageLoopStart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CefBrowserMainParts::PreCreateThreads() {
|
int CefBrowserMainParts::PreCreateThreads() {
|
||||||
|
PlatformInitialize();
|
||||||
|
net::NetModule::SetResourceProvider(&ResourceProvider);
|
||||||
|
|
||||||
|
// Initialize the GpuDataManager before IO access restrictions are applied and
|
||||||
|
// before the IO thread is started.
|
||||||
|
content::GpuDataManager::GetInstance();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserMainParts::PreMainMessageLoopRun() {
|
void CefBrowserMainParts::PreMainMessageLoopRun() {
|
||||||
browser_context_.reset(new CefBrowserContext());
|
browser_context_.reset(new CefBrowserContext());
|
||||||
|
|
||||||
PlatformInitialize();
|
|
||||||
net::NetModule::SetResourceProvider(&ResourceProvider);
|
|
||||||
|
|
||||||
// Initialize the GpuDataManager before IO access restrictions are applied.
|
|
||||||
content::GpuDataManager::GetInstance();
|
|
||||||
|
|
||||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||||
if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
|
if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
|
||||||
std::string port_str =
|
std::string port_str =
|
||||||
@ -82,13 +83,11 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserMainParts::PostMainMessageLoopRun() {
|
void CefBrowserMainParts::PostMainMessageLoopRun() {
|
||||||
PlatformCleanup();
|
|
||||||
|
|
||||||
if (devtools_delegate_)
|
if (devtools_delegate_)
|
||||||
devtools_delegate_->Stop();
|
devtools_delegate_->Stop();
|
||||||
browser_context_.reset();
|
browser_context_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
void CefBrowserMainParts::PostDestroyThreads() {
|
||||||
return false;
|
PlatformCleanup();
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ class CefBrowserMainParts : public content::BrowserMainParts {
|
|||||||
virtual void PreMainMessageLoopStart() OVERRIDE;
|
virtual void PreMainMessageLoopStart() OVERRIDE;
|
||||||
virtual int PreCreateThreads() OVERRIDE;
|
virtual int PreCreateThreads() OVERRIDE;
|
||||||
virtual void PreMainMessageLoopRun() OVERRIDE;
|
virtual void PreMainMessageLoopRun() OVERRIDE;
|
||||||
virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
|
|
||||||
virtual void PostMainMessageLoopRun() OVERRIDE;
|
virtual void PostMainMessageLoopRun() OVERRIDE;
|
||||||
|
virtual void PostDestroyThreads() OVERRIDE;
|
||||||
|
|
||||||
CefBrowserContext* browser_context() const { return browser_context_.get(); }
|
CefBrowserContext* browser_context() const { return browser_context_.get(); }
|
||||||
CefDevToolsDelegate* devtools_delegate() const { return devtools_delegate_; }
|
CefDevToolsDelegate* devtools_delegate() const { return devtools_delegate_; }
|
||||||
|
107
libcef/browser/download_item_impl.cc
Normal file
107
libcef/browser/download_item_impl.cc
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
// 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/download_item_impl.h"
|
||||||
|
|
||||||
|
#include "libcef/common/time_util.h"
|
||||||
|
|
||||||
|
#include "content/public/browser/download_item.h"
|
||||||
|
#include "googleurl/src/gurl.h"
|
||||||
|
|
||||||
|
|
||||||
|
CefDownloadItemImpl::CefDownloadItemImpl(content::DownloadItem* value)
|
||||||
|
: CefValueBase<CefDownloadItem, content::DownloadItem>(
|
||||||
|
value, NULL, kOwnerNoDelete, true,
|
||||||
|
new CefValueControllerNonThreadSafe()) {
|
||||||
|
// Indicate that this object owns the controller.
|
||||||
|
SetOwnsController();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDownloadItemImpl::IsValid() {
|
||||||
|
return !detached();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDownloadItemImpl::IsInProgress() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||||
|
return const_value().IsInProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDownloadItemImpl::IsComplete() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||||
|
return const_value().IsComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDownloadItemImpl::IsCanceled() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||||
|
return const_value().IsCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 CefDownloadItemImpl::GetCurrentSpeed() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||||
|
return const_value().CurrentSpeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CefDownloadItemImpl::GetPercentComplete() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, -1);
|
||||||
|
return const_value().PercentComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 CefDownloadItemImpl::GetTotalBytes() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||||
|
return const_value().GetTotalBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 CefDownloadItemImpl::GetReceivedBytes() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||||
|
return const_value().GetReceivedBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefTime CefDownloadItemImpl::GetStartTime() {
|
||||||
|
CefTime time;
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, time);
|
||||||
|
cef_time_from_basetime(const_value().GetStartTime(), time);
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefTime CefDownloadItemImpl::GetEndTime() {
|
||||||
|
CefTime time;
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, time);
|
||||||
|
cef_time_from_basetime(const_value().GetEndTime(), time);
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemImpl::GetFullPath() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
||||||
|
return const_value().GetFullPath().value();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 CefDownloadItemImpl::GetId() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||||
|
return const_value().GetId();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemImpl::GetURL() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
||||||
|
return const_value().GetURL().spec();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemImpl::GetSuggestedFileName() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
||||||
|
return const_value().GetSuggestedFilename();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemImpl::GetContentDisposition() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
||||||
|
return const_value().GetContentDisposition();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemImpl::GetMimeType() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
||||||
|
return const_value().GetMimeType();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemImpl::GetReferrerCharset() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
||||||
|
return const_value().GetReferrerCharset();
|
||||||
|
}
|
45
libcef/browser/download_item_impl.h
Normal file
45
libcef/browser/download_item_impl.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.
|
||||||
|
|
||||||
|
#ifndef CEF_LIBCEF_BROWSER_DOWNLOAD_ITEM_IMPL_H_
|
||||||
|
#define CEF_LIBCEF_BROWSER_DOWNLOAD_ITEM_IMPL_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/cef_download_item.h"
|
||||||
|
#include "libcef/common/value_base.h"
|
||||||
|
|
||||||
|
namespace content {
|
||||||
|
class DownloadItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CefDownloadItem implementation
|
||||||
|
class CefDownloadItemImpl
|
||||||
|
: public CefValueBase<CefDownloadItem, content::DownloadItem> {
|
||||||
|
public:
|
||||||
|
explicit CefDownloadItemImpl(content::DownloadItem* value);
|
||||||
|
|
||||||
|
// CefDownloadItem methods.
|
||||||
|
virtual bool IsValid() OVERRIDE;
|
||||||
|
virtual bool IsInProgress() OVERRIDE;
|
||||||
|
virtual bool IsComplete() OVERRIDE;
|
||||||
|
virtual bool IsCanceled() OVERRIDE;
|
||||||
|
virtual int64 GetCurrentSpeed() OVERRIDE;
|
||||||
|
virtual int GetPercentComplete() OVERRIDE;
|
||||||
|
virtual int64 GetTotalBytes() OVERRIDE;
|
||||||
|
virtual int64 GetReceivedBytes() OVERRIDE;
|
||||||
|
virtual CefTime GetStartTime() OVERRIDE;
|
||||||
|
virtual CefTime GetEndTime() OVERRIDE;
|
||||||
|
virtual CefString GetFullPath() OVERRIDE;
|
||||||
|
virtual int32 GetId() OVERRIDE;
|
||||||
|
virtual CefString GetURL() OVERRIDE;
|
||||||
|
virtual CefString GetSuggestedFileName() OVERRIDE;
|
||||||
|
virtual CefString GetContentDisposition() OVERRIDE;
|
||||||
|
virtual CefString GetMimeType() OVERRIDE;
|
||||||
|
virtual CefString GetReferrerCharset() OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefDownloadItemImpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_BROWSER_DOWNLOAD_ITEM_IMPL_H_
|
@ -4,65 +4,226 @@
|
|||||||
|
|
||||||
#include "libcef/browser/download_manager_delegate.h"
|
#include "libcef/browser/download_manager_delegate.h"
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#include "include/cef_download_handler.h"
|
||||||
#include <windows.h>
|
#include "libcef/browser/browser_context.h"
|
||||||
#include <commdlg.h>
|
#include "libcef/browser/browser_host_impl.h"
|
||||||
#endif
|
#include "libcef/browser/context.h"
|
||||||
|
#include "libcef/browser/download_item_impl.h"
|
||||||
|
#include "libcef/browser/thread_util.h"
|
||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/file_util.h"
|
#include "base/file_util.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/path_service.h"
|
||||||
#include "base/string_util.h"
|
#include "base/string_util.h"
|
||||||
#include "base/utf_string_conversions.h"
|
#include "base/utf_string_conversions.h"
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
|
||||||
#include "content/public/browser/download_manager.h"
|
#include "content/public/browser/download_manager.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "net/base/net_util.h"
|
#include "net/base/net_util.h"
|
||||||
|
|
||||||
using content::BrowserThread;
|
|
||||||
using content::DownloadItem;
|
using content::DownloadItem;
|
||||||
using content::DownloadManager;
|
using content::DownloadManager;
|
||||||
using content::WebContents;
|
using content::WebContents;
|
||||||
|
|
||||||
CefDownloadManagerDelegate::CefDownloadManagerDelegate()
|
|
||||||
: download_manager_(NULL) {
|
namespace {
|
||||||
|
|
||||||
|
// Helper function to retrieve the CefBrowserHostImpl.
|
||||||
|
CefRefPtr<CefBrowserHostImpl> GetBrowser(DownloadItem* item) {
|
||||||
|
content::WebContents* contents = item->GetWebContents();
|
||||||
|
if (!contents)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return CefBrowserHostImpl::GetBrowserForContents(contents).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to retrieve the CefDownloadHandler.
|
||||||
|
CefRefPtr<CefDownloadHandler> GetDownloadHandler(
|
||||||
|
CefRefPtr<CefBrowserHostImpl> browser) {
|
||||||
|
CefRefPtr<CefClient> client = browser->GetClient();
|
||||||
|
if (client.get())
|
||||||
|
return client->GetDownloadHandler();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to retrieve the DownloadManager.
|
||||||
|
scoped_refptr<content::DownloadManager> GetDownloadManager() {
|
||||||
|
return content::BrowserContext::GetDownloadManager(
|
||||||
|
_Context->browser_context());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CefBeforeDownloadCallback implementation.
|
||||||
|
class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||||
|
public:
|
||||||
|
CefBeforeDownloadCallbackImpl(int32 download_id,
|
||||||
|
const FilePath& suggested_name)
|
||||||
|
: download_id_(download_id),
|
||||||
|
suggested_name_(suggested_name) {
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Continue(const CefString& download_path,
|
||||||
|
bool show_dialog) OVERRIDE {
|
||||||
|
if (CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
if (download_id_ <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
||||||
|
if (manager) {
|
||||||
|
FilePath path = FilePath(download_path);
|
||||||
|
CEF_POST_TASK(CEF_FILET,
|
||||||
|
base::Bind(&CefBeforeDownloadCallbackImpl::GenerateFilename,
|
||||||
|
download_id_, suggested_name_, path, show_dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
download_id_ = 0;
|
||||||
|
} else {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::Bind(&CefBeforeDownloadCallbackImpl::Continue, this,
|
||||||
|
download_path, show_dialog));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void GenerateFilename(int32 download_id,
|
||||||
|
const FilePath& suggested_name,
|
||||||
|
const FilePath& download_path,
|
||||||
|
bool show_dialog) {
|
||||||
|
FilePath suggested_path = download_path;
|
||||||
|
if (!suggested_path.empty()) {
|
||||||
|
// Create the directory if necessary.
|
||||||
|
FilePath dir_path = suggested_path.DirName();
|
||||||
|
if (!file_util::DirectoryExists(dir_path) &&
|
||||||
|
!file_util::CreateDirectory(dir_path)) {
|
||||||
|
NOTREACHED() << "failed to create the download directory";
|
||||||
|
suggested_path.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (suggested_path.empty()) {
|
||||||
|
if (PathService::Get(base::DIR_TEMP, &suggested_path)) {
|
||||||
|
// Use the temp directory.
|
||||||
|
suggested_path = suggested_path.Append(suggested_name);
|
||||||
|
} else {
|
||||||
|
// Use the current working directory.
|
||||||
|
suggested_path = suggested_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
content::DownloadItem::TargetDisposition disposition = show_dialog ?
|
||||||
|
DownloadItem::TARGET_DISPOSITION_PROMPT :
|
||||||
|
DownloadItem::TARGET_DISPOSITION_OVERWRITE;
|
||||||
|
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::Bind(&CefBeforeDownloadCallbackImpl::RestartDownload,
|
||||||
|
download_id, suggested_path, disposition));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void RestartDownload(int32 download_id,
|
||||||
|
const FilePath& suggested_path,
|
||||||
|
DownloadItem::TargetDisposition disposition) {
|
||||||
|
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
||||||
|
if (!manager)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DownloadItem* item = manager->GetActiveDownloadItem(download_id);
|
||||||
|
if (!item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
item->OnTargetPathDetermined(suggested_path,
|
||||||
|
disposition,
|
||||||
|
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
|
||||||
|
manager->RestartDownload(download_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 download_id_;
|
||||||
|
FilePath suggested_name_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(CefBeforeDownloadCallbackImpl);
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefBeforeDownloadCallbackImpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// CefDownloadItemCallback implementation.
|
||||||
|
class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
||||||
|
public:
|
||||||
|
explicit CefDownloadItemCallbackImpl(int32 download_id)
|
||||||
|
: download_id_(download_id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Cancel() OVERRIDE {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::Bind(&CefDownloadItemCallbackImpl::DoCancel, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void DoCancel() {
|
||||||
|
if (download_id_ <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
||||||
|
if (manager) {
|
||||||
|
content::DownloadItem* item =
|
||||||
|
manager->GetActiveDownloadItem(download_id_);
|
||||||
|
if (item && item->IsInProgress())
|
||||||
|
item->Cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
download_id_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 download_id_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(CefDownloadItemCallbackImpl);
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefDownloadItemCallbackImpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
CefDownloadManagerDelegate::CefDownloadManagerDelegate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CefDownloadManagerDelegate::~CefDownloadManagerDelegate() {
|
CefDownloadManagerDelegate::~CefDownloadManagerDelegate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefDownloadManagerDelegate::SetDownloadManager(
|
|
||||||
DownloadManager* download_manager) {
|
|
||||||
download_manager_ = download_manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefDownloadManagerDelegate::ShouldStartDownload(int32 download_id) {
|
bool CefDownloadManagerDelegate::ShouldStartDownload(int32 download_id) {
|
||||||
DownloadItem* download =
|
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
||||||
download_manager_->GetActiveDownloadItem(download_id);
|
DownloadItem* item = manager->GetActiveDownloadItem(download_id);
|
||||||
|
|
||||||
if (!download->GetForcedFilePath().empty()) {
|
if (!item->GetForcedFilePath().empty()) {
|
||||||
download->OnTargetPathDetermined(
|
item->OnTargetPathDetermined(
|
||||||
download->GetForcedFilePath(),
|
item->GetForcedFilePath(),
|
||||||
DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
|
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath generated_name = net::GenerateFileName(
|
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser(item);
|
||||||
download->GetURL(),
|
CefRefPtr<CefDownloadHandler> handler;
|
||||||
download->GetContentDisposition(),
|
if (browser.get())
|
||||||
download->GetReferrerCharset(),
|
handler = GetDownloadHandler(browser);
|
||||||
download->GetSuggestedFilename(),
|
|
||||||
download->GetMimeType(),
|
if (handler.get()) {
|
||||||
"download");
|
FilePath suggested_name = net::GenerateFileName(
|
||||||
|
item->GetURL(),
|
||||||
|
item->GetContentDisposition(),
|
||||||
|
item->GetReferrerCharset(),
|
||||||
|
item->GetSuggestedFilename(),
|
||||||
|
item->GetMimeType(),
|
||||||
|
"download");
|
||||||
|
|
||||||
|
CefRefPtr<CefDownloadItemImpl> download_item(new CefDownloadItemImpl(item));
|
||||||
|
CefRefPtr<CefBeforeDownloadCallback> callback(
|
||||||
|
new CefBeforeDownloadCallbackImpl(download_id, suggested_name));
|
||||||
|
|
||||||
|
handler->OnBeforeDownload(browser.get(), download_item.get(),
|
||||||
|
suggested_name.value(), callback);
|
||||||
|
|
||||||
|
download_item->Detach(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
BrowserThread::PostTask(
|
|
||||||
BrowserThread::FILE,
|
|
||||||
FROM_HERE,
|
|
||||||
base::Bind(
|
|
||||||
&CefDownloadManagerDelegate::GenerateFilename,
|
|
||||||
this, download_id, generated_name));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,47 +238,35 @@ void CefDownloadManagerDelegate::ChooseDownloadPath(
|
|||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
||||||
if (result.empty()) {
|
if (result.empty()) {
|
||||||
download_manager_->FileSelectionCanceled(item->GetId());
|
manager->FileSelectionCanceled(item->GetId());
|
||||||
} else {
|
} else {
|
||||||
download_manager_->FileSelected(result, item->GetId());
|
manager->FileSelected(result, item->GetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefDownloadManagerDelegate::AddItemToPersistentStore(
|
void CefDownloadManagerDelegate::AddItemToPersistentStore(
|
||||||
content::DownloadItem* item) {
|
DownloadItem* item) {
|
||||||
static int next_id;
|
static int next_id;
|
||||||
download_manager_->OnItemAddedToPersistentStore(item->GetId(), ++next_id);
|
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
||||||
|
manager->OnItemAddedToPersistentStore(item->GetId(), ++next_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefDownloadManagerDelegate::GenerateFilename(
|
void CefDownloadManagerDelegate::UpdateItemInPersistentStore(
|
||||||
int32 download_id,
|
DownloadItem* item) {
|
||||||
const FilePath& generated_name) {
|
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser(item);
|
||||||
FilePath suggested_path = download_manager_->GetBrowserContext()->GetPath().
|
CefRefPtr<CefDownloadHandler> handler;
|
||||||
Append(FILE_PATH_LITERAL("Downloads"));
|
if (browser.get())
|
||||||
if (!file_util::DirectoryExists(suggested_path))
|
handler = GetDownloadHandler(browser);
|
||||||
file_util::CreateDirectory(suggested_path);
|
|
||||||
|
|
||||||
suggested_path = suggested_path.Append(generated_name);
|
if (handler.get()) {
|
||||||
BrowserThread::PostTask(
|
CefRefPtr<CefDownloadItemImpl> download_item(new CefDownloadItemImpl(item));
|
||||||
BrowserThread::UI,
|
CefRefPtr<CefDownloadItemCallback> callback(
|
||||||
FROM_HERE,
|
new CefDownloadItemCallbackImpl(item->GetId()));
|
||||||
base::Bind(
|
|
||||||
&CefDownloadManagerDelegate::RestartDownload,
|
handler->OnDownloadUpdated(browser.get(), download_item.get(), callback);
|
||||||
this, download_id, suggested_path));
|
|
||||||
}
|
download_item->Detach(NULL);
|
||||||
|
}
|
||||||
void CefDownloadManagerDelegate::RestartDownload(
|
|
||||||
int32 download_id,
|
|
||||||
const FilePath& suggested_path) {
|
|
||||||
DownloadItem* download =
|
|
||||||
download_manager_->GetActiveDownloadItem(download_id);
|
|
||||||
if (!download)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Since we have no download UI, show the user a dialog always.
|
|
||||||
download->OnTargetPathDetermined(suggested_path,
|
|
||||||
DownloadItem::TARGET_DISPOSITION_PROMPT,
|
|
||||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
|
|
||||||
download_manager_->RestartDownload(download_id);
|
|
||||||
}
|
}
|
||||||
|
@ -22,28 +22,21 @@ class CefDownloadManagerDelegate
|
|||||||
public:
|
public:
|
||||||
CefDownloadManagerDelegate();
|
CefDownloadManagerDelegate();
|
||||||
|
|
||||||
void SetDownloadManager(content::DownloadManager* manager);
|
|
||||||
|
|
||||||
// DownloadManagerDelegate methods.
|
// DownloadManagerDelegate methods.
|
||||||
virtual bool ShouldStartDownload(int32 download_id) OVERRIDE;
|
virtual bool ShouldStartDownload(int32 download_id) OVERRIDE;
|
||||||
virtual void ChooseDownloadPath(content::DownloadItem* item) OVERRIDE;
|
virtual void ChooseDownloadPath(content::DownloadItem* item) OVERRIDE;
|
||||||
virtual void AddItemToPersistentStore(content::DownloadItem* item) OVERRIDE;
|
virtual void AddItemToPersistentStore(content::DownloadItem* item) OVERRIDE;
|
||||||
|
virtual void UpdateItemInPersistentStore(
|
||||||
|
content::DownloadItem* item) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class base::RefCountedThreadSafe<CefDownloadManagerDelegate>;
|
friend class base::RefCountedThreadSafe<CefDownloadManagerDelegate>;
|
||||||
|
|
||||||
virtual ~CefDownloadManagerDelegate();
|
virtual ~CefDownloadManagerDelegate();
|
||||||
|
|
||||||
void GenerateFilename(int32 download_id,
|
|
||||||
const FilePath& generated_name);
|
|
||||||
void RestartDownload(int32 download_id,
|
|
||||||
const FilePath& suggested_path);
|
|
||||||
|
|
||||||
FilePath PlatformChooseDownloadPath(content::WebContents* web_contents,
|
FilePath PlatformChooseDownloadPath(content::WebContents* web_contents,
|
||||||
const FilePath& suggested_path);
|
const FilePath& suggested_path);
|
||||||
|
|
||||||
content::DownloadManager* download_manager_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate);
|
DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,6 +12,11 @@ CefResourceContext::CefResourceContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CefResourceContext::~CefResourceContext() {
|
CefResourceContext::~CefResourceContext() {
|
||||||
|
// Destroy the getter after content::ResourceContext has finished destructing.
|
||||||
|
// Otherwise, the URLRequestContext objects will be deleted before
|
||||||
|
// ResourceDispatcherHost has canceled any pending URLRequests.
|
||||||
|
content::BrowserThread::ReleaseSoon(
|
||||||
|
content::BrowserThread::IO, FROM_HERE, getter_.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
net::HostResolver* CefResourceContext::GetHostResolver() {
|
net::HostResolver* CefResourceContext::GetHostResolver() {
|
||||||
|
@ -13,10 +13,12 @@
|
|||||||
#include "libcef/browser/context.h"
|
#include "libcef/browser/context.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
#include "libcef/browser/url_network_delegate.h"
|
#include "libcef/browser/url_network_delegate.h"
|
||||||
|
#include "libcef/browser/url_request_context_proxy.h"
|
||||||
#include "libcef/browser/url_request_interceptor.h"
|
#include "libcef/browser/url_request_interceptor.h"
|
||||||
|
|
||||||
#include "base/file_util.h"
|
#include "base/file_util.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/stl_util.h"
|
||||||
#include "base/string_split.h"
|
#include "base/string_split.h"
|
||||||
#include "base/threading/thread_restrictions.h"
|
#include "base/threading/thread_restrictions.h"
|
||||||
#include "base/threading/worker_pool.h"
|
#include "base/threading/worker_pool.h"
|
||||||
@ -137,6 +139,7 @@ CefURLRequestContextGetter::CefURLRequestContextGetter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CefURLRequestContextGetter::~CefURLRequestContextGetter() {
|
CefURLRequestContextGetter::~CefURLRequestContextGetter() {
|
||||||
|
STLDeleteElements(&url_request_context_proxies_);
|
||||||
}
|
}
|
||||||
|
|
||||||
net::URLRequestContext* CefURLRequestContextGetter::GetURLRequestContext() {
|
net::URLRequestContext* CefURLRequestContextGetter::GetURLRequestContext() {
|
||||||
@ -353,6 +356,51 @@ void CefURLRequestContextGetter::SetCookieSupportedSchemes(
|
|||||||
delete [] arr;
|
delete [] arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefURLRequestContextProxy*
|
||||||
|
CefURLRequestContextGetter::CreateURLRequestContextProxy() {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
|
CefURLRequestContextProxy* proxy = new CefURLRequestContextProxy(this);
|
||||||
|
url_request_context_proxies_.insert(proxy);
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefURLRequestContextGetter::ReleaseURLRequestContextProxy(
|
||||||
|
CefURLRequestContextProxy* proxy) {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
|
|
||||||
|
// Don't do anything if we're currently shutting down. The proxy objects will
|
||||||
|
// be deleted when this object is destroyed.
|
||||||
|
if (_Context->shutting_down())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (proxy->url_requests()->size() == 0) {
|
||||||
|
// Safe to delete the proxy.
|
||||||
|
RequestContextProxySet::iterator it =
|
||||||
|
url_request_context_proxies_.find(proxy);
|
||||||
|
DCHECK(it != url_request_context_proxies_.end());
|
||||||
|
url_request_context_proxies_.erase(it);
|
||||||
|
delete proxy;
|
||||||
|
} else {
|
||||||
|
proxy->increment_delete_try_count();
|
||||||
|
if (proxy->delete_try_count() <= 1) {
|
||||||
|
// Cancel the pending requests. This may result in additional tasks being
|
||||||
|
// posted on the IO thread.
|
||||||
|
std::set<const net::URLRequest*>::iterator it =
|
||||||
|
proxy->url_requests()->begin();
|
||||||
|
for (; it != proxy->url_requests()->end(); ++it)
|
||||||
|
const_cast<net::URLRequest*>(*it)->Cancel();
|
||||||
|
|
||||||
|
// Try to delete the proxy again later.
|
||||||
|
CEF_POST_TASK(CEF_IOT,
|
||||||
|
base::Bind(&CefURLRequestContextGetter::ReleaseURLRequestContextProxy,
|
||||||
|
this, proxy));
|
||||||
|
} else {
|
||||||
|
NOTREACHED() <<
|
||||||
|
"too many retries to delete URLRequestContext proxy object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CefURLRequestContextGetter::CreateProxyConfigService() {
|
void CefURLRequestContextGetter::CreateProxyConfigService() {
|
||||||
if (proxy_config_service_.get())
|
if (proxy_config_service_.get())
|
||||||
return;
|
return;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_
|
#define CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -16,6 +17,7 @@
|
|||||||
#include "net/url_request/url_request_context_getter.h"
|
#include "net/url_request/url_request_context_getter.h"
|
||||||
|
|
||||||
class CefRequestInterceptor;
|
class CefRequestInterceptor;
|
||||||
|
class CefURLRequestContextProxy;
|
||||||
class MessageLoop;
|
class MessageLoop;
|
||||||
|
|
||||||
namespace net {
|
namespace net {
|
||||||
@ -44,6 +46,12 @@ class CefURLRequestContextGetter : public net::URLRequestContextGetter {
|
|||||||
void SetCookieStoragePath(const FilePath& path);
|
void SetCookieStoragePath(const FilePath& path);
|
||||||
void SetCookieSupportedSchemes(const std::vector<std::string>& schemes);
|
void SetCookieSupportedSchemes(const std::vector<std::string>& schemes);
|
||||||
|
|
||||||
|
// Manage URLRequestContext proxy objects. It's important that proxy objects
|
||||||
|
// not be destroyed while any in-flight URLRequests exist. These methods
|
||||||
|
// manage that requirement.
|
||||||
|
CefURLRequestContextProxy* CreateURLRequestContextProxy();
|
||||||
|
void ReleaseURLRequestContextProxy(CefURLRequestContextProxy* proxy);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateProxyConfigService();
|
void CreateProxyConfigService();
|
||||||
|
|
||||||
@ -57,6 +65,9 @@ class CefURLRequestContextGetter : public net::URLRequestContextGetter {
|
|||||||
scoped_ptr<net::URLRequestContext> url_request_context_;
|
scoped_ptr<net::URLRequestContext> url_request_context_;
|
||||||
scoped_ptr<net::URLSecurityManager> url_security_manager_;
|
scoped_ptr<net::URLSecurityManager> url_security_manager_;
|
||||||
|
|
||||||
|
typedef std::set<CefURLRequestContextProxy*> RequestContextProxySet;
|
||||||
|
RequestContextProxySet url_request_context_proxies_;
|
||||||
|
|
||||||
FilePath cookie_store_path_;
|
FilePath cookie_store_path_;
|
||||||
std::vector<std::string> cookie_supported_schemes_;
|
std::vector<std::string> cookie_supported_schemes_;
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include "libcef/browser/browser_host_impl.h"
|
#include "libcef/browser/browser_host_impl.h"
|
||||||
#include "libcef/browser/cookie_manager_impl.h"
|
#include "libcef/browser/cookie_manager_impl.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
|
#include "libcef/browser/url_request_context_getter.h"
|
||||||
|
#include "libcef/browser/url_request_context_proxy.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/message_loop_proxy.h"
|
#include "base/message_loop_proxy.h"
|
||||||
@ -117,69 +119,32 @@ class CefCookieStoreProxy : public net::CookieStore {
|
|||||||
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy);
|
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CefRequestContextProxy : public net::URLRequestContext {
|
|
||||||
public:
|
|
||||||
CefRequestContextProxy(CefBrowserHostImpl* browser,
|
|
||||||
net::URLRequestContextGetter* parent)
|
|
||||||
: parent_(parent) {
|
|
||||||
net::URLRequestContext* context = parent->GetURLRequestContext();
|
|
||||||
|
|
||||||
// Cookie store that proxies to the browser implementation.
|
|
||||||
cookie_store_proxy_ = new CefCookieStoreProxy(browser, context);
|
|
||||||
set_cookie_store(cookie_store_proxy_);
|
|
||||||
|
|
||||||
// All other values refer to the parent request context.
|
|
||||||
set_net_log(context->net_log());
|
|
||||||
set_host_resolver(context->host_resolver());
|
|
||||||
set_cert_verifier(context->cert_verifier());
|
|
||||||
set_server_bound_cert_service(context->server_bound_cert_service());
|
|
||||||
set_fraudulent_certificate_reporter(
|
|
||||||
context->fraudulent_certificate_reporter());
|
|
||||||
set_proxy_service(context->proxy_service());
|
|
||||||
set_ssl_config_service(context->ssl_config_service());
|
|
||||||
set_http_auth_handler_factory(context->http_auth_handler_factory());
|
|
||||||
set_http_transaction_factory(context->http_transaction_factory());
|
|
||||||
set_ftp_transaction_factory(context->ftp_transaction_factory());
|
|
||||||
set_network_delegate(context->network_delegate());
|
|
||||||
set_http_server_properties(context->http_server_properties());
|
|
||||||
set_transport_security_state(context->transport_security_state());
|
|
||||||
set_accept_charset(context->accept_charset());
|
|
||||||
set_accept_language(context->accept_language());
|
|
||||||
set_referrer_charset(context->referrer_charset());
|
|
||||||
set_job_factory(context->job_factory());
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE {
|
|
||||||
return parent_->GetURLRequestContext()->GetUserAgent(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
net::URLRequestContextGetter* parent_;
|
|
||||||
scoped_refptr<net::CookieStore> cookie_store_proxy_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefRequestContextProxy);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
CefURLRequestContextGetterProxy::CefURLRequestContextGetterProxy(
|
CefURLRequestContextGetterProxy::CefURLRequestContextGetterProxy(
|
||||||
CefBrowserHostImpl* browser,
|
CefBrowserHostImpl* browser,
|
||||||
net::URLRequestContextGetter* parent)
|
CefURLRequestContextGetter* parent)
|
||||||
: browser_(browser),
|
: browser_(browser),
|
||||||
parent_(parent) {
|
parent_(parent),
|
||||||
|
context_proxy_(NULL) {
|
||||||
DCHECK(browser);
|
DCHECK(browser);
|
||||||
DCHECK(parent);
|
DCHECK(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefURLRequestContextGetterProxy::~CefURLRequestContextGetterProxy() {
|
||||||
|
if (context_proxy_)
|
||||||
|
parent_->ReleaseURLRequestContextProxy(context_proxy_);
|
||||||
|
}
|
||||||
|
|
||||||
net::URLRequestContext*
|
net::URLRequestContext*
|
||||||
CefURLRequestContextGetterProxy::GetURLRequestContext() {
|
CefURLRequestContextGetterProxy::GetURLRequestContext() {
|
||||||
CEF_REQUIRE_IOT();
|
CEF_REQUIRE_IOT();
|
||||||
if (!context_proxy_.get()) {
|
if (!context_proxy_) {
|
||||||
context_proxy_.reset(
|
context_proxy_ = parent_->CreateURLRequestContextProxy();
|
||||||
new CefRequestContextProxy(browser_, parent_));
|
context_proxy_->Initialize(browser_);
|
||||||
}
|
}
|
||||||
return context_proxy_.get();
|
return context_proxy_;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner>
|
scoped_refptr<base::SingleThreadTaskRunner>
|
||||||
|
@ -10,11 +10,14 @@
|
|||||||
#include "net/url_request/url_request_context_getter.h"
|
#include "net/url_request/url_request_context_getter.h"
|
||||||
|
|
||||||
class CefBrowserHostImpl;
|
class CefBrowserHostImpl;
|
||||||
|
class CefURLRequestContextGetter;
|
||||||
|
class CefURLRequestContextProxy;
|
||||||
|
|
||||||
class CefURLRequestContextGetterProxy : public net::URLRequestContextGetter {
|
class CefURLRequestContextGetterProxy : public net::URLRequestContextGetter {
|
||||||
public:
|
public:
|
||||||
CefURLRequestContextGetterProxy(CefBrowserHostImpl* browser,
|
CefURLRequestContextGetterProxy(CefBrowserHostImpl* browser,
|
||||||
net::URLRequestContextGetter* parent);
|
CefURLRequestContextGetter* parent);
|
||||||
|
virtual ~CefURLRequestContextGetterProxy();
|
||||||
|
|
||||||
// net::URLRequestContextGetter implementation.
|
// net::URLRequestContextGetter implementation.
|
||||||
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
|
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
|
||||||
@ -23,8 +26,10 @@ class CefURLRequestContextGetterProxy : public net::URLRequestContextGetter {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CefBrowserHostImpl* browser_;
|
CefBrowserHostImpl* browser_;
|
||||||
scoped_refptr<net::URLRequestContextGetter> parent_;
|
scoped_refptr<CefURLRequestContextGetter> parent_;
|
||||||
scoped_ptr<net::URLRequestContext> context_proxy_;
|
|
||||||
|
// The |context_proxy_| object is owned by |parent_|.
|
||||||
|
CefURLRequestContextProxy* context_proxy_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetterProxy);
|
DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetterProxy);
|
||||||
};
|
};
|
||||||
|
164
libcef/browser/url_request_context_proxy.cc
Normal file
164
libcef/browser/url_request_context_proxy.cc
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
// 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/url_request_context_proxy.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "libcef/browser/browser_host_impl.h"
|
||||||
|
#include "libcef/browser/cookie_manager_impl.h"
|
||||||
|
#include "libcef/browser/thread_util.h"
|
||||||
|
|
||||||
|
#include "base/logging.h"
|
||||||
|
#include "base/message_loop_proxy.h"
|
||||||
|
#include "net/cookies/cookie_store.h"
|
||||||
|
#include "net/url_request/url_request_context_getter.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class CefCookieStoreProxy : public net::CookieStore {
|
||||||
|
public:
|
||||||
|
explicit CefCookieStoreProxy(CefBrowserHostImpl* browser,
|
||||||
|
net::URLRequestContext* parent)
|
||||||
|
: parent_(parent),
|
||||||
|
browser_(browser) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// net::CookieStore methods.
|
||||||
|
virtual void SetCookieWithOptionsAsync(
|
||||||
|
const GURL& url,
|
||||||
|
const std::string& cookie_line,
|
||||||
|
const net::CookieOptions& options,
|
||||||
|
const SetCookiesCallback& callback) OVERRIDE {
|
||||||
|
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
||||||
|
cookie_store->SetCookieWithOptionsAsync(url, cookie_line, options,
|
||||||
|
callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void GetCookiesWithOptionsAsync(
|
||||||
|
const GURL& url, const net::CookieOptions& options,
|
||||||
|
const GetCookiesCallback& callback) OVERRIDE {
|
||||||
|
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
||||||
|
cookie_store->GetCookiesWithOptionsAsync(url, options, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetCookiesWithInfoAsync(
|
||||||
|
const GURL& url,
|
||||||
|
const net::CookieOptions& options,
|
||||||
|
const GetCookieInfoCallback& callback) OVERRIDE {
|
||||||
|
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
||||||
|
cookie_store->GetCookiesWithInfoAsync(url, options, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void DeleteCookieAsync(const GURL& url,
|
||||||
|
const std::string& cookie_name,
|
||||||
|
const base::Closure& callback) OVERRIDE {
|
||||||
|
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
||||||
|
cookie_store->DeleteCookieAsync(url, cookie_name, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin,
|
||||||
|
const base::Time& delete_end,
|
||||||
|
const DeleteCallback& callback)
|
||||||
|
OVERRIDE {
|
||||||
|
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
||||||
|
cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end,
|
||||||
|
callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void DeleteSessionCookiesAsync(const DeleteCallback& callback)
|
||||||
|
OVERRIDE {
|
||||||
|
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
||||||
|
cookie_store->DeleteSessionCookiesAsync(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual net::CookieMonster* GetCookieMonster() OVERRIDE {
|
||||||
|
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
||||||
|
return cookie_store->GetCookieMonster();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
net::CookieStore* GetCookieStore() {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
|
|
||||||
|
scoped_refptr<net::CookieStore> cookie_store;
|
||||||
|
|
||||||
|
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||||
|
if (client.get()) {
|
||||||
|
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
|
||||||
|
if (handler.get()) {
|
||||||
|
// Get the manager from the handler.
|
||||||
|
CefRefPtr<CefCookieManager> manager =
|
||||||
|
handler->GetCookieManager(browser_,
|
||||||
|
browser_->GetLoadingURL().spec());
|
||||||
|
if (manager.get()) {
|
||||||
|
cookie_store =
|
||||||
|
reinterpret_cast<CefCookieManagerImpl*>(
|
||||||
|
manager.get())->cookie_monster();
|
||||||
|
DCHECK(cookie_store);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cookie_store) {
|
||||||
|
// Use the global cookie store.
|
||||||
|
cookie_store = parent_->cookie_store();
|
||||||
|
}
|
||||||
|
|
||||||
|
DCHECK(cookie_store);
|
||||||
|
return cookie_store;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This pointer is guaranteed by the CefRequestContextProxy object.
|
||||||
|
net::URLRequestContext* parent_;
|
||||||
|
CefBrowserHostImpl* browser_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
CefURLRequestContextProxy::CefURLRequestContextProxy(
|
||||||
|
net::URLRequestContextGetter* parent)
|
||||||
|
: parent_(parent),
|
||||||
|
delete_try_count_(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
CefURLRequestContextProxy::~CefURLRequestContextProxy() {
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& CefURLRequestContextProxy::GetUserAgent(const GURL& url) const {
|
||||||
|
return parent_->GetURLRequestContext()->GetUserAgent(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefURLRequestContextProxy::Initialize(CefBrowserHostImpl* browser) {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
|
|
||||||
|
net::URLRequestContext* context = parent_->GetURLRequestContext();
|
||||||
|
|
||||||
|
// Cookie store that proxies to the browser implementation.
|
||||||
|
cookie_store_proxy_ = new CefCookieStoreProxy(browser, context);
|
||||||
|
set_cookie_store(cookie_store_proxy_);
|
||||||
|
|
||||||
|
// All other values refer to the parent request context.
|
||||||
|
set_net_log(context->net_log());
|
||||||
|
set_host_resolver(context->host_resolver());
|
||||||
|
set_cert_verifier(context->cert_verifier());
|
||||||
|
set_server_bound_cert_service(context->server_bound_cert_service());
|
||||||
|
set_fraudulent_certificate_reporter(
|
||||||
|
context->fraudulent_certificate_reporter());
|
||||||
|
set_proxy_service(context->proxy_service());
|
||||||
|
set_ssl_config_service(context->ssl_config_service());
|
||||||
|
set_http_auth_handler_factory(context->http_auth_handler_factory());
|
||||||
|
set_http_transaction_factory(context->http_transaction_factory());
|
||||||
|
set_ftp_transaction_factory(context->ftp_transaction_factory());
|
||||||
|
set_network_delegate(context->network_delegate());
|
||||||
|
set_http_server_properties(context->http_server_properties());
|
||||||
|
set_transport_security_state(context->transport_security_state());
|
||||||
|
set_accept_charset(context->accept_charset());
|
||||||
|
set_accept_language(context->accept_language());
|
||||||
|
set_referrer_charset(context->referrer_charset());
|
||||||
|
set_job_factory(context->job_factory());
|
||||||
|
}
|
43
libcef/browser/url_request_context_proxy.h
Normal file
43
libcef/browser/url_request_context_proxy.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.
|
||||||
|
|
||||||
|
#ifndef CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_PROXY_H_
|
||||||
|
#define CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_PROXY_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/memory/scoped_ptr.h"
|
||||||
|
#include "net/url_request/url_request_context.h"
|
||||||
|
|
||||||
|
class CefBrowserHostImpl;
|
||||||
|
|
||||||
|
namespace net {
|
||||||
|
class CookieStore;
|
||||||
|
class URLRequestContextGetter;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CefURLRequestContextProxy : public net::URLRequestContext {
|
||||||
|
public:
|
||||||
|
explicit CefURLRequestContextProxy(net::URLRequestContextGetter* parent);
|
||||||
|
virtual ~CefURLRequestContextProxy();
|
||||||
|
|
||||||
|
virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE;
|
||||||
|
|
||||||
|
void Initialize(CefBrowserHostImpl* browser);
|
||||||
|
|
||||||
|
// We may try to delete this proxy multiple times if URLRequests are still
|
||||||
|
// pending. Keep track of the number of tries so that they don't become
|
||||||
|
// excessive.
|
||||||
|
int delete_try_count() const { return delete_try_count_; }
|
||||||
|
void increment_delete_try_count() { delete_try_count_++; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
net::URLRequestContextGetter* parent_;
|
||||||
|
scoped_refptr<net::CookieStore> cookie_store_proxy_;
|
||||||
|
|
||||||
|
int delete_try_count_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextProxy);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_PROXY_H_
|
52
libcef_dll/cpptoc/before_download_callback_cpptoc.cc
Normal file
52
libcef_dll/cpptoc/before_download_callback_cpptoc.cc
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// 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/before_download_callback_cpptoc.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK before_download_callback_cont(
|
||||||
|
struct _cef_before_download_callback_t* self,
|
||||||
|
const cef_string_t* download_path, int show_dialog) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: download_path; type: string_byref_const
|
||||||
|
DCHECK(download_path);
|
||||||
|
if (!download_path)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefBeforeDownloadCallbackCppToC::Get(self)->Continue(
|
||||||
|
CefString(download_path),
|
||||||
|
show_dialog?true:false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefBeforeDownloadCallbackCppToC::CefBeforeDownloadCallbackCppToC(
|
||||||
|
CefBeforeDownloadCallback* cls)
|
||||||
|
: CefCppToC<CefBeforeDownloadCallbackCppToC, CefBeforeDownloadCallback,
|
||||||
|
cef_before_download_callback_t>(cls) {
|
||||||
|
struct_.struct_.cont = before_download_callback_cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefBeforeDownloadCallbackCppToC,
|
||||||
|
CefBeforeDownloadCallback, cef_before_download_callback_t>::DebugObjCt =
|
||||||
|
0;
|
||||||
|
#endif
|
||||||
|
|
37
libcef_dll/cpptoc/before_download_callback_cpptoc.h
Normal file
37
libcef_dll/cpptoc/before_download_callback_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_BEFORE_DOWNLOAD_CALLBACK_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_BEFORE_DOWNLOAD_CALLBACK_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_download_handler.h"
|
||||||
|
#include "include/capi/cef_download_handler_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 CefBeforeDownloadCallbackCppToC
|
||||||
|
: public CefCppToC<CefBeforeDownloadCallbackCppToC,
|
||||||
|
CefBeforeDownloadCallback, cef_before_download_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefBeforeDownloadCallbackCppToC(CefBeforeDownloadCallback* cls);
|
||||||
|
virtual ~CefBeforeDownloadCallbackCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_BEFORE_DOWNLOAD_CALLBACK_CPPTOC_H_
|
||||||
|
|
@ -13,6 +13,7 @@
|
|||||||
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/download_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
|
||||||
@ -58,6 +59,22 @@ struct _cef_display_handler_t* CEF_CALLBACK client_get_display_handler(
|
|||||||
return CefDisplayHandlerCppToC::Wrap(_retval);
|
return CefDisplayHandlerCppToC::Wrap(_retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct _cef_download_handler_t* CEF_CALLBACK client_get_download_handler(
|
||||||
|
struct _cef_client_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefRefPtr<CefDownloadHandler> _retval = CefClientCppToC::Get(
|
||||||
|
self)->GetDownloadHandler();
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefDownloadHandlerCppToC::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
struct _cef_focus_handler_t* CEF_CALLBACK client_get_focus_handler(
|
struct _cef_focus_handler_t* CEF_CALLBACK client_get_focus_handler(
|
||||||
struct _cef_client_t* self) {
|
struct _cef_client_t* self) {
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
@ -204,6 +221,7 @@ CefClientCppToC::CefClientCppToC(CefClient* cls)
|
|||||||
: CefCppToC<CefClientCppToC, CefClient, cef_client_t>(cls) {
|
: CefCppToC<CefClientCppToC, CefClient, cef_client_t>(cls) {
|
||||||
struct_.struct_.get_context_menu_handler = client_get_context_menu_handler;
|
struct_.struct_.get_context_menu_handler = client_get_context_menu_handler;
|
||||||
struct_.struct_.get_display_handler = client_get_display_handler;
|
struct_.struct_.get_display_handler = client_get_display_handler;
|
||||||
|
struct_.struct_.get_download_handler = client_get_download_handler;
|
||||||
struct_.struct_.get_focus_handler = client_get_focus_handler;
|
struct_.struct_.get_focus_handler = client_get_focus_handler;
|
||||||
struct_.struct_.get_geolocation_handler = client_get_geolocation_handler;
|
struct_.struct_.get_geolocation_handler = client_get_geolocation_handler;
|
||||||
struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler;
|
struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler;
|
||||||
|
100
libcef_dll/cpptoc/download_handler_cpptoc.cc
Normal file
100
libcef_dll/cpptoc/download_handler_cpptoc.cc
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// 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/download_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/ctocpp/before_download_callback_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/download_item_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/download_item_callback_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK download_handler_on_before_download(
|
||||||
|
struct _cef_download_handler_t* self, cef_browser_t* browser,
|
||||||
|
struct _cef_download_item_t* download_item,
|
||||||
|
const cef_string_t* suggested_name,
|
||||||
|
cef_before_download_callback_t* callback) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: browser; type: refptr_diff
|
||||||
|
DCHECK(browser);
|
||||||
|
if (!browser)
|
||||||
|
return;
|
||||||
|
// Verify param: download_item; type: refptr_diff
|
||||||
|
DCHECK(download_item);
|
||||||
|
if (!download_item)
|
||||||
|
return;
|
||||||
|
// Verify param: suggested_name; type: string_byref_const
|
||||||
|
DCHECK(suggested_name);
|
||||||
|
if (!suggested_name)
|
||||||
|
return;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback);
|
||||||
|
if (!callback)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefDownloadHandlerCppToC::Get(self)->OnBeforeDownload(
|
||||||
|
CefBrowserCToCpp::Wrap(browser),
|
||||||
|
CefDownloadItemCToCpp::Wrap(download_item),
|
||||||
|
CefString(suggested_name),
|
||||||
|
CefBeforeDownloadCallbackCToCpp::Wrap(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK download_handler_on_download_updated(
|
||||||
|
struct _cef_download_handler_t* self, cef_browser_t* browser,
|
||||||
|
struct _cef_download_item_t* download_item,
|
||||||
|
cef_download_item_callback_t* callback) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: browser; type: refptr_diff
|
||||||
|
DCHECK(browser);
|
||||||
|
if (!browser)
|
||||||
|
return;
|
||||||
|
// Verify param: download_item; type: refptr_diff
|
||||||
|
DCHECK(download_item);
|
||||||
|
if (!download_item)
|
||||||
|
return;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback);
|
||||||
|
if (!callback)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefDownloadHandlerCppToC::Get(self)->OnDownloadUpdated(
|
||||||
|
CefBrowserCToCpp::Wrap(browser),
|
||||||
|
CefDownloadItemCToCpp::Wrap(download_item),
|
||||||
|
CefDownloadItemCallbackCToCpp::Wrap(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefDownloadHandlerCppToC::CefDownloadHandlerCppToC(CefDownloadHandler* cls)
|
||||||
|
: CefCppToC<CefDownloadHandlerCppToC, CefDownloadHandler,
|
||||||
|
cef_download_handler_t>(cls) {
|
||||||
|
struct_.struct_.on_before_download = download_handler_on_before_download;
|
||||||
|
struct_.struct_.on_download_updated = download_handler_on_download_updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefDownloadHandlerCppToC, CefDownloadHandler,
|
||||||
|
cef_download_handler_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
37
libcef_dll/cpptoc/download_handler_cpptoc.h
Normal file
37
libcef_dll/cpptoc/download_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_DOWNLOAD_HANDLER_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_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_download_handler.h"
|
||||||
|
#include "include/capi/cef_download_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 CefDownloadHandlerCppToC
|
||||||
|
: public CefCppToC<CefDownloadHandlerCppToC, CefDownloadHandler,
|
||||||
|
cef_download_handler_t> {
|
||||||
|
public:
|
||||||
|
explicit CefDownloadHandlerCppToC(CefDownloadHandler* cls);
|
||||||
|
virtual ~CefDownloadHandlerCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_HANDLER_CPPTOC_H_
|
||||||
|
|
44
libcef_dll/cpptoc/download_item_callback_cpptoc.cc
Normal file
44
libcef_dll/cpptoc/download_item_callback_cpptoc.cc
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// 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/download_item_callback_cpptoc.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK download_item_callback_cancel(
|
||||||
|
struct _cef_download_item_callback_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefDownloadItemCallbackCppToC::Get(self)->Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefDownloadItemCallbackCppToC::CefDownloadItemCallbackCppToC(
|
||||||
|
CefDownloadItemCallback* cls)
|
||||||
|
: CefCppToC<CefDownloadItemCallbackCppToC, CefDownloadItemCallback,
|
||||||
|
cef_download_item_callback_t>(cls) {
|
||||||
|
struct_.struct_.cancel = download_item_callback_cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefDownloadItemCallbackCppToC,
|
||||||
|
CefDownloadItemCallback, cef_download_item_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
37
libcef_dll/cpptoc/download_item_callback_cpptoc.h
Normal file
37
libcef_dll/cpptoc/download_item_callback_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_DOWNLOAD_ITEM_CALLBACK_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CALLBACK_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_download_handler.h"
|
||||||
|
#include "include/capi/cef_download_handler_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 CefDownloadItemCallbackCppToC
|
||||||
|
: public CefCppToC<CefDownloadItemCallbackCppToC, CefDownloadItemCallback,
|
||||||
|
cef_download_item_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefDownloadItemCallbackCppToC(CefDownloadItemCallback* cls);
|
||||||
|
virtual ~CefDownloadItemCallbackCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CALLBACK_CPPTOC_H_
|
||||||
|
|
300
libcef_dll/cpptoc/download_item_cpptoc.cc
Normal file
300
libcef_dll/cpptoc/download_item_cpptoc.cc
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
// 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/download_item_cpptoc.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
int CEF_CALLBACK download_item_is_valid(struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefDownloadItemCppToC::Get(self)->IsValid();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK download_item_is_in_progress(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefDownloadItemCppToC::Get(self)->IsInProgress();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK download_item_is_complete(struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefDownloadItemCppToC::Get(self)->IsComplete();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK download_item_is_canceled(struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefDownloadItemCppToC::Get(self)->IsCanceled();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 CEF_CALLBACK download_item_get_current_speed(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int64 _retval = CefDownloadItemCppToC::Get(self)->GetCurrentSpeed();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK download_item_get_percent_complete(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = CefDownloadItemCppToC::Get(self)->GetPercentComplete();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 CEF_CALLBACK download_item_get_total_bytes(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int64 _retval = CefDownloadItemCppToC::Get(self)->GetTotalBytes();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 CEF_CALLBACK download_item_get_received_bytes(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int64 _retval = CefDownloadItemCppToC::Get(self)->GetReceivedBytes();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_time_t CEF_CALLBACK download_item_get_start_time(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return CefTime();
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_time_t _retval = CefDownloadItemCppToC::Get(self)->GetStartTime();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_time_t CEF_CALLBACK download_item_get_end_time(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return CefTime();
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_time_t _retval = CefDownloadItemCppToC::Get(self)->GetEndTime();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_string_userfree_t CEF_CALLBACK download_item_get_full_path(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefString _retval = CefDownloadItemCppToC::Get(self)->GetFullPath();
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
return _retval.DetachToUserFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 CEF_CALLBACK download_item_get_id(struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int32 _retval = CefDownloadItemCppToC::Get(self)->GetId();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_string_userfree_t CEF_CALLBACK download_item_get_url(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefString _retval = CefDownloadItemCppToC::Get(self)->GetURL();
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
return _retval.DetachToUserFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_string_userfree_t CEF_CALLBACK download_item_get_suggested_file_name(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefString _retval = CefDownloadItemCppToC::Get(self)->GetSuggestedFileName();
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
return _retval.DetachToUserFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_string_userfree_t CEF_CALLBACK download_item_get_content_disposition(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefString _retval = CefDownloadItemCppToC::Get(self)->GetContentDisposition();
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
return _retval.DetachToUserFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_string_userfree_t CEF_CALLBACK download_item_get_mime_type(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefString _retval = CefDownloadItemCppToC::Get(self)->GetMimeType();
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
return _retval.DetachToUserFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_string_userfree_t CEF_CALLBACK download_item_get_referrer_charset(
|
||||||
|
struct _cef_download_item_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefString _retval = CefDownloadItemCppToC::Get(self)->GetReferrerCharset();
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
return _retval.DetachToUserFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefDownloadItemCppToC::CefDownloadItemCppToC(CefDownloadItem* cls)
|
||||||
|
: CefCppToC<CefDownloadItemCppToC, CefDownloadItem, cef_download_item_t>(
|
||||||
|
cls) {
|
||||||
|
struct_.struct_.is_valid = download_item_is_valid;
|
||||||
|
struct_.struct_.is_in_progress = download_item_is_in_progress;
|
||||||
|
struct_.struct_.is_complete = download_item_is_complete;
|
||||||
|
struct_.struct_.is_canceled = download_item_is_canceled;
|
||||||
|
struct_.struct_.get_current_speed = download_item_get_current_speed;
|
||||||
|
struct_.struct_.get_percent_complete = download_item_get_percent_complete;
|
||||||
|
struct_.struct_.get_total_bytes = download_item_get_total_bytes;
|
||||||
|
struct_.struct_.get_received_bytes = download_item_get_received_bytes;
|
||||||
|
struct_.struct_.get_start_time = download_item_get_start_time;
|
||||||
|
struct_.struct_.get_end_time = download_item_get_end_time;
|
||||||
|
struct_.struct_.get_full_path = download_item_get_full_path;
|
||||||
|
struct_.struct_.get_id = download_item_get_id;
|
||||||
|
struct_.struct_.get_url = download_item_get_url;
|
||||||
|
struct_.struct_.get_suggested_file_name =
|
||||||
|
download_item_get_suggested_file_name;
|
||||||
|
struct_.struct_.get_content_disposition =
|
||||||
|
download_item_get_content_disposition;
|
||||||
|
struct_.struct_.get_mime_type = download_item_get_mime_type;
|
||||||
|
struct_.struct_.get_referrer_charset = download_item_get_referrer_charset;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefDownloadItemCppToC, CefDownloadItem,
|
||||||
|
cef_download_item_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
37
libcef_dll/cpptoc/download_item_cpptoc.h
Normal file
37
libcef_dll/cpptoc/download_item_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_DOWNLOAD_ITEM_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_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_download_item.h"
|
||||||
|
#include "include/capi/cef_download_item_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 CefDownloadItemCppToC
|
||||||
|
: public CefCppToC<CefDownloadItemCppToC, CefDownloadItem,
|
||||||
|
cef_download_item_t> {
|
||||||
|
public:
|
||||||
|
explicit CefDownloadItemCppToC(CefDownloadItem* cls);
|
||||||
|
virtual ~CefDownloadItemCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CPPTOC_H_
|
||||||
|
|
42
libcef_dll/ctocpp/before_download_callback_ctocpp.cc
Normal file
42
libcef_dll/ctocpp/before_download_callback_ctocpp.cc
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// 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/before_download_callback_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CefBeforeDownloadCallbackCToCpp::Continue(const CefString& download_path,
|
||||||
|
bool show_dialog) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, cont))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: download_path; type: string_byref_const
|
||||||
|
DCHECK(!download_path.empty());
|
||||||
|
if (download_path.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->cont(struct_,
|
||||||
|
download_path.GetStruct(),
|
||||||
|
show_dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefBeforeDownloadCallbackCToCpp,
|
||||||
|
CefBeforeDownloadCallback, cef_before_download_callback_t>::DebugObjCt =
|
||||||
|
0;
|
||||||
|
#endif
|
||||||
|
|
43
libcef_dll/ctocpp/before_download_callback_ctocpp.h
Normal file
43
libcef_dll/ctocpp/before_download_callback_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_BEFORE_DOWNLOAD_CALLBACK_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_BEFORE_DOWNLOAD_CALLBACK_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_download_handler.h"
|
||||||
|
#include "include/capi/cef_download_handler_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 CefBeforeDownloadCallbackCToCpp
|
||||||
|
: public CefCToCpp<CefBeforeDownloadCallbackCToCpp,
|
||||||
|
CefBeforeDownloadCallback, cef_before_download_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefBeforeDownloadCallbackCToCpp(cef_before_download_callback_t* str)
|
||||||
|
: CefCToCpp<CefBeforeDownloadCallbackCToCpp, CefBeforeDownloadCallback,
|
||||||
|
cef_before_download_callback_t>(str) {}
|
||||||
|
virtual ~CefBeforeDownloadCallbackCToCpp() {}
|
||||||
|
|
||||||
|
// CefBeforeDownloadCallback methods
|
||||||
|
virtual void Continue(const CefString& download_path,
|
||||||
|
bool show_dialog) OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_BEFORE_DOWNLOAD_CALLBACK_CTOCPP_H_
|
||||||
|
|
@ -15,6 +15,7 @@
|
|||||||
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/download_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h"
|
||||||
@ -53,6 +54,19 @@ CefRefPtr<CefDisplayHandler> CefClientCToCpp::GetDisplayHandler() {
|
|||||||
return CefDisplayHandlerCToCpp::Wrap(_retval);
|
return CefDisplayHandlerCToCpp::Wrap(_retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefDownloadHandler> CefClientCToCpp::GetDownloadHandler() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_download_handler))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_download_handler_t* _retval = struct_->get_download_handler(struct_);
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefDownloadHandlerCToCpp::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
CefRefPtr<CefFocusHandler> CefClientCToCpp::GetFocusHandler() {
|
CefRefPtr<CefFocusHandler> CefClientCToCpp::GetFocusHandler() {
|
||||||
if (CEF_MEMBER_MISSING(struct_, get_focus_handler))
|
if (CEF_MEMBER_MISSING(struct_, get_focus_handler))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -34,6 +34,7 @@ class CefClientCToCpp
|
|||||||
// CefClient methods
|
// CefClient methods
|
||||||
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE;
|
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE;
|
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE;
|
||||||
|
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE;
|
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE;
|
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE;
|
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE;
|
||||||
|
88
libcef_dll/ctocpp/download_handler_ctocpp.cc
Normal file
88
libcef_dll/ctocpp/download_handler_ctocpp.cc
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// 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/before_download_callback_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/download_item_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/download_item_callback_cpptoc.h"
|
||||||
|
#include "libcef_dll/ctocpp/download_handler_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CefDownloadHandlerCToCpp::OnBeforeDownload(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item, const CefString& suggested_name,
|
||||||
|
CefRefPtr<CefBeforeDownloadCallback> callback) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_before_download))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: browser; type: refptr_diff
|
||||||
|
DCHECK(browser.get());
|
||||||
|
if (!browser.get())
|
||||||
|
return;
|
||||||
|
// Verify param: download_item; type: refptr_diff
|
||||||
|
DCHECK(download_item.get());
|
||||||
|
if (!download_item.get())
|
||||||
|
return;
|
||||||
|
// Verify param: suggested_name; type: string_byref_const
|
||||||
|
DCHECK(!suggested_name.empty());
|
||||||
|
if (suggested_name.empty())
|
||||||
|
return;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback.get());
|
||||||
|
if (!callback.get())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->on_before_download(struct_,
|
||||||
|
CefBrowserCppToC::Wrap(browser),
|
||||||
|
CefDownloadItemCppToC::Wrap(download_item),
|
||||||
|
suggested_name.GetStruct(),
|
||||||
|
CefBeforeDownloadCallbackCppToC::Wrap(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefDownloadHandlerCToCpp::OnDownloadUpdated(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item,
|
||||||
|
CefRefPtr<CefDownloadItemCallback> callback) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_download_updated))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: browser; type: refptr_diff
|
||||||
|
DCHECK(browser.get());
|
||||||
|
if (!browser.get())
|
||||||
|
return;
|
||||||
|
// Verify param: download_item; type: refptr_diff
|
||||||
|
DCHECK(download_item.get());
|
||||||
|
if (!download_item.get())
|
||||||
|
return;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback.get());
|
||||||
|
if (!callback.get())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->on_download_updated(struct_,
|
||||||
|
CefBrowserCppToC::Wrap(browser),
|
||||||
|
CefDownloadItemCppToC::Wrap(download_item),
|
||||||
|
CefDownloadItemCallbackCppToC::Wrap(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefDownloadHandlerCToCpp, CefDownloadHandler,
|
||||||
|
cef_download_handler_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
48
libcef_dll/ctocpp/download_handler_ctocpp.h
Normal file
48
libcef_dll/ctocpp/download_handler_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_DOWNLOAD_HANDLER_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_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_download_handler.h"
|
||||||
|
#include "include/capi/cef_download_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 CefDownloadHandlerCToCpp
|
||||||
|
: public CefCToCpp<CefDownloadHandlerCToCpp, CefDownloadHandler,
|
||||||
|
cef_download_handler_t> {
|
||||||
|
public:
|
||||||
|
explicit CefDownloadHandlerCToCpp(cef_download_handler_t* str)
|
||||||
|
: CefCToCpp<CefDownloadHandlerCToCpp, CefDownloadHandler,
|
||||||
|
cef_download_handler_t>(str) {}
|
||||||
|
virtual ~CefDownloadHandlerCToCpp() {}
|
||||||
|
|
||||||
|
// CefDownloadHandler methods
|
||||||
|
virtual void OnBeforeDownload(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item,
|
||||||
|
const CefString& suggested_name,
|
||||||
|
CefRefPtr<CefBeforeDownloadCallback> callback) OVERRIDE;
|
||||||
|
virtual void OnDownloadUpdated(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item,
|
||||||
|
CefRefPtr<CefDownloadItemCallback> callback) OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_HANDLER_CTOCPP_H_
|
||||||
|
|
33
libcef_dll/ctocpp/download_item_callback_ctocpp.cc
Normal file
33
libcef_dll/ctocpp/download_item_callback_ctocpp.cc
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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/download_item_callback_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CefDownloadItemCallbackCToCpp::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<CefDownloadItemCallbackCToCpp,
|
||||||
|
CefDownloadItemCallback, cef_download_item_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
42
libcef_dll/ctocpp/download_item_callback_ctocpp.h
Normal file
42
libcef_dll/ctocpp/download_item_callback_ctocpp.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// 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_DOWNLOAD_ITEM_CALLBACK_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CALLBACK_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_download_handler.h"
|
||||||
|
#include "include/capi/cef_download_handler_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 CefDownloadItemCallbackCToCpp
|
||||||
|
: public CefCToCpp<CefDownloadItemCallbackCToCpp, CefDownloadItemCallback,
|
||||||
|
cef_download_item_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefDownloadItemCallbackCToCpp(cef_download_item_callback_t* str)
|
||||||
|
: CefCToCpp<CefDownloadItemCallbackCToCpp, CefDownloadItemCallback,
|
||||||
|
cef_download_item_callback_t>(str) {}
|
||||||
|
virtual ~CefDownloadItemCallbackCToCpp() {}
|
||||||
|
|
||||||
|
// CefDownloadItemCallback methods
|
||||||
|
virtual void Cancel() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CALLBACK_CTOCPP_H_
|
||||||
|
|
256
libcef_dll/ctocpp/download_item_ctocpp.cc
Normal file
256
libcef_dll/ctocpp/download_item_ctocpp.cc
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
// 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/download_item_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
bool CefDownloadItemCToCpp::IsValid() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, is_valid))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->is_valid(struct_);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDownloadItemCToCpp::IsInProgress() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, is_in_progress))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->is_in_progress(struct_);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDownloadItemCToCpp::IsComplete() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, is_complete))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->is_complete(struct_);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDownloadItemCToCpp::IsCanceled() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, is_canceled))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->is_canceled(struct_);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 CefDownloadItemCToCpp::GetCurrentSpeed() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_current_speed))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int64 _retval = struct_->get_current_speed(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CefDownloadItemCToCpp::GetPercentComplete() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_percent_complete))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->get_percent_complete(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 CefDownloadItemCToCpp::GetTotalBytes() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_total_bytes))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int64 _retval = struct_->get_total_bytes(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 CefDownloadItemCToCpp::GetReceivedBytes() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_received_bytes))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int64 _retval = struct_->get_received_bytes(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefTime CefDownloadItemCToCpp::GetStartTime() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_start_time))
|
||||||
|
return CefTime();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_time_t _retval = struct_->get_start_time(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefTime CefDownloadItemCToCpp::GetEndTime() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_end_time))
|
||||||
|
return CefTime();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_time_t _retval = struct_->get_end_time(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemCToCpp::GetFullPath() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_full_path))
|
||||||
|
return CefString();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_string_userfree_t _retval = struct_->get_full_path(struct_);
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
CefString _retvalStr;
|
||||||
|
_retvalStr.AttachToUserFree(_retval);
|
||||||
|
return _retvalStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 CefDownloadItemCToCpp::GetId() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_id))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int32 _retval = struct_->get_id(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemCToCpp::GetURL() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_url))
|
||||||
|
return CefString();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_string_userfree_t _retval = struct_->get_url(struct_);
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
CefString _retvalStr;
|
||||||
|
_retvalStr.AttachToUserFree(_retval);
|
||||||
|
return _retvalStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemCToCpp::GetSuggestedFileName() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_suggested_file_name))
|
||||||
|
return CefString();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_string_userfree_t _retval = struct_->get_suggested_file_name(struct_);
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
CefString _retvalStr;
|
||||||
|
_retvalStr.AttachToUserFree(_retval);
|
||||||
|
return _retvalStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemCToCpp::GetContentDisposition() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_content_disposition))
|
||||||
|
return CefString();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_string_userfree_t _retval = struct_->get_content_disposition(struct_);
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
CefString _retvalStr;
|
||||||
|
_retvalStr.AttachToUserFree(_retval);
|
||||||
|
return _retvalStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemCToCpp::GetMimeType() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_mime_type))
|
||||||
|
return CefString();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_string_userfree_t _retval = struct_->get_mime_type(struct_);
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
CefString _retvalStr;
|
||||||
|
_retvalStr.AttachToUserFree(_retval);
|
||||||
|
return _retvalStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDownloadItemCToCpp::GetReferrerCharset() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_referrer_charset))
|
||||||
|
return CefString();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_string_userfree_t _retval = struct_->get_referrer_charset(struct_);
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
CefString _retvalStr;
|
||||||
|
_retvalStr.AttachToUserFree(_retval);
|
||||||
|
return _retvalStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefDownloadItemCToCpp, CefDownloadItem,
|
||||||
|
cef_download_item_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
58
libcef_dll/ctocpp/download_item_ctocpp.h
Normal file
58
libcef_dll/ctocpp/download_item_ctocpp.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// 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_DOWNLOAD_ITEM_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_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_download_item.h"
|
||||||
|
#include "include/capi/cef_download_item_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 CefDownloadItemCToCpp
|
||||||
|
: public CefCToCpp<CefDownloadItemCToCpp, CefDownloadItem,
|
||||||
|
cef_download_item_t> {
|
||||||
|
public:
|
||||||
|
explicit CefDownloadItemCToCpp(cef_download_item_t* str)
|
||||||
|
: CefCToCpp<CefDownloadItemCToCpp, CefDownloadItem, cef_download_item_t>(
|
||||||
|
str) {}
|
||||||
|
virtual ~CefDownloadItemCToCpp() {}
|
||||||
|
|
||||||
|
// CefDownloadItem methods
|
||||||
|
virtual bool IsValid() OVERRIDE;
|
||||||
|
virtual bool IsInProgress() OVERRIDE;
|
||||||
|
virtual bool IsComplete() OVERRIDE;
|
||||||
|
virtual bool IsCanceled() OVERRIDE;
|
||||||
|
virtual int64 GetCurrentSpeed() OVERRIDE;
|
||||||
|
virtual int GetPercentComplete() OVERRIDE;
|
||||||
|
virtual int64 GetTotalBytes() OVERRIDE;
|
||||||
|
virtual int64 GetReceivedBytes() OVERRIDE;
|
||||||
|
virtual CefTime GetStartTime() OVERRIDE;
|
||||||
|
virtual CefTime GetEndTime() OVERRIDE;
|
||||||
|
virtual CefString GetFullPath() OVERRIDE;
|
||||||
|
virtual int32 GetId() OVERRIDE;
|
||||||
|
virtual CefString GetURL() OVERRIDE;
|
||||||
|
virtual CefString GetSuggestedFileName() OVERRIDE;
|
||||||
|
virtual CefString GetContentDisposition() OVERRIDE;
|
||||||
|
virtual CefString GetMimeType() OVERRIDE;
|
||||||
|
virtual CefString GetReferrerCharset() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CTOCPP_H_
|
||||||
|
|
@ -29,6 +29,7 @@
|
|||||||
#include "include/cef_web_plugin.h"
|
#include "include/cef_web_plugin.h"
|
||||||
#include "include/capi/cef_web_plugin_capi.h"
|
#include "include/capi/cef_web_plugin_capi.h"
|
||||||
#include "libcef_dll/cpptoc/auth_callback_cpptoc.h"
|
#include "libcef_dll/cpptoc/auth_callback_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/before_download_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/binary_value_cpptoc.h"
|
#include "libcef_dll/cpptoc/binary_value_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
|
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
|
||||||
@ -40,6 +41,8 @@
|
|||||||
#include "libcef_dll/cpptoc/domevent_cpptoc.h"
|
#include "libcef_dll/cpptoc/domevent_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/domnode_cpptoc.h"
|
#include "libcef_dll/cpptoc/domnode_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
|
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/download_item_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/download_item_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/frame_cpptoc.h"
|
#include "libcef_dll/cpptoc/frame_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h"
|
#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h"
|
#include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h"
|
||||||
@ -63,6 +66,7 @@
|
|||||||
#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h"
|
#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/domvisitor_ctocpp.h"
|
#include "libcef_dll/ctocpp/domvisitor_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/download_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h"
|
||||||
@ -153,6 +157,7 @@ CEF_EXPORT void cef_shutdown() {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// Check that all wrapper objects have been destroyed
|
// Check that all wrapper objects have been destroyed
|
||||||
DCHECK_EQ(CefAuthCallbackCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefAuthCallbackCppToC::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefBeforeDownloadCallbackCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefBinaryValueCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefBinaryValueCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefBrowserCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefBrowserCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefBrowserHostCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefBrowserHostCppToC::DebugObjCt, 0);
|
||||||
@ -169,6 +174,9 @@ CEF_EXPORT void cef_shutdown() {
|
|||||||
DCHECK_EQ(CefDOMVisitorCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefDOMVisitorCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefDictionaryValueCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefDictionaryValueCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefDisplayHandlerCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefDisplayHandlerCToCpp::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefDownloadHandlerCToCpp::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefDownloadItemCallbackCppToC::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefDownloadItemCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefFocusHandlerCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefFocusHandlerCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefFrameCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefFrameCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefGeolocationCallbackCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefGeolocationCallbackCppToC::DebugObjCt, 0);
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
|
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/domvisitor_cpptoc.h"
|
#include "libcef_dll/cpptoc/domvisitor_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/download_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
|
||||||
@ -57,6 +58,7 @@
|
|||||||
#include "libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h"
|
#include "libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/write_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/write_handler_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/auth_callback_ctocpp.h"
|
#include "libcef_dll/ctocpp/auth_callback_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/before_download_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/binary_value_ctocpp.h"
|
#include "libcef_dll/ctocpp/binary_value_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
||||||
@ -68,6 +70,8 @@
|
|||||||
#include "libcef_dll/ctocpp/domevent_ctocpp.h"
|
#include "libcef_dll/ctocpp/domevent_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/domnode_ctocpp.h"
|
#include "libcef_dll/ctocpp/domnode_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
|
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/download_item_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/download_item_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/frame_ctocpp.h"
|
#include "libcef_dll/ctocpp/frame_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h"
|
#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h"
|
#include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h"
|
||||||
@ -145,6 +149,7 @@ CEF_GLOBAL void CefShutdown() {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// Check that all wrapper objects have been destroyed
|
// Check that all wrapper objects have been destroyed
|
||||||
DCHECK_EQ(CefAuthCallbackCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefAuthCallbackCToCpp::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefBeforeDownloadCallbackCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefBinaryValueCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefBinaryValueCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefBrowserCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefBrowserCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefBrowserHostCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefBrowserHostCToCpp::DebugObjCt, 0);
|
||||||
@ -161,6 +166,9 @@ CEF_GLOBAL void CefShutdown() {
|
|||||||
DCHECK_EQ(CefDOMVisitorCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefDOMVisitorCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefDictionaryValueCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefDictionaryValueCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefDisplayHandlerCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefDisplayHandlerCppToC::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefDownloadHandlerCppToC::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefDownloadItemCToCpp::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefDownloadItemCallbackCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefFocusHandlerCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefFocusHandlerCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefFrameCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefFrameCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefGeolocationCallbackCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefGeolocationCallbackCToCpp::DebugObjCt, 0);
|
||||||
|
@ -179,6 +179,27 @@ bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientHandler::OnBeforeDownload(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item,
|
||||||
|
const CefString& suggested_name,
|
||||||
|
CefRefPtr<CefBeforeDownloadCallback> callback) {
|
||||||
|
REQUIRE_UI_THREAD();
|
||||||
|
// Continue the download and show the "Save As" dialog.
|
||||||
|
callback->Continue(GetDownloadPath(suggested_name), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientHandler::OnDownloadUpdated(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item,
|
||||||
|
CefRefPtr<CefDownloadItemCallback> callback) {
|
||||||
|
REQUIRE_UI_THREAD();
|
||||||
|
if (download_item->IsComplete()) {
|
||||||
|
SetLastDownloadFile(download_item->GetFullPath());
|
||||||
|
SendNotification(NOTIFY_DOWNLOAD_COMPLETE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ClientHandler::OnRequestGeolocationPermission(
|
void ClientHandler::OnRequestGeolocationPermission(
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
const CefString& requesting_url,
|
const CefString& requesting_url,
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
class ClientHandler : public CefClient,
|
class ClientHandler : public CefClient,
|
||||||
public CefContextMenuHandler,
|
public CefContextMenuHandler,
|
||||||
public CefDisplayHandler,
|
public CefDisplayHandler,
|
||||||
|
public CefDownloadHandler,
|
||||||
public CefGeolocationHandler,
|
public CefGeolocationHandler,
|
||||||
public CefKeyboardHandler,
|
public CefKeyboardHandler,
|
||||||
public CefLifeSpanHandler,
|
public CefLifeSpanHandler,
|
||||||
@ -74,6 +75,9 @@ class ClientHandler : public CefClient,
|
|||||||
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
|
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE {
|
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -120,6 +124,17 @@ class ClientHandler : public CefClient,
|
|||||||
const CefString& source,
|
const CefString& source,
|
||||||
int line) OVERRIDE;
|
int line) OVERRIDE;
|
||||||
|
|
||||||
|
// CefDownloadHandler methods
|
||||||
|
virtual void OnBeforeDownload(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item,
|
||||||
|
const CefString& suggested_name,
|
||||||
|
CefRefPtr<CefBeforeDownloadCallback> callback) OVERRIDE;
|
||||||
|
virtual void OnDownloadUpdated(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDownloadItem> download_item,
|
||||||
|
CefRefPtr<CefDownloadItemCallback> callback) OVERRIDE;
|
||||||
|
|
||||||
// CefGeolocationHandler methods
|
// CefGeolocationHandler methods
|
||||||
virtual void OnRequestGeolocationPermission(
|
virtual void OnRequestGeolocationPermission(
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
@ -215,6 +230,10 @@ class ClientHandler : public CefClient,
|
|||||||
int radio_item;
|
int radio_item;
|
||||||
} m_TestMenuState;
|
} m_TestMenuState;
|
||||||
|
|
||||||
|
// Returns the full download path for the specified file, or an empty path to
|
||||||
|
// use the default temp directory.
|
||||||
|
std::string GetDownloadPath(const std::string& file_name);
|
||||||
|
|
||||||
// The child browser window
|
// The child browser window
|
||||||
CefRefPtr<CefBrowser> m_Browser;
|
CefRefPtr<CefBrowser> m_Browser;
|
||||||
|
|
||||||
|
@ -57,3 +57,7 @@ void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) {
|
|||||||
void ClientHandler::CloseMainWindow() {
|
void ClientHandler::CloseMainWindow() {
|
||||||
// TODO(port): Close main window.
|
// TODO(port): Close main window.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ClientHandler::GetDownloadPath(const std::string& file_name) {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
@ -68,3 +68,7 @@ void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) {
|
|||||||
void ClientHandler::CloseMainWindow() {
|
void ClientHandler::CloseMainWindow() {
|
||||||
// TODO(port): Close window
|
// TODO(port): Close window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ClientHandler::GetDownloadPath(const std::string& file_name) {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "cefclient/client_handler.h"
|
#include "cefclient/client_handler.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
|
||||||
#include "include/cef_browser.h"
|
#include "include/cef_browser.h"
|
||||||
#include "include/cef_frame.h"
|
#include "include/cef_frame.h"
|
||||||
#include "cefclient/resource.h"
|
#include "cefclient/resource.h"
|
||||||
@ -66,3 +70,17 @@ void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) {
|
|||||||
void ClientHandler::CloseMainWindow() {
|
void ClientHandler::CloseMainWindow() {
|
||||||
::PostMessage(m_MainHwnd, WM_CLOSE, 0, 0);
|
::PostMessage(m_MainHwnd, WM_CLOSE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ClientHandler::GetDownloadPath(const std::string& file_name) {
|
||||||
|
TCHAR szFolderPath[MAX_PATH];
|
||||||
|
std::string path;
|
||||||
|
|
||||||
|
// Save the file in the user's "My Documents" folder.
|
||||||
|
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE,
|
||||||
|
NULL, 0, szFolderPath))) {
|
||||||
|
path = CefString(szFolderPath);
|
||||||
|
path += "\\" + file_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user