- 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:
Marshall Greenblatt
2012-06-28 17:21:18 +00:00
parent 14bbc90ddb
commit 421001ba9d
51 changed files with 2685 additions and 171 deletions

View 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

View 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_

View File

@ -15,6 +15,7 @@
#include "libcef_dll/ctocpp/client_ctocpp.h"
#include "libcef_dll/ctocpp/context_menu_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/geolocation_handler_ctocpp.h"
#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h"
@ -53,6 +54,19 @@ CefRefPtr<CefDisplayHandler> CefClientCToCpp::GetDisplayHandler() {
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() {
if (CEF_MEMBER_MISSING(struct_, get_focus_handler))
return NULL;

View File

@ -34,6 +34,7 @@ class CefClientCToCpp
// CefClient methods
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE;
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE;
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE;
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE;
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE;
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE;

View 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

View 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_

View 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

View 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_

View 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

View 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_