- Add the CefHandler::HandleDownloadResponse() method and CefDownloadHandler class to support file download in response to 'Content-Disposition' headers (issue #6).

- Fix parsing error in cef_parser.py due to space between angle brackets in template type definitions, and add support for int64 type.
- Update copyright messages in Python and generated files.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@117 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2010-10-16 19:10:11 +00:00
parent 6db1d580cd
commit 9aa285ac8d
85 changed files with 831 additions and 81 deletions

View File

@ -33,6 +33,8 @@
'tests/cefclient/cefclient.rc',
'tests/cefclient/clientplugin.cpp',
'tests/cefclient/clientplugin.h',
'tests/cefclient/download_handler.cpp',
'tests/cefclient/download_handler.h',
'tests/cefclient/extension_test.cpp',
'tests/cefclient/extension_test.h',
'tests/cefclient/plugin_test.cpp',
@ -52,6 +54,7 @@
'tests/cefclient/uiplugin.h',
'tests/cefclient/uiplugin_test.cpp',
'tests/cefclient/uiplugin_test.h',
'tests/cefclient/util.h',
],
'conditions': [
['OS=="win"', {
@ -214,6 +217,8 @@
'libcef_dll/cpptoc/v8value_cpptoc.cc',
'libcef_dll/cpptoc/v8value_cpptoc.h',
'libcef_dll/ctocpp/ctocpp.h',
'libcef_dll/ctocpp/download_handler_ctocpp.cc',
'libcef_dll/ctocpp/download_handler_ctocpp.h',
'libcef_dll/ctocpp/handler_ctocpp.cc',
'libcef_dll/ctocpp/handler_ctocpp.h',
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
@ -271,6 +276,8 @@
'sources': [
'libcef_dll/cef_logging.h',
'libcef_dll/cpptoc/cpptoc.h',
'libcef_dll/cpptoc/download_handler_cpptoc.cc',
'libcef_dll/cpptoc/download_handler_cpptoc.h',
'libcef_dll/cpptoc/handler_cpptoc.cc',
'libcef_dll/cpptoc/handler_cpptoc.h',
'libcef_dll/cpptoc/read_handler_cpptoc.cc',

View File

@ -45,6 +45,7 @@
#include "cef_types.h"
class CefBrowser;
class CefDownloadHandler;
class CefFrame;
class CefHandler;
class CefPostData;
@ -617,6 +618,20 @@ public:
std::wstring& mimeType,
int loadFlags) =0;
// Called when a server indicates via the 'Content-Disposition' header that a
// response represents a file to download. |mimeType| is the mime type for
// the download, |fileName| is the suggested target file name and
// |contentLength| is either the value of the 'Content-Size' header or -1 if
// no size was provided. Set |handler| to the CefDownloadHandler instance that
// will recieve the file contents. Return RV_CONTINUE to download the file
// or RV_HANDLED to cancel the file download.
/*--cef()--*/
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
const std::wstring& mimeType,
const std::wstring& fileName,
int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler) =0;
// Structure representing menu information.
typedef cef_handler_menuinfo_t MenuInfo;
@ -1201,4 +1216,20 @@ public:
};
// Class used to handle file downloads.
/*--cef(source=client)--*/
class CefDownloadHandler : public CefBase
{
public:
// A portion of the file contents have been received. This method will be
// called multiple times until the download is complete. Return |true| to
// continue receiving data and |false| to cancel.
/*--cef()--*/
virtual bool ReceivedData(void* data, int data_size) =0;
// The download is complete.
/*--cef()--*/
virtual void Complete() =0;
};
#endif // _CEF_H

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
// Copyright (c) 2010 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
@ -445,6 +445,18 @@ typedef struct _cef_handler_t
struct _cef_stream_reader_t** resourceStream, cef_string_t* mimeType,
int loadFlags);
// Called when a server indicates via the 'Content-Disposition' header that a
// response represents a file to download. |mimeType| is the mime type for the
// download, |fileName| is the suggested target file name and |contentLength|
// is either the value of the 'Content-Size' header or -1 if no size was
// provided. Set |handler| to the cef_download_handler_t instance that will
// recieve the file contents. Return RV_CONTINUE to download the file or
// RV_HANDLED to cancel the file download.
enum cef_retval_t (CEF_CALLBACK *handle_download_response)(
struct _cef_handler_t* self, struct _cef_browser_t* browser,
const wchar_t* mimeType, const wchar_t* fileName, int64 contentLength,
struct _cef_download_handler_t** handler);
// Event called before a context menu is displayed. To cancel display of the
// default context menu return RV_HANDLED.
enum cef_retval_t (CEF_CALLBACK *handle_before_menu)(
@ -974,6 +986,24 @@ typedef struct _cef_scheme_handler_t
} cef_scheme_handler_t;
// Structure used to handle file downloads.
typedef struct _cef_download_handler_t
{
// Base structure.
cef_base_t base;
// A portion of the file contents have been received. This function will be
// called multiple times until the download is complete. Return |true (1)| to
// continue receiving data and |false (0)| to cancel.
int (CEF_CALLBACK *received_data)(struct _cef_download_handler_t* self,
void* data, int data_size);
// The download is complete.
void (CEF_CALLBACK *complete)(struct _cef_download_handler_t* self);
} cef_download_handler_t;
#ifdef __cplusplus
}
#endif

