diff --git a/CefSharp.WinForms/WebView.cpp b/CefSharp.WinForms/WebView.cpp index d1cffcbfe..d24ff11d0 100644 --- a/CefSharp.WinForms/WebView.cpp +++ b/CefSharp.WinForms/WebView.cpp @@ -280,8 +280,7 @@ namespace WinForms CefRefPtr browser; if (TryGetCefBrowser(browser)) { - _scriptCore->Execute(browser->GetMainFrame(), - toNative(script)); + _scriptCore->Execute(browser, toNative(script)); } } @@ -297,8 +296,8 @@ namespace WinForms CefRefPtr browser; if (TryGetCefBrowser(browser)) { - return _scriptCore->Evaluate(browser->GetMainFrame(), - toNative(script), timeout.TotalMilliseconds); + return _scriptCore->Evaluate(browser, toNative(script), + timeout.TotalMilliseconds); } else { diff --git a/CefSharp.Wpf/WebView.cpp b/CefSharp.Wpf/WebView.cpp index e5b499d75..789ff7847 100644 --- a/CefSharp.Wpf/WebView.cpp +++ b/CefSharp.Wpf/WebView.cpp @@ -485,8 +485,7 @@ namespace Wpf CefRefPtr browser; if (TryGetCefBrowser(browser)) { - _scriptCore->Execute(browser->GetMainFrame(), - toNative(script)); + _scriptCore->Execute(browser, toNative(script)); } } @@ -502,8 +501,8 @@ namespace Wpf CefRefPtr browser; if (TryGetCefBrowser(browser)) { - return _scriptCore->Evaluate(browser->GetMainFrame(), - toNative(script), timeout.TotalMilliseconds); + return _scriptCore->Evaluate(browser, toNative(script), + timeout.TotalMilliseconds); } else { diff --git a/CefSharp/ScriptCore.cpp b/CefSharp/ScriptCore.cpp index 4149478f5..81799f825 100644 --- a/CefSharp/ScriptCore.cpp +++ b/CefSharp/ScriptCore.cpp @@ -5,14 +5,14 @@ namespace CefSharp { - void ScriptCore::UIT_Execute(CefRefPtr frame, CefString script) + void ScriptCore::UIT_Execute(CefRefPtr browser, CefString script) { - frame->ExecuteJavaScript(script, "about:blank", 0); + browser->GetMainFrame()->ExecuteJavaScript(script, "about:blank", 0); } - void ScriptCore::UIT_Evaluate(CefRefPtr frame, CefString script) + void ScriptCore::UIT_Evaluate(CefRefPtr browser, CefString script) { - CefRefPtr context = frame->GetV8Context(); + CefRefPtr context = browser->GetMainFrame()->GetV8Context(); if (context.get() && context->Enter()) @@ -53,20 +53,20 @@ namespace CefSharp SetEvent(_event); } - void ScriptCore::Execute(CefRefPtr frame, CefString script) + void ScriptCore::Execute(CefRefPtr browser, CefString script) { if (CefCurrentlyOn(TID_UI)) { - UIT_Execute(frame, script); + UIT_Execute(browser, script); } else { CefPostTask(TID_UI, NewCefRunnableMethod(this, &ScriptCore::UIT_Execute, - frame, script)); + browser, script)); } } - gcroot ScriptCore::Evaluate(CefRefPtr frame, CefString script, double timeout) + gcroot ScriptCore::Evaluate(CefRefPtr browser, CefString script, double timeout) { AutoLock lock_scope(this); _result = nullptr; @@ -74,12 +74,12 @@ namespace CefSharp if (CefCurrentlyOn(TID_UI)) { - UIT_Evaluate(frame, script); + UIT_Evaluate(browser, script); } else { CefPostTask(TID_UI, NewCefRunnableMethod(this, &ScriptCore::UIT_Evaluate, - frame, script)); + browser, script)); switch (WaitForSingleObject(_event, timeout)) { diff --git a/CefSharp/ScriptCore.h b/CefSharp/ScriptCore.h index ba47477dc..d0b03a937 100644 --- a/CefSharp/ScriptCore.h +++ b/CefSharp/ScriptCore.h @@ -11,8 +11,8 @@ namespace CefSharp gcroot _result; gcroot _exception; - void UIT_Execute(CefRefPtr frame, CefString script); - void UIT_Evaluate(CefRefPtr frame, CefString script); + void UIT_Execute(CefRefPtr browser, CefString script); + void UIT_Evaluate(CefRefPtr browser, CefString script); public: ScriptCore() @@ -20,8 +20,8 @@ namespace CefSharp _event = CreateEvent(NULL, FALSE, FALSE, NULL); } - DECL void Execute(CefRefPtr frame, CefString script); - DECL gcroot Evaluate(CefRefPtr frame, CefString script, double timeout); + DECL void Execute(CefRefPtr browser, CefString script); + DECL gcroot Evaluate(CefRefPtr browser, CefString script, double timeout); IMPLEMENT_LOCKING(ScriptCore); IMPLEMENT_REFCOUNTING(ScriptCore);