diff --git a/patches/cef_151_v8task.v5.patch b/patches/cef_151_v8task.v5.patch index 3c244c23a..8c997e52f 100644 --- a/patches/cef_151_v8task.v5.patch +++ b/patches/cef_151_v8task.v5.patch @@ -1,614 +1,651 @@ -Index: libcef_dll/cpptoc/v8task_cpptoc.h -=================================================================== ---- libcef_dll/cpptoc/v8task_cpptoc.h (revision 0) -+++ libcef_dll/cpptoc/v8task_cpptoc.h (revision 0) -@@ -0,0 +1,67 @@ -+// 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 _V8TASK_CPPTOC_H -+#define _V8TASK_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 CefV8TaskCppToC -+ : public CefCppToC -+{ -+public: -+ CefV8TaskCppToC(CefV8Task* cls); -+ virtual ~CefV8TaskCppToC() {} -+}; -+ -+#endif // USING_CEF_SHARED -+#endif // _V8TASK_CPPTOC_H -+ -+// 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 _V8TASK_CPPTOC_H -+#define _V8TASK_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 CefV8TaskCppToC -+ : public CefCppToC -+{ -+public: -+ CefV8TaskCppToC(CefV8Task* cls); -+ virtual ~CefV8TaskCppToC() {} -+}; -+ -+#endif // USING_CEF_SHARED -+#endif // _V8TASK_CPPTOC_H -Index: libcef_dll/cpptoc/frame_cpptoc.cc -=================================================================== ---- libcef_dll/cpptoc/frame_cpptoc.cc (revision 253) -+++ libcef_dll/cpptoc/frame_cpptoc.cc (working copy) -@@ -15,6 +15,7 @@ - #include "libcef_dll/cpptoc/request_cpptoc.h" - #include "libcef_dll/cpptoc/stream_reader_cpptoc.h" - #include "libcef_dll/ctocpp/domvisitor_ctocpp.h" -+#include "libcef_dll/ctocpp/v8task_ctocpp.h" - - - // MEMBER FUNCTIONS - Body may be edited by hand. -@@ -175,6 +176,17 @@ - CefString(scriptUrl), startLine); - } - -+void CEF_CALLBACK frame_execute_java_script_task(struct _cef_frame_t* self, -+ cef_v8task_t* jsTask) -+{ -+ DCHECK(self); -+ DCHECK(jsTask); -+ if(!self || !jsTask) -+ return; -+ -+ CefFrameCppToC::Get(self)->ExecuteJavaScriptTask(CefV8TaskCToCpp::Wrap(jsTask)); -+} -+ - int CEF_CALLBACK frame_is_main(struct _cef_frame_t* self) - { - DCHECK(self); -@@ -259,6 +271,7 @@ - struct_.struct_.load_string = frame_load_string; - struct_.struct_.load_stream = frame_load_stream; - struct_.struct_.execute_java_script = frame_execute_java_script; -+ struct_.struct_.execute_java_script_task = frame_execute_java_script_task; - struct_.struct_.is_main = frame_is_main; - struct_.struct_.is_focused = frame_is_focused; - struct_.struct_.get_name = frame_get_name; -Index: libcef_dll/cpptoc/v8task_cpptoc.cc -=================================================================== ---- libcef_dll/cpptoc/v8task_cpptoc.cc (revision 0) -+++ libcef_dll/cpptoc/v8task_cpptoc.cc (revision 0) -@@ -0,0 +1,84 @@ -+// 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/v8task_cpptoc.h" -+#include "libcef_dll/ctocpp/v8value_ctocpp.h" -+ -+ -+// MEMBER FUNCTIONS - Body may be edited by hand. -+ -+cef_string_userfree_t CEF_CALLBACK v8task_get_script(struct _cef_v8task_t* self) -+{ -+ DCHECK(self); -+ if(!self) -+ return 0; -+ -+ CefString valueStr = CefV8TaskCppToC::Get(self)->GetScript(); -+ return valueStr.DetachToUserFree(); -+} -+ -+cef_string_userfree_t CEF_CALLBACK v8task_get_script_name( -+ struct _cef_v8task_t* self) -+{ -+ DCHECK(self); -+ if(!self) -+ return 0; -+ -+ CefString valueStr = CefV8TaskCppToC::Get(self)->GetScriptName(); -+ return valueStr.DetachToUserFree(); -+} -+ -+int CEF_CALLBACK v8task_get_start_line(struct _cef_v8task_t* self) -+{ -+ DCHECK(self); -+ if(!self) -+ return 0; -+ -+ return CefV8TaskCppToC::Get(self)->GetStartLine(); -+} -+ -+void CEF_CALLBACK v8task_handle_success(struct _cef_v8task_t* self, -+ struct _cef_v8value_t* result) -+{ -+ DCHECK(self); -+ if(!self) -+ return; -+ -+ CefV8TaskCppToC::Get(self)->HandleSuccess(CefV8ValueCToCpp::Wrap(result)); -+} -+ -+void CEF_CALLBACK v8task_handle_error(struct _cef_v8task_t* self) -+{ -+ DCHECK(self); -+ if(!self) -+ return; -+ -+ CefV8TaskCppToC::Get(self)->HandleError(); -+} -+ -+ -+// CONSTRUCTOR - Do not edit by hand. -+ -+CefV8TaskCppToC::CefV8TaskCppToC(CefV8Task* cls) -+ : CefCppToC(cls) -+{ -+ struct_.struct_.get_script = v8task_get_script; -+ struct_.struct_.get_script_name = v8task_get_script_name; -+ struct_.struct_.get_start_line = v8task_get_start_line; -+ struct_.struct_.handle_success = v8task_handle_success; -+ struct_.struct_.handle_error = v8task_handle_error; -+} -+ -+#ifdef _DEBUG -+template<> long CefCppToC::DebugObjCt = 0; -+#endif -Index: libcef_dll/ctocpp/v8task_ctocpp.h -=================================================================== ---- libcef_dll/ctocpp/v8task_ctocpp.h (revision 0) -+++ libcef_dll/ctocpp/v8task_ctocpp.h (revision 0) -@@ -0,0 +1,85 @@ -+// 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 _V8TASK_CTOCPP_H -+#define _V8TASK_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 CefV8TaskCToCpp -+ : public CefCToCpp -+{ -+public: -+ CefV8TaskCToCpp(cef_v8task_t* str) -+ : CefCToCpp(str) {} -+ virtual ~CefV8TaskCToCpp() {} -+ -+ // CefV8Task methods -+ virtual CefString GetScript(); -+ virtual CefString GetScriptName(); -+ virtual int GetStartLine(); -+ virtual void HandleSuccess(CefRefPtr result); -+ virtual void HandleError(); -+}; -+ -+#endif // BUILDING_CEF_SHARED -+#endif // _V8TASK_CTOCPP_H -+ -+// 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 _V8TASK_CTOCPP_H -+#define _V8TASK_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 CefV8TaskCToCpp -+ : public CefCToCpp -+{ -+public: -+ CefV8TaskCToCpp(cef_v8task_t* str) -+ : CefCToCpp(str) {} -+ virtual ~CefV8TaskCToCpp() {} -+ -+ // CefV8Task methods -+ virtual CefString GetScript(); -+ virtual CefString GetScriptName(); -+ virtual int GetStartLine(); -+ virtual void HandleSuccess(CefRefPtr result); -+ virtual void HandleError(); -+}; -+ -+#endif // BUILDING_CEF_SHARED -+#endif // _V8TASK_CTOCPP_H -Index: libcef_dll/ctocpp/frame_ctocpp.cc -=================================================================== ---- libcef_dll/ctocpp/frame_ctocpp.cc (revision 253) -+++ libcef_dll/ctocpp/frame_ctocpp.cc (working copy) -@@ -12,6 +12,7 @@ - - #include "libcef_dll/cpptoc/domvisitor_cpptoc.h" - #include "libcef_dll/ctocpp/browser_ctocpp.h" -+#include "libcef_dll/cpptoc/v8task_cpptoc.h" - #include "libcef_dll/ctocpp/frame_ctocpp.h" - #include "libcef_dll/ctocpp/request_ctocpp.h" - #include "libcef_dll/ctocpp/stream_reader_ctocpp.h" -@@ -157,6 +158,14 @@ - scriptUrl.GetStruct(), startLine); - } - -+void CefFrameCToCpp::ExecuteJavaScriptTask(CefRefPtr jsTask) -+{ -+ if(CEF_MEMBER_MISSING(struct_, execute_java_script_task)) -+ return; -+ -+ struct_->execute_java_script_task(struct_, CefV8TaskCppToC::Wrap(jsTask)); -+} -+ - bool CefFrameCToCpp::IsMain() - { - if(CEF_MEMBER_MISSING(struct_, is_main)) -Index: libcef_dll/ctocpp/v8task_ctocpp.cc -=================================================================== ---- libcef_dll/ctocpp/v8task_ctocpp.cc (revision 0) -+++ libcef_dll/ctocpp/v8task_ctocpp.cc (revision 0) -@@ -0,0 +1,69 @@ -+// 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/cpptoc/v8value_cpptoc.h" -+#include "libcef_dll/ctocpp/v8task_ctocpp.h" -+ -+ -+// VIRTUAL METHODS - Body may be edited by hand. -+ -+CefString CefV8TaskCToCpp::GetScript() -+{ -+ CefString str; -+ if(CEF_MEMBER_MISSING(struct_, get_script)) -+ return str; -+ -+ cef_string_userfree_t strPtr = struct_->get_script(struct_); -+ str.AttachToUserFree(strPtr); -+ return str; -+} -+ -+CefString CefV8TaskCToCpp::GetScriptName() -+{ -+ CefString str; -+ if(CEF_MEMBER_MISSING(struct_, get_script_name)) -+ return str; -+ -+ cef_string_userfree_t strPtr = struct_->get_script_name(struct_); -+ str.AttachToUserFree(strPtr); -+ return str; -+} -+ -+int CefV8TaskCToCpp::GetStartLine() -+{ -+ if(CEF_MEMBER_MISSING(struct_, get_start_line)) -+ return 1; -+ -+ return struct_->get_start_line(struct_); -+} -+ -+void CefV8TaskCToCpp::HandleSuccess(CefRefPtr result) -+{ -+ if(CEF_MEMBER_MISSING(struct_, handle_success)) -+ return; -+ -+ cef_v8value_t* resPtr = CefV8ValueCppToC::Wrap(result); -+ struct_->handle_success(struct_, resPtr); -+} -+ -+void CefV8TaskCToCpp::HandleError() -+{ -+ if(CEF_MEMBER_MISSING(struct_, handle_error)) -+ return; -+ -+ struct_->handle_error(struct_); -+} -+ -+#ifdef _DEBUG -+template<> long CefCToCpp::DebugObjCt = 0; -+#endif -Index: libcef_dll/ctocpp/frame_ctocpp.h -=================================================================== ---- libcef_dll/ctocpp/frame_ctocpp.h (revision 253) -+++ libcef_dll/ctocpp/frame_ctocpp.h (working copy) -@@ -50,6 +50,7 @@ - const CefString& url) OVERRIDE; - virtual void ExecuteJavaScript(const CefString& jsCode, - const CefString& scriptUrl, int startLine) OVERRIDE; -+ virtual void ExecuteJavaScriptTask(CefRefPtr jsTask) OVERRIDE; - virtual bool IsMain() OVERRIDE; - virtual bool IsFocused() OVERRIDE; - virtual CefString GetName() OVERRIDE; -Index: include/cef_capi.h -=================================================================== ---- include/cef_capi.h (revision 253) -+++ include/cef_capi.h (working copy) -@@ -245,7 +245,33 @@ - // if the whitelist cannot be accessed. - /// - CEF_EXPORT int cef_clear_cross_origin_whitelist(); -+// Implement this structure for V8 javascript task execution. -+typedef struct _cef_v8task_t -+{ -+ // Base structure. -+ cef_base_t base; - -+ // Script that will be executed. -+ // The resulting string must be freed by calling cef_string_userfree_free(). -+ cef_string_userfree_t (CEF_CALLBACK *get_script)(struct _cef_v8task_t* self); -+ -+ // name/url of the script for error reporting purposes -+ // The resulting string must be freed by calling cef_string_userfree_free(). -+ cef_string_userfree_t (CEF_CALLBACK *get_script_name)( -+ struct _cef_v8task_t* self); -+ -+ // starting line number of the script for error reporting purposes -+ int (CEF_CALLBACK *get_start_line)(struct _cef_v8task_t* self); -+ -+ // executed on successful completion of the script -+ void (CEF_CALLBACK *handle_success)(struct _cef_v8task_t* self, -+ struct _cef_v8value_t* result); -+ -+ // executed on successful completion of the script -+ void (CEF_CALLBACK *handle_error)(struct _cef_v8task_t* self); -+ -+} cef_v8task_t; -+ - /// - // CEF maintains multiple internal threads that are used for handling different - // types of tasks. The UI thread creates the browser window and is used for all -@@ -523,6 +549,10 @@ - - /// - // Explicitly close the developer tools window if one exists for this browser -+ // Execute the cef_v8task_t code in this frame. -+ void (CEF_CALLBACK *execute_java_script_task)(struct _cef_frame_t* self, -+ struct _cef_v8task_t* jsTask); -+ - // instance. - /// - void (CEF_CALLBACK *close_dev_tools)(struct _cef_browser_t* self); -Index: include/cef.h -=================================================================== ---- include/cef.h (revision 253) -+++ include/cef.h (working copy) -@@ -78,6 +78,7 @@ - class CefV8Context; - class CefV8Handler; - class CefV8Value; -+class CefV8Task; - class CefWebURLRequest; - class CefWebURLRequestClient; - -@@ -387,6 +388,27 @@ - /*--cef()--*/ - bool CefDeleteCookies(const CefString& url, const CefString& cookie_name); - -+// Implement this interface for V8 javascript task execution. -+/*--cef(source=client)--*/ -+class CefV8Task : public virtual CefBase -+{ -+public: -+ // Script that will be executed. -+ /*--cef()--*/ -+ virtual CefString GetScript() =0; -+ // name/url of the script for error reporting purposes -+ /*--cef()--*/ -+ virtual CefString GetScriptName() =0; -+ // starting line number of the script for error reporting purposes -+ /*--cef()--*/ -+ virtual int GetStartLine() =0; -+ // executed on successful completion of the script -+ /*--cef()--*/ -+ virtual void HandleSuccess(CefRefPtr result) =0; -+ // executed if script execution fails to compile or throws an uncaught exception -+ /*--cef()--*/ -+ virtual void HandleError() =0; -+}; - - /// - // Interface defining the reference count implementation methods. All framework -@@ -670,6 +692,8 @@ - - /// - // Get the zoom level. -+ virtual void ExecuteJavaScriptTask(CefRefPtr jstask) =0; -+ - /// - /*--cef()--*/ - virtual double GetZoomLevel() =0; -Index: libcef/browser_impl.h -=================================================================== ---- libcef/browser_impl.h (revision 253) -+++ libcef/browser_impl.h (working copy) -@@ -128,6 +128,8 @@ - const CefString& jsCode, - const CefString& scriptUrl, - int startLine); -+ void ExecuteJavaScriptTask(CefRefPtr frame, -+ CefRefPtr jsTask); - CefString GetURL(CefRefPtr frame); - - // CefFrames are light-weight objects managed by the browser and loosely -@@ -244,6 +246,8 @@ - const CefString& js_code, - const CefString& script_url, - int start_line); -+ void UIT_ExecuteJavaScriptTask(CefFrame* frame, -+ CefV8Task* task); - void UIT_GoBackOrForward(int offset); - void UIT_Reload(bool ignoreCache); - bool UIT_Navigate(const BrowserNavigationEntry& entry, -@@ -405,6 +409,8 @@ - virtual void LoadStream(CefRefPtr stream, - const CefString& url) OVERRIDE - { return browser_->LoadStream(this, stream, url); } -+ virtual void ExecuteJavaScriptTask(CefRefPtr jsTask) -+ { return browser_->ExecuteJavaScriptTask(this, jsTask); } - virtual void ExecuteJavaScript(const CefString& jsCode, - const CefString& scriptUrl, - int startLine) OVERRIDE -Index: libcef/browser_impl.cc -=================================================================== ---- libcef/browser_impl.cc (revision 253) -+++ libcef/browser_impl.cc (working copy) -@@ -10,6 +10,7 @@ - #include "dom_document_impl.h" - #include "request_impl.h" - #include "stream_impl.h" -+#include "v8_impl.h" - - #include "base/file_path.h" - #include "base/path_service.h" -@@ -570,6 +571,14 @@ - startLine)); - } - -+void CefBrowserImpl::ExecuteJavaScriptTask(CefRefPtr frame, CefRefPtr jsTask) -+{ -+ frame->AddRef(); -+ jsTask->AddRef(); -+ CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this, -+ &CefBrowserImpl::UIT_ExecuteJavaScriptTask, frame.get(), jsTask.get())); -+} -+ - CefString CefBrowserImpl::GetURL(CefRefPtr frame) - { - // Verify that this method is being called on the UI thread. -@@ -848,6 +857,33 @@ - } - } - -+void CefBrowserImpl::UIT_ExecuteJavaScriptTask(CefFrame* frame, -+ CefV8Task* jsTask) -+{ -+ REQUIRE_UIT(); -+ -+ WebFrame* web_frame = UIT_GetWebFrame(frame); -+ v8::Handle result; -+ -+ if(web_frame) { -+ result = web_frame->executeScriptAndReturnValue( -+ WebScriptSource(string16(jsTask->GetScript()), -+ WebURL(GURL(std::string(jsTask->GetScriptName()))), -+ jsTask->GetStartLine())); -+ } -+ -+ if(result.IsEmpty()) { -+ jsTask->HandleError(); -+ } -+ else { -+ CefRefPtr cefResult = new CefV8ValueImpl(result); -+ jsTask->HandleSuccess(cefResult); -+ } -+ -+ frame->Release(); -+ jsTask->Release(); -+} -+ - void CefBrowserImpl::UIT_GoBackOrForward(int offset) - { - REQUIRE_UIT(); -Index: cef.gyp -=================================================================== ---- cef.gyp (revision 253) -+++ cef.gyp (working copy) -@@ -404,6 +404,8 @@ - 'libcef_dll/ctocpp/v8handler_ctocpp.h', - 'libcef_dll/ctocpp/web_urlrequest_client_ctocpp.cc', - 'libcef_dll/ctocpp/web_urlrequest_client_ctocpp.h', -+ 'libcef_dll/ctocpp/v8task_ctocpp.cc', -+ 'libcef_dll/ctocpp/v8task_ctocpp.h', - 'libcef_dll/ctocpp/write_handler_ctocpp.cc', - 'libcef_dll/ctocpp/write_handler_ctocpp.h', - 'libcef_dll/libcef_dll.cc', -@@ -511,6 +513,8 @@ - 'libcef_dll/cpptoc/v8handler_cpptoc.h', - 'libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc', - 'libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h', -+ 'libcef_dll/cpptoc/v8task_cpptoc.cc', -+ 'libcef_dll/cpptoc/v8task_cpptoc.h', - 'libcef_dll/cpptoc/write_handler_cpptoc.cc', - 'libcef_dll/cpptoc/write_handler_cpptoc.h', - 'libcef_dll/ctocpp/browser_ctocpp.cc', +Index: libcef_dll/cpptoc/v8task_cpptoc.h +=================================================================== +--- libcef_dll/cpptoc/v8task_cpptoc.h (revision 0) ++++ libcef_dll/cpptoc/v8task_cpptoc.h (revision 0) +@@ -0,0 +1,67 @@ ++// 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 _V8TASK_CPPTOC_H ++#define _V8TASK_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 CefV8TaskCppToC ++ : public CefCppToC ++{ ++public: ++ CefV8TaskCppToC(CefV8Task* cls); ++ virtual ~CefV8TaskCppToC() {} ++}; ++ ++#endif // USING_CEF_SHARED ++#endif // _V8TASK_CPPTOC_H ++ ++// 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 _V8TASK_CPPTOC_H ++#define _V8TASK_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 CefV8TaskCppToC ++ : public CefCppToC ++{ ++public: ++ CefV8TaskCppToC(CefV8Task* cls); ++ virtual ~CefV8TaskCppToC() {} ++}; ++ ++#endif // USING_CEF_SHARED ++#endif // _V8TASK_CPPTOC_H +Index: libcef_dll/cpptoc/frame_cpptoc.cc +=================================================================== +--- libcef_dll/cpptoc/frame_cpptoc.cc (revision 253) ++++ libcef_dll/cpptoc/frame_cpptoc.cc (working copy) +@@ -15,6 +15,7 @@ + #include "libcef_dll/cpptoc/request_cpptoc.h" + #include "libcef_dll/cpptoc/stream_reader_cpptoc.h" + #include "libcef_dll/ctocpp/domvisitor_ctocpp.h" ++#include "libcef_dll/ctocpp/v8task_ctocpp.h" + + + // MEMBER FUNCTIONS - Body may be edited by hand. +@@ -175,6 +176,17 @@ + CefString(scriptUrl), startLine); + } + ++void CEF_CALLBACK frame_execute_java_script_task(struct _cef_frame_t* self, ++ cef_v8task_t* jsTask) ++{ ++ DCHECK(self); ++ DCHECK(jsTask); ++ if(!self || !jsTask) ++ return; ++ ++ CefFrameCppToC::Get(self)->ExecuteJavaScriptTask(CefV8TaskCToCpp::Wrap(jsTask)); ++} ++ + int CEF_CALLBACK frame_is_main(struct _cef_frame_t* self) + { + DCHECK(self); +@@ -259,6 +271,7 @@ + struct_.struct_.load_string = frame_load_string; + struct_.struct_.load_stream = frame_load_stream; + struct_.struct_.execute_java_script = frame_execute_java_script; ++ struct_.struct_.execute_java_script_task = frame_execute_java_script_task; + struct_.struct_.is_main = frame_is_main; + struct_.struct_.is_focused = frame_is_focused; + struct_.struct_.get_name = frame_get_name; +Index: libcef_dll/cpptoc/v8task_cpptoc.cc +=================================================================== +--- libcef_dll/cpptoc/v8task_cpptoc.cc (revision 0) ++++ libcef_dll/cpptoc/v8task_cpptoc.cc (revision 0) +@@ -0,0 +1,84 @@ ++// 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/v8task_cpptoc.h" ++#include "libcef_dll/ctocpp/v8value_ctocpp.h" ++ ++ ++// MEMBER FUNCTIONS - Body may be edited by hand. ++ ++cef_string_userfree_t CEF_CALLBACK v8task_get_script(struct _cef_v8task_t* self) ++{ ++ DCHECK(self); ++ if(!self) ++ return 0; ++ ++ CefString valueStr = CefV8TaskCppToC::Get(self)->GetScript(); ++ return valueStr.DetachToUserFree(); ++} ++ ++cef_string_userfree_t CEF_CALLBACK v8task_get_script_name( ++ struct _cef_v8task_t* self) ++{ ++ DCHECK(self); ++ if(!self) ++ return 0; ++ ++ CefString valueStr = CefV8TaskCppToC::Get(self)->GetScriptName(); ++ return valueStr.DetachToUserFree(); ++} ++ ++int CEF_CALLBACK v8task_get_start_line(struct _cef_v8task_t* self) ++{ ++ DCHECK(self); ++ if(!self) ++ return 0; ++ ++ return CefV8TaskCppToC::Get(self)->GetStartLine(); ++} ++ ++void CEF_CALLBACK v8task_handle_success(struct _cef_v8task_t* self, ++ struct _cef_v8value_t* result) ++{ ++ DCHECK(self); ++ if(!self) ++ return; ++ ++ CefV8TaskCppToC::Get(self)->HandleSuccess(CefV8ValueCToCpp::Wrap(result)); ++} ++ ++void CEF_CALLBACK v8task_handle_error(struct _cef_v8task_t* self) ++{ ++ DCHECK(self); ++ if(!self) ++ return; ++ ++ CefV8TaskCppToC::Get(self)->HandleError(); ++} ++ ++ ++// CONSTRUCTOR - Do not edit by hand. ++ ++CefV8TaskCppToC::CefV8TaskCppToC(CefV8Task* cls) ++ : CefCppToC(cls) ++{ ++ struct_.struct_.get_script = v8task_get_script; ++ struct_.struct_.get_script_name = v8task_get_script_name; ++ struct_.struct_.get_start_line = v8task_get_start_line; ++ struct_.struct_.handle_success = v8task_handle_success; ++ struct_.struct_.handle_error = v8task_handle_error; ++} ++ ++#ifdef _DEBUG ++template<> long CefCppToC::DebugObjCt = 0; ++#endif +Index: libcef_dll/ctocpp/v8task_ctocpp.h +=================================================================== +--- libcef_dll/ctocpp/v8task_ctocpp.h (revision 0) ++++ libcef_dll/ctocpp/v8task_ctocpp.h (revision 0) +@@ -0,0 +1,85 @@ ++// 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 _V8TASK_CTOCPP_H ++#define _V8TASK_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 CefV8TaskCToCpp ++ : public CefCToCpp ++{ ++public: ++ CefV8TaskCToCpp(cef_v8task_t* str) ++ : CefCToCpp(str) {} ++ virtual ~CefV8TaskCToCpp() {} ++ ++ // CefV8Task methods ++ virtual CefString GetScript(); ++ virtual CefString GetScriptName(); ++ virtual int GetStartLine(); ++ virtual void HandleSuccess(CefRefPtr result); ++ virtual void HandleError(); ++}; ++ ++#endif // BUILDING_CEF_SHARED ++#endif // _V8TASK_CTOCPP_H ++ ++// 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 _V8TASK_CTOCPP_H ++#define _V8TASK_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 CefV8TaskCToCpp ++ : public CefCToCpp ++{ ++public: ++ CefV8TaskCToCpp(cef_v8task_t* str) ++ : CefCToCpp(str) {} ++ virtual ~CefV8TaskCToCpp() {} ++ ++ // CefV8Task methods ++ virtual CefString GetScript(); ++ virtual CefString GetScriptName(); ++ virtual int GetStartLine(); ++ virtual void HandleSuccess(CefRefPtr result); ++ virtual void HandleError(); ++}; ++ ++#endif // BUILDING_CEF_SHARED ++#endif // _V8TASK_CTOCPP_H +Index: libcef_dll/ctocpp/frame_ctocpp.cc +=================================================================== +--- libcef_dll/ctocpp/frame_ctocpp.cc (revision 253) ++++ libcef_dll/ctocpp/frame_ctocpp.cc (working copy) +@@ -12,6 +12,7 @@ + + #include "libcef_dll/cpptoc/domvisitor_cpptoc.h" + #include "libcef_dll/ctocpp/browser_ctocpp.h" ++#include "libcef_dll/cpptoc/v8task_cpptoc.h" + #include "libcef_dll/ctocpp/frame_ctocpp.h" + #include "libcef_dll/ctocpp/request_ctocpp.h" + #include "libcef_dll/ctocpp/stream_reader_ctocpp.h" +@@ -157,6 +158,14 @@ + scriptUrl.GetStruct(), startLine); + } + ++void CefFrameCToCpp::ExecuteJavaScriptTask(CefRefPtr jsTask) ++{ ++ if(CEF_MEMBER_MISSING(struct_, execute_java_script_task)) ++ return; ++ ++ struct_->execute_java_script_task(struct_, CefV8TaskCppToC::Wrap(jsTask)); ++} ++ + bool CefFrameCToCpp::IsMain() + { + if(CEF_MEMBER_MISSING(struct_, is_main)) +Index: libcef_dll/ctocpp/v8task_ctocpp.cc +=================================================================== +--- libcef_dll/ctocpp/v8task_ctocpp.cc (revision 0) ++++ libcef_dll/ctocpp/v8task_ctocpp.cc (revision 0) +@@ -0,0 +1,69 @@ ++// 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/cpptoc/v8value_cpptoc.h" ++#include "libcef_dll/ctocpp/v8task_ctocpp.h" ++ ++ ++// VIRTUAL METHODS - Body may be edited by hand. ++ ++CefString CefV8TaskCToCpp::GetScript() ++{ ++ CefString str; ++ if(CEF_MEMBER_MISSING(struct_, get_script)) ++ return str; ++ ++ cef_string_userfree_t strPtr = struct_->get_script(struct_); ++ str.AttachToUserFree(strPtr); ++ return str; ++} ++ ++CefString CefV8TaskCToCpp::GetScriptName() ++{ ++ CefString str; ++ if(CEF_MEMBER_MISSING(struct_, get_script_name)) ++ return str; ++ ++ cef_string_userfree_t strPtr = struct_->get_script_name(struct_); ++ str.AttachToUserFree(strPtr); ++ return str; ++} ++ ++int CefV8TaskCToCpp::GetStartLine() ++{ ++ if(CEF_MEMBER_MISSING(struct_, get_start_line)) ++ return 1; ++ ++ return struct_->get_start_line(struct_); ++} ++ ++void CefV8TaskCToCpp::HandleSuccess(CefRefPtr result) ++{ ++ if(CEF_MEMBER_MISSING(struct_, handle_success)) ++ return; ++ ++ cef_v8value_t* resPtr = CefV8ValueCppToC::Wrap(result); ++ struct_->handle_success(struct_, resPtr); ++} ++ ++void CefV8TaskCToCpp::HandleError() ++{ ++ if(CEF_MEMBER_MISSING(struct_, handle_error)) ++ return; ++ ++ struct_->handle_error(struct_); ++} ++ ++#ifdef _DEBUG ++template<> long CefCToCpp::DebugObjCt = 0; ++#endif +Index: libcef_dll/ctocpp/frame_ctocpp.h +=================================================================== +--- libcef_dll/ctocpp/frame_ctocpp.h (revision 253) ++++ libcef_dll/ctocpp/frame_ctocpp.h (working copy) +@@ -50,6 +50,7 @@ + const CefString& url) OVERRIDE; + virtual void ExecuteJavaScript(const CefString& jsCode, + const CefString& scriptUrl, int startLine) OVERRIDE; ++ virtual void ExecuteJavaScriptTask(CefRefPtr jsTask) OVERRIDE; + virtual bool IsMain() OVERRIDE; + virtual bool IsFocused() OVERRIDE; + virtual CefString GetName() OVERRIDE; +Index: include/cef_capi.h +=================================================================== +--- include/cef_capi.h (revision 253) ++++ include/cef_capi.h (working copy) +@@ -367,6 +367,44 @@ + } cef_task_t; + + ++// Implement this structure for V8 javascript task execution. ++typedef struct _cef_v8task_t ++{ ++ // Base structure. ++ cef_base_t base; ++ ++ /// ++ // Script that will be executed. ++ // The resulting string must be freed by calling cef_string_userfree_free(). ++ /// ++ cef_string_userfree_t (CEF_CALLBACK *get_script)(struct _cef_v8task_t* self); ++ ++ /// ++ // name/url of the script for error reporting purposes ++ // The resulting string must be freed by calling cef_string_userfree_free(). ++ /// ++ cef_string_userfree_t (CEF_CALLBACK *get_script_name)( ++ struct _cef_v8task_t* self); ++ ++ /// ++ // starting line number of the script for error reporting purposes ++ /// ++ int (CEF_CALLBACK *get_start_line)(struct _cef_v8task_t* self); ++ ++ /// ++ // executed on successful completion of the script ++ /// ++ void (CEF_CALLBACK *handle_success)(struct _cef_v8task_t* self, ++ struct _cef_v8value_t* result); ++ ++ /// ++ // executed on successful completion of the script ++ /// ++ void (CEF_CALLBACK *handle_error)(struct _cef_v8task_t* self); ++ ++} cef_v8task_t; ++ ++ + /// + // Structure to implement for visiting cookie values. The functions of this + // structure will always be called on the IO thread. +@@ -523,6 +561,7 @@ + + /// + // Explicitly close the developer tools window if one exists for this browser ++ // Execute the cef_v8task_t code in this frame. + // instance. + /// + void (CEF_CALLBACK *close_dev_tools)(struct _cef_browser_t* self); +@@ -744,6 +783,12 @@ + int startLine); + + /// ++ // Execute a V8 task. ++ /// ++ void (CEF_CALLBACK *execute_java_script_task)(struct _cef_frame_t* self, ++ struct _cef_v8task_t* jsTask); ++ ++ /// + // Returns true (1) if this is the main frame. + /// + int (CEF_CALLBACK *is_main)(struct _cef_frame_t* self); +Index: include/cef.h +=================================================================== +--- include/cef.h (revision 253) ++++ include/cef.h (working copy) +@@ -78,6 +78,7 @@ + class CefV8Context; + class CefV8Handler; + class CefV8Value; ++class CefV8Task; + class CefWebURLRequest; + class CefWebURLRequestClient; + +@@ -502,7 +502,39 @@ + virtual void Execute(CefThreadId threadId) =0; + }; + ++// Implement this interface for V8 javascript task execution. ++/*--cef(source=client)--*/ ++class CefV8Task : public virtual CefBase ++{ ++public: ++ /// ++ // Script that will be executed. ++ /// ++ /*--cef()--*/ ++ virtual CefString GetScript() =0; ++ /// ++ // name/url of the script for error reporting purposes ++ /// ++ /*--cef()--*/ ++ virtual CefString GetScriptName() =0; ++ /// ++ // starting line number of the script for error reporting purposes ++ /// ++ /*--cef()--*/ ++ virtual int GetStartLine() =0; ++ /// ++ // executed on successful completion of the script ++ /// ++ /*--cef()--*/ ++ virtual void HandleSuccess(CefRefPtr result) =0; ++ /// ++ // executed if script execution fails to compile or throws an uncaught exception ++ /// ++ /*--cef()--*/ ++ virtual void HandleError() =0; ++}; + ++ + /// + // Interface to implement for visiting cookie values. The methods of this class + // will always be called on the IO thread. +@@ -899,6 +931,12 @@ + int startLine) =0; + + /// ++ // Execute a CefV8Task. ++ /// ++ /*--cef()--*/ ++ virtual void ExecuteJavaScriptTask(CefRefPtr jstask) =0; ++ ++ /// + // Returns true if this is the main frame. + /// + /*--cef()--*/ +Index: libcef/browser_impl.h +=================================================================== +--- libcef/browser_impl.h (revision 253) ++++ libcef/browser_impl.h (working copy) +@@ -128,6 +128,8 @@ + const CefString& jsCode, + const CefString& scriptUrl, + int startLine); ++ void ExecuteJavaScriptTask(CefRefPtr frame, ++ CefRefPtr jsTask); + CefString GetURL(CefRefPtr frame); + + // CefFrames are light-weight objects managed by the browser and loosely +@@ -244,6 +246,8 @@ + const CefString& js_code, + const CefString& script_url, + int start_line); ++ void UIT_ExecuteJavaScriptTask(CefFrame* frame, ++ CefV8Task* task); + void UIT_GoBackOrForward(int offset); + void UIT_Reload(bool ignoreCache); + bool UIT_Navigate(const BrowserNavigationEntry& entry, +@@ -405,6 +409,8 @@ + virtual void LoadStream(CefRefPtr stream, + const CefString& url) OVERRIDE + { return browser_->LoadStream(this, stream, url); } ++ virtual void ExecuteJavaScriptTask(CefRefPtr jsTask) ++ { return browser_->ExecuteJavaScriptTask(this, jsTask); } + virtual void ExecuteJavaScript(const CefString& jsCode, + const CefString& scriptUrl, + int startLine) OVERRIDE +Index: libcef/browser_impl.cc +=================================================================== +--- libcef/browser_impl.cc (revision 253) ++++ libcef/browser_impl.cc (working copy) +@@ -10,6 +10,7 @@ + #include "dom_document_impl.h" + #include "request_impl.h" + #include "stream_impl.h" ++#include "v8_impl.h" + + #include "base/file_path.h" + #include "base/path_service.h" +@@ -570,6 +571,14 @@ + startLine)); + } + ++void CefBrowserImpl::ExecuteJavaScriptTask(CefRefPtr frame, CefRefPtr jsTask) ++{ ++ frame->AddRef(); ++ jsTask->AddRef(); ++ CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this, ++ &CefBrowserImpl::UIT_ExecuteJavaScriptTask, frame.get(), jsTask.get())); ++} ++ + CefString CefBrowserImpl::GetURL(CefRefPtr frame) + { + // Verify that this method is being called on the UI thread. +@@ -848,6 +857,33 @@ + } + } + ++void CefBrowserImpl::UIT_ExecuteJavaScriptTask(CefFrame* frame, ++ CefV8Task* jsTask) ++{ ++ REQUIRE_UIT(); ++ ++ WebFrame* web_frame = UIT_GetWebFrame(frame); ++ v8::Handle result; ++ ++ if(web_frame) { ++ result = web_frame->executeScriptAndReturnValue( ++ WebScriptSource(string16(jsTask->GetScript()), ++ WebURL(GURL(std::string(jsTask->GetScriptName()))), ++ jsTask->GetStartLine())); ++ } ++ ++ if(result.IsEmpty()) { ++ jsTask->HandleError(); ++ } ++ else { ++ CefRefPtr cefResult = new CefV8ValueImpl(result); ++ jsTask->HandleSuccess(cefResult); ++ } ++ ++ frame->Release(); ++ jsTask->Release(); ++} ++ + void CefBrowserImpl::UIT_GoBackOrForward(int offset) + { + REQUIRE_UIT(); +Index: cef.gyp +=================================================================== +--- cef.gyp (revision 253) ++++ cef.gyp (working copy) +@@ -404,6 +404,8 @@ + 'libcef_dll/ctocpp/v8handler_ctocpp.h', + 'libcef_dll/ctocpp/web_urlrequest_client_ctocpp.cc', + 'libcef_dll/ctocpp/web_urlrequest_client_ctocpp.h', ++ 'libcef_dll/ctocpp/v8task_ctocpp.cc', ++ 'libcef_dll/ctocpp/v8task_ctocpp.h', + 'libcef_dll/ctocpp/write_handler_ctocpp.cc', + 'libcef_dll/ctocpp/write_handler_ctocpp.h', + 'libcef_dll/libcef_dll.cc', +@@ -511,6 +513,8 @@ + 'libcef_dll/cpptoc/v8handler_cpptoc.h', + 'libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc', + 'libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h', ++ 'libcef_dll/cpptoc/v8task_cpptoc.cc', ++ 'libcef_dll/cpptoc/v8task_cpptoc.h', + 'libcef_dll/cpptoc/write_handler_cpptoc.cc', + 'libcef_dll/cpptoc/write_handler_cpptoc.h', + 'libcef_dll/ctocpp/browser_ctocpp.cc',