View File

@ -45,6 +45,13 @@ extern "C" {
#include "cef_types_linux.h"
#endif
// The NSPR system headers define 64-bit as |long| when possible. In order to
// not have typedef mismatches, we do the same on LP64.
#if __LP64__
typedef long int64;
#else
typedef long long int64;
#endif
// Define handler return value types. Returning RV_HANDLED indicates
// that the implementation completely handled the method and that no further

View File

@ -35,6 +35,7 @@
#include "browser_resource_loader_bridge.h"
#include "browser_request_context.h"
#include "browser_socket_stream_bridge.h"
#include "browser_webkit_glue.h"
#include "browser_impl.h"
#include "cef_context.h"
#include "cef_process.h"
@ -129,6 +130,11 @@ class RequestProxy : public URLRequest::Delegate,
}
void Cancel() {
if(download_handler_.get()) {
// WebKit will try to cancel the download but we won't allow it.
return;
}
// proxy over to the io thread
CefThread::PostTask(CefThread::IO, FROM_HERE, NewRunnableMethod(
this, &RequestProxy::AsyncCancel));
@ -164,6 +170,22 @@ class RequestProxy : public URLRequest::Delegate,
void NotifyReceivedResponse(const ResourceResponseInfo& info,
bool content_filtered) {
std::string cd_header, filename;
if (info.headers && browser_.get() &&
info.headers->GetNormalizedHeader("Content-Disposition", &cd_header) &&
webkit_glue::IsContentDispositionAttachment(cd_header, filename)) {
// The response represents a download request.
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if (handler.get()) {
CefRefPtr<CefDownloadHandler> dl_handler;
if (handler->HandleDownloadResponse(browser_,
UTF8ToWide(info.mime_type), UTF8ToWide(filename),
info.content_length, dl_handler) == RV_CONTINUE) {
download_handler_ = dl_handler;
}
}
}
if (peer_)
peer_->OnReceivedResponse(info, content_filtered);
}
@ -186,6 +208,13 @@ class RequestProxy : public URLRequest::Delegate,
CefThread::PostTask(CefThread::IO, FROM_HERE, NewRunnableMethod(
this, &RequestProxy::AsyncReadData));
if (download_handler_.get() &&
!download_handler_->ReceivedData(buf_copy.get(), bytes_read)) {
// Cancel loading by proxying over to the io thread.
CefThread::PostTask(CefThread::IO, FROM_HERE, NewRunnableMethod(
this, &RequestProxy::AsyncCancel));
}
peer_->OnReceivedData(buf_copy.get(), bytes_read);
}
@ -203,6 +232,11 @@ class RequestProxy : public URLRequest::Delegate,
void NotifyCompletedRequest(const URLRequestStatus& status,
const std::string& security_info,
const base::Time& complete_time) {
if (download_handler_.get()) {
download_handler_->Complete();
download_handler_ = NULL;
}
if (peer_) {
peer_->OnCompletedRequest(status, security_info, complete_time);
DropPeer(); // ensure no further notifications
@ -594,6 +628,8 @@ class RequestProxy : public URLRequest::Delegate,
// Info used to determine whether or not to send an upload progress update.
uint64 last_upload_position_;
base::TimeTicks last_upload_ticks_;
CefRefPtr<CefDownloadHandler> download_handler_;
};
//-----------------------------------------------------------------------------

View File

@ -9,6 +9,7 @@
MSVC_PUSH_WARNING_LEVEL(0);
#include "Cache.h"
#include "TextEncoding.h"
#include "third_party/WebKit/WebCore/platform/network/HTTPParsers.h"
#include "third_party/WebKit/WebKit/chromium/src/WebFrameImpl.h"
MSVC_POP_WARNING();
@ -145,4 +146,20 @@ void EnableSpdy(bool enable) {
// Used in benchmarking, Ignored for CEF.
}
bool IsContentDispositionAttachment(const std::string& cd_header,
std::string& file_name) {
WTF::String cd_str(cd_header.c_str(), cd_header.length());
if (WebCore::contentDispositionType(cd_str) ==
WebCore::ContentDispositionAttachment) {
WTF::String name_str =
WebCore::filenameFromHTTPContentDisposition(cd_str);
if (!name_str.isEmpty()) {
file_name = WideToUTF8(
std::wstring(name_str.characters(), name_str.length()));
}
return true;
}
return false;
}
} // namespace webkit_glue

