mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
101 lines
2.2 KiB
C++
101 lines
2.2 KiB
C++
#include "stdafx.h"
|
|
|
|
#include "BrowserCore.h"
|
|
|
|
namespace CefSharp
|
|
{
|
|
void BrowserCore::WaitForInitialized()
|
|
{
|
|
if (IsInitialized)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// TODO: risk of infinite lock
|
|
_browserInitialized->WaitOne();
|
|
}
|
|
|
|
void BrowserCore::OnInitialized()
|
|
{
|
|
_browserInitialized->Set();
|
|
}
|
|
|
|
void BrowserCore::Load(String^ url)
|
|
{
|
|
WaitForInitialized();
|
|
_clientAdapter->GetCefBrowser()->GetMainFrame()->LoadURL(toNative(url));
|
|
}
|
|
|
|
void BrowserCore::Stop()
|
|
{
|
|
WaitForInitialized();
|
|
_clientAdapter->GetCefBrowser()->StopLoad();
|
|
}
|
|
|
|
void BrowserCore::Back()
|
|
{
|
|
WaitForInitialized();
|
|
_clientAdapter->GetCefBrowser()->GoBack();
|
|
}
|
|
|
|
void BrowserCore::Forward()
|
|
{
|
|
WaitForInitialized();
|
|
_clientAdapter->GetCefBrowser()->GoForward();
|
|
}
|
|
|
|
void BrowserCore::Reload()
|
|
{
|
|
Reload(false);
|
|
}
|
|
|
|
void BrowserCore::Reload(bool ignoreCache)
|
|
{
|
|
WaitForInitialized();
|
|
if (ignoreCache)
|
|
{
|
|
_clientAdapter->GetCefBrowser()->ReloadIgnoreCache();
|
|
}
|
|
else
|
|
{
|
|
_clientAdapter->GetCefBrowser()->Reload();
|
|
}
|
|
}
|
|
|
|
void BrowserCore::Print()
|
|
{
|
|
WaitForInitialized();
|
|
_clientAdapter->GetCefBrowser()->GetMainFrame()->Print();
|
|
}
|
|
|
|
void BrowserCore::SetNavState(bool isLoading, bool canGoBack, bool canGoForward)
|
|
{
|
|
if(isLoading != _isLoading)
|
|
{
|
|
_isLoading = isLoading;
|
|
PropertyChanged(this, gcnew PropertyChangedEventArgs(L"IsLoading"));
|
|
}
|
|
|
|
if(canGoBack != _canGoBack)
|
|
{
|
|
_canGoBack = canGoBack;
|
|
PropertyChanged(this, gcnew PropertyChangedEventArgs(L"CanGoBack"));
|
|
}
|
|
|
|
if(canGoForward != _canGoForward)
|
|
{
|
|
_canGoForward = canGoForward;
|
|
PropertyChanged(this, gcnew PropertyChangedEventArgs(L"CanGoForward"));
|
|
}
|
|
}
|
|
|
|
void BrowserCore::AddFrame(CefRefPtr<CefFrame> frame)
|
|
{
|
|
_loadCompleted->AddCount();
|
|
}
|
|
|
|
void BrowserCore::FrameLoadComplete(CefRefPtr<CefFrame> frame)
|
|
{
|
|
_loadCompleted->Signal();
|
|
}
|
|
} |