#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 frame) { _loadCompleted->AddCount(); } void BrowserCore::FrameLoadComplete(CefRefPtr frame) { _loadCompleted->Signal(); } }