View File

@ -47,4 +47,9 @@ WebKit::WebString StdWStringToWebString(const std::wstring& str);
std::wstring WebStringToStdWString(const WebKit::WebString& str);
// Returns true if the specified 'Content-Disposition' header value represents
// an attachment download. Also returns the file name.
bool IsContentDispositionAttachment(const std::string& cd_header,
std::string& file_name);
} // namespace webkit_glue

View File

@ -74,10 +74,6 @@ bool EnsureFontLoaded(HFONT font) {
return true;
}
bool DownloadUrl(const std::string& url, HWND caller_window) {
return false;
}
void CaptureWebViewBitmap(HWND mainWnd, WebView* webview, HBITMAP& bitmap,
SIZE& size)
{

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -0,0 +1,53 @@
// Copyright (c) 2010 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/download_handler_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK download_handler_received_data(
struct _cef_download_handler_t* self, void* data, int data_size)
{
DCHECK(self);
if(!self)
return 0;
return CefDownloadHandlerCppToC::Get(self)->ReceivedData(data, data_size);
}
void CEF_CALLBACK download_handler_complete(
struct _cef_download_handler_t* self)
{
DCHECK(self);
if(!self)
return;
CefDownloadHandlerCppToC::Get(self)->Complete();
}
// CONSTRUCTOR - Do not edit by hand.
CefDownloadHandlerCppToC::CefDownloadHandlerCppToC(CefDownloadHandler* cls)
: CefCppToC<CefDownloadHandlerCppToC, CefDownloadHandler,
cef_download_handler_t>(cls)
{
struct_.struct_.received_data = download_handler_received_data;
struct_.struct_.complete = download_handler_complete;
}
#ifdef _DEBUG
long CefCppToC<CefDownloadHandlerCppToC, CefDownloadHandler,
cef_download_handler_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,35 @@
// Copyright (c) 2010 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 and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _DOWNLOADHANDLER_CPPTOC_H
#define _DOWNLOADHANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_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:
CefDownloadHandlerCppToC(CefDownloadHandler* cls);
virtual ~CefDownloadHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // _DOWNLOADHANDLER_CPPTOC_H

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//
@ -10,6 +10,7 @@
// for more information.
//
#include "libcef_dll/cpptoc/download_handler_cpptoc.h"
#include "libcef_dll/cpptoc/handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
@ -228,6 +229,36 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load(
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_download_response(
struct _cef_handler_t* self, cef_browser_t* browser,
const wchar_t* mimeType, const wchar_t* fileName, int64 contentLength,
struct _cef_download_handler_t** handler)
{
DCHECK(self);
DCHECK(browser);
DCHECK(mimeType);
DCHECK(fileName);
if(!self || !browser || !mimeType || !fileName)
return RV_CONTINUE;
std::wstring mimeTypeStr, fileNameStr;
CefRefPtr<CefDownloadHandler> downloadPtr;
if(mimeType)
mimeTypeStr = mimeType;
if(fileName)
fileNameStr = fileName;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->
HandleDownloadResponse(CefBrowserCToCpp::Wrap(browser), mimeTypeStr,
fileNameStr, contentLength, downloadPtr);
if(downloadPtr.get())
*handler = CefDownloadHandlerCppToC::Wrap(downloadPtr);
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_before_menu(
struct _cef_handler_t* self, cef_browser_t* browser,
const cef_handler_menuinfo_t* menuInfo)
@ -559,6 +590,7 @@ CefHandlerCppToC::CefHandlerCppToC(CefHandler* cls)
struct_.struct_.handle_load_error = handler_handle_load_error;
struct_.struct_.handle_before_resource_load =
handler_handle_before_resource_load;
struct_.struct_.handle_download_response = handler_handle_download_response;
struct_.struct_.handle_before_menu = handler_handle_before_menu;
struct_.struct_.handle_get_menu_label = handler_handle_get_menu_label;
struct_.struct_.handle_menu_action = handler_handle_menu_action;

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -0,0 +1,39 @@
// Copyright (c) 2010 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "libcef_dll/ctocpp/download_handler_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
bool CefDownloadHandlerCToCpp::ReceivedData(void* data, int data_size)
{
if(CEF_MEMBER_MISSING(struct_, received_data))
return false;
return struct_->received_data(struct_, data, data_size) ? true : false;
}
void CefDownloadHandlerCToCpp::Complete()
{
if(CEF_MEMBER_MISSING(struct_, complete))
return;
return struct_->complete(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefDownloadHandlerCToCpp, CefDownloadHandler,
cef_download_handler_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,42 @@
// Copyright (c) 2010 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 and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _DOWNLOADHANDLER_CTOCPP_H
#define _DOWNLOADHANDLER_CTOCPP_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_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:
CefDownloadHandlerCToCpp(cef_download_handler_t* str)
: CefCToCpp<CefDownloadHandlerCToCpp, CefDownloadHandler,
cef_download_handler_t>(str) {}
virtual ~CefDownloadHandlerCToCpp() {}
// CefDownloadHandler methods
virtual bool ReceivedData(void* data, int data_size);
virtual void Complete();
};
#endif // BUILDING_CEF_SHARED
#endif // _DOWNLOADHANDLER_CTOCPP_H

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//
@ -15,6 +15,7 @@
#include "libcef_dll/cpptoc/request_cpptoc.h"
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
#include "libcef_dll/cpptoc/v8value_cpptoc.h"
#include "libcef_dll/ctocpp/download_handler_ctocpp.h"
#include "libcef_dll/ctocpp/handler_ctocpp.h"
#include "libcef_dll/transfer_util.h"
@ -178,6 +179,26 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeResourceLoad(
return rv;
}
CefHandler::RetVal CefHandlerCToCpp::HandleDownloadResponse(
CefRefPtr<CefBrowser> browser, const std::wstring& mimeType,
const std::wstring& fileName, int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler)
{
if(CEF_MEMBER_MISSING(struct_, handle_download_response))
return RV_CONTINUE;
cef_download_handler_t* handlerRet = NULL;
cef_retval_t rv = struct_->handle_download_response(struct_,
CefBrowserCppToC::Wrap(browser), mimeType.c_str(), fileName.c_str(),
contentLength, &handlerRet);
if(handlerRet)
handler = CefDownloadHandlerCToCpp::Wrap(handlerRet);
return rv;
}
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeMenu(
CefRefPtr<CefBrowser> browser, const MenuInfo& menuInfo)
{

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//
@ -53,6 +53,9 @@ public:
CefRefPtr<CefRequest> request, std::wstring& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream, std::wstring& mimeType,
int loadFlags);
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
const std::wstring& mimeType, const std::wstring& fileName,
int64 contentLength, CefRefPtr<CefDownloadHandler>& handler);
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
const MenuInfo& menuInfo);
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2010 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.
//

View File

@ -5,12 +5,14 @@
#include "include/cef.h"
#include "cefclient.h"
#include "binding_test.h"
#include "download_handler.h"
#include "extension_test.h"
#include "plugin_test.h"
#include "resource_util.h"
#include "scheme_test.h"
#include "string_util.h"
#include "uiplugin_test.h"
#include "util.h"
#include <sstream>
#include <commdlg.h>
@ -191,7 +193,35 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
class ClientHandler : public CefThreadSafeBase<CefHandler>
{
public:
// Implements the DownloadListener interface.
class ClientDownloadListener : public CefThreadSafeBase<DownloadListener>
{
public:
ClientDownloadListener(ClientHandler* handler) : handler_(handler) {}
// Called when the download is complete.
virtual void NotifyDownloadComplete(const std::wstring& fileName)
{
handler_->SetLastDownloadFile(fileName);
PostMessage(handler_->GetMainHwnd(), WM_COMMAND,
ID_WARN_DOWNLOADCOMPLETE, 0);
}
// Called if the download fails.
virtual void NotifyDownloadError(const std::wstring& fileName)
{
handler_->SetLastDownloadFile(fileName);
PostMessage(handler_->GetMainHwnd(), WM_COMMAND,
ID_WARN_DOWNLOADERROR, 0);
}
private:
ClientHandler* handler_;
};
ClientHandler()
: ALLOW_THIS_IN_INITIALIZER_LIST(
m_DownloadListener(new ClientDownloadListener(this)))
{
m_MainHwnd = NULL;
m_BrowserHwnd = NULL;
@ -399,6 +429,25 @@ public:
return RV_CONTINUE;
}
// Called when a server indicates via the 'Content-Disposition' header that a
// response represents a file to download. |mime_type| is the mime type for
// the download, |file_name| is the suggested target file name and
// |content_length| is either the value of the 'Content-Size' header or -1 if
// no size was provided. Set |handler| to the CefDownloadHandler instance that
// will recieve the file contents. Return RV_CONTINUE to download the file
// or RV_HANDLED to cancel the file download.
/*--cef()--*/
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
const std::wstring& mimeType,
const std::wstring& fileName,
int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler)
{
// Create the handler for the file download.
handler = CreateDownloadHandler(m_DownloadListener, fileName);
return RV_CONTINUE;
}
// Event called before a context menu is displayed. To cancel display of the
// default context menu return RV_HANDLED.
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
@ -407,7 +456,6 @@ public:
return RV_CONTINUE;
}
// Event called to optionally override the default text for a context menu
// item. |label| contains the default text and may be modified to substitute
// alternate text. The return value is currently ignored.
@ -668,6 +716,22 @@ public:
return str;
}
void SetLastDownloadFile(const std::wstring& fileName)
{
Lock();
m_LastDownloadFile = fileName;
Unlock();
}
std::wstring GetLastDownloadFile()
{
std::wstring str;
Lock();
str = m_LastDownloadFile;
Unlock();
return str;
}
protected:
// The child browser window
CefRefPtr<CefBrowser> m_Browser;
@ -689,6 +753,10 @@ protected:
bool m_bCanGoForward;
std::wstring m_LogFile;
// Support for downloading files.
CefRefPtr<DownloadListener> m_DownloadListener;
std::wstring m_LastDownloadFile;
};
// global handler instance
@ -941,6 +1009,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
MB_OK | MB_ICONINFORMATION);
}
return 0;
case ID_WARN_DOWNLOADCOMPLETE:
case ID_WARN_DOWNLOADERROR:
if(g_handler.get()) {
std::wstringstream ss;
ss << L"File \"" << g_handler->GetLastDownloadFile() << L"\" ";
if(wmId == ID_WARN_DOWNLOADCOMPLETE)
ss << L"downloaded successfully.";
else
ss << L"failed to download.";
MessageBoxW(hWnd, ss.str().c_str(), L"File Download",
MB_OK | MB_ICONINFORMATION);
}
return 0;
case ID_FIND:
if(!hFindDlg)
{

View File

@ -0,0 +1,229 @@
// Copyright (c) 2010 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 "download_handler.h"
#include "util.h"
#ifdef _WIN32
#include <windows.h>
#include <shlobj.h>
#include <shlwapi.h>
#endif // _WIN32
#include <sstream>
#include <vector>
namespace {
// Template for creating a task that executes a method with no arguments.
template <class T, class Method>
class Task : public CefThreadSafeBase<CefTask>
{
public:
Task(T* object, Method method)
: object_(object), method_(method) {}
virtual void Execute(CefThreadId threadId)
{
(object_->*method_)();
}
protected:
CefRefPtr<T> object_;
Method method_;
};
// Helper method for posting a task on a specific thread.
template <class T, class Method>
inline void PostOnThread(CefThreadId threadId,
T* object,
Method method) {
CefRefPtr<CefTask> task = new Task<T,Method>(object, method);
CefPostTask(threadId, task);
}
} // namespace
// Implementation of the CefDownloadHandler interface.
class ClientDownloadHandler : public CefThreadSafeBase<CefDownloadHandler>
{
public:
ClientDownloadHandler(CefRefPtr<DownloadListener> listener,
const std::wstring& fileName)
: listener_(listener), filename_(fileName), file_(NULL)
{
// Open the file on the FILE thread.
PostOnThread(TID_FILE, this, &ClientDownloadHandler::OnOpen);
}
~ClientDownloadHandler()
{
ASSERT(pending_data_.empty());
ASSERT(file_ == NULL);
if(!pending_data_.empty()) {
// Delete remaining pending data.
std::vector<std::vector<char>*>::iterator it = pending_data_.begin();
for(; it != pending_data_.end(); ++it)
delete (*it);
}
if(file_) {
// Close the dangling file pointer on the FILE thread.
class TaskCloseFile : public CefThreadSafeBase<CefTask>
{
public:
TaskCloseFile(FILE* file) : file_(file) {}
virtual void Execute(CefThreadId threadId) { fclose(file_); }
private:
FILE* file_;
};
CefPostTask(TID_FILE, new TaskCloseFile(file_));
// Notify the listener that the download failed.
listener_->NotifyDownloadError(filename_);
}
}
// --------------------------------------------------
// The following methods are called on the UI thread.
// --------------------------------------------------
// A portion of the file contents have been received. This method will be
// called multiple times until the download is complete. Return |true| to
// continue receiving data and |false| to cancel.
virtual bool ReceivedData(void* data, int data_size)
{
ASSERT(CefCurrentlyOn(TID_UI));
if(data_size == 0)
return true;
// Create a new vector for the data.
std::vector<char>* buffer = new std::vector<char>(data_size);
memcpy(&(*buffer)[0], data, data_size);
// Add the new data vector to the pending data queue.
Lock();
pending_data_.push_back(buffer);
Unlock();
// Write data to file on the FILE thread.
PostOnThread(TID_FILE, this, &ClientDownloadHandler::OnReceivedData);
return true;
}
// The download is complete.
virtual void Complete()
{
ASSERT(CefCurrentlyOn(TID_UI));
// Flush and close the file on the FILE thread.
PostOnThread(TID_FILE, this, &ClientDownloadHandler::OnComplete);
}
// ----------------------------------------------------
// The following methods are called on the FILE thread.
// ----------------------------------------------------
void OnOpen()
{
ASSERT(CefCurrentlyOn(TID_FILE));
if(file_)
return;
#ifdef _WIN32
TCHAR szFolderPath[MAX_PATH];
// Save the file in the user's "My Documents" folder.
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE,
NULL, 0, szFolderPath))) {
LPWSTR name = PathFindFileName(filename_.c_str());
LPWSTR ext = PathFindExtension(filename_.c_str());
int ct = 0;
std::wstringstream ss;
if(ext) {
name[ext-name] = 0;
ext++;
}
// Make sure the file name is unique.
do {
if(ct > 0)
ss.str(L"");
ss << szFolderPath << L"\\" << name;
if(ct > 0)
ss << L" (" << ct << L")";
if(ext)
ss << L"." << ext;
ct++;
} while(PathFileExists(ss.str().c_str()));
Lock();
filename_ = ss.str();
Unlock();
file_ = _wfopen(ss.str().c_str(), L"wb");
ASSERT(file_ != NULL);
}
#endif // _WIN32
}
void OnComplete()
{
ASSERT(CefCurrentlyOn(TID_FILE));
if(!file_)
return;
// Make sure any pending data is written.
OnReceivedData();
fclose(file_);
file_ = NULL;
// Notify the listener that the download completed.
listener_->NotifyDownloadComplete(filename_);
}
void OnReceivedData()
{
ASSERT(CefCurrentlyOn(TID_FILE));
std::vector<std::vector<char>*> data;
// Remove all data from the pending data queue.
Lock();
if(!pending_data_.empty()) {
data = pending_data_;
pending_data_.clear();
}
Unlock();
if(data.empty())
return;
// Write all pending data to file.
std::vector<std::vector<char>*>::iterator it = data.begin();
for(; it != data.end(); ++it) {
std::vector<char>* buffer = *it;
if(file_)
fwrite(&(*buffer)[0], buffer->size(), 1, file_);
delete buffer;
}
data.clear();
}
private:
CefRefPtr<DownloadListener> listener_;
std::wstring filename_;
FILE* file_;
std::vector<std::vector<char>*> pending_data_;
};
CefRefPtr<CefDownloadHandler> CreateDownloadHandler(
CefRefPtr<DownloadListener> listener, const std::wstring& fileName)
{
return new ClientDownloadHandler(listener, fileName);
}

View File

@ -0,0 +1,21 @@
// Copyright (c) 2010 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.
#pragma once
#include "include/cef.h"
// Implement this interface to receive download notifications.
class DownloadListener : public CefBase
{
public:
// Called when the download is complete.
virtual void NotifyDownloadComplete(const std::wstring& fileName) =0;
// Called if the download fails.
virtual void NotifyDownloadError(const std::wstring& fileName) =0;
};
// Create a new download handler to manage download of a single file.
CefRefPtr<CefDownloadHandler> CreateDownloadHandler(
CefRefPtr<DownloadListener> listener, const std::wstring& fileName);

View File

@ -22,8 +22,10 @@
#define IDC_NAV_RELOAD 202
#define IDC_NAV_STOP 203
#define ID_WARN_CONSOLEMESSAGE 32000
#define ID_FIND 32001
#define ID_PRINT 32002
#define ID_WARN_DOWNLOADCOMPLETE 32001
#define ID_WARN_DOWNLOADERROR 32002
#define ID_FIND 32101
#define ID_PRINT 32102
#define ID_TESTS_GETSOURCE 32769
#define ID_TESTS_GETTEXT 32770
#define ID_TESTS_JAVASCRIPT_BINDING 32771

48
tests/cefclient/util.h Normal file
View File

@ -0,0 +1,48 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#ifdef _WIN32
#include <windows.h>
#ifdef _DEBUG
#define ASSERT(condition) if(!(condition)) { DebugBreak(); }
#else
#define ASSERT(condition) ((void)0)
#endif
// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled.
// The warning remains disabled until popped by MSVC_POP_WARNING.
#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
__pragma(warning(disable:n))
// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level
// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all
// warnings.
#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n))
// Pop effects of innermost MSVC_PUSH_* macro.
#define MSVC_POP_WARNING() __pragma(warning(pop))
// Allows |this| to be passed as an argument in constructor initializer lists.
// This uses push/pop instead of the seemingly simpler suppress feature to avoid
// having the warning be disabled for more than just |code|.
//
// Example usage:
// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {}
//
// Compiler warning C4355: 'this': used in base member initializer list:
// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \
code \
MSVC_POP_WARNING()
#endif // _WIN32
#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif

View File

@ -110,6 +110,15 @@ public:
return RV_CONTINUE;
}
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
const std::wstring& mimeType,
const std::wstring& fileName,
int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler)
{
return RV_CONTINUE;
}
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
const MenuInfo& menuInfo)
{

View File

@ -1,4 +1,4 @@
# Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
# Copyright (c) 2010 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.
@ -410,6 +410,9 @@ class obj_header:
# read the input file into memory
data = read_file(filename)
# remove space from between template definition end brackets
data = data.replace("> >", ">>")
# extract global typedefs
p = re.compile('\ntypedef'+_cre_space+_cre_retval+
_cre_space+_cre_cfname+';',
@ -1065,6 +1068,7 @@ class obj_analysis:
simpletypes = {
'void' : 'void',
'int' : 'int',
'int64' : 'int64',
'double' : 'double',
'long' : 'long',
'unsigned long' : 'unsigned long',

View File

@ -1,4 +1,4 @@
# Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
# Copyright (c) 2010 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.
@ -45,7 +45,7 @@ def make_capi_header(header):
# header string
result = \
"""// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
"""// Copyright (c) 2010 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

View File

@ -1,4 +1,4 @@
# Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
# Copyright (c) 2010 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.
@ -14,7 +14,7 @@ def make_cpptoc_header(header, clsname):
capiname = cls.get_capi_name()
result = \
"""// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
"""// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
# Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
# Copyright (c) 2010 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.
@ -106,7 +106,7 @@ def make_cpptoc_impl(header, clsname, impl):
# build the final output
result = \
"""// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
"""// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
# Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
# Copyright (c) 2010 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.
@ -14,7 +14,7 @@ def make_ctocpp_header(header, clsname):
capiname = cls.get_capi_name()
result = \
"""// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
"""// Copyright (c) 2010 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.
//

View File

@ -1,4 +1,4 @@
# Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
# Copyright (c) 2010 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.
@ -104,7 +104,7 @@ def make_ctocpp_impl(header, clsname, impl):
# build the final output
result = \
"""// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
"""// Copyright (c) 2010 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.
//