mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
70de3a6d9c
* WinForms/WPF - Dispose of IFrame after calling LoadUrl * BrowserProcess - Add initial implementation of IRenderProcessHandler.OnContextCreated/OnContextReleased - IV8Context.Execute is the only method to be implemented so far (execute script without returning a result) - Wrappers for CefFrame and CefBrowser have yet to be imported yet, still need to determine if they should be included individually or reference to CefSharp.Core added * BrowserProcess - Add wrappers for Browser and Frame Ultimately we should probably remove the CefSharp.BrowserSubprocess.Core project and move all the code into a folder/namespace within CefSharp.Core This would allow us to share the a lot of existing code, major refactor required * CefSharp.Common.props - Add CefSharpBrowserProcessCore32/64 properties Make creating your own custom browser process easier * BrowserProcess - Remove example and add comments about creating your own custom version
222 lines
3.9 KiB
C++
222 lines
3.9 KiB
C++
// Copyright © 2015 The CefSharp 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 "Stdafx.h"
|
|
|
|
#include "Frame.h"
|
|
#include "Browser.h"
|
|
|
|
using namespace CefSharp::BrowserSubprocess;
|
|
|
|
///
|
|
// Returns the browser host object. This method can only be called in the
|
|
// browser process.
|
|
///
|
|
/*--cef()--*/
|
|
IBrowserHost^ Browser::GetHost()
|
|
{
|
|
throw gcnew NotImplementedException("Browser process only");
|
|
}
|
|
|
|
///
|
|
// Returns true if the browser can navigate backwards.
|
|
///
|
|
/*--cef()--*/
|
|
bool Browser::CanGoBack::get()
|
|
{
|
|
return _browser->CanGoBack();
|
|
}
|
|
|
|
///
|
|
// Navigate backwards.
|
|
///
|
|
/*--cef()--*/
|
|
void Browser::GoBack()
|
|
{
|
|
_browser->GoBack();
|
|
}
|
|
|
|
///
|
|
// Returns true if the browser can navigate forwards.
|
|
///
|
|
/*--cef()--*/
|
|
bool Browser::CanGoForward::get()
|
|
{
|
|
return _browser->CanGoForward();
|
|
}
|
|
|
|
///
|
|
// Navigate forwards.
|
|
///
|
|
/*--cef()--*/
|
|
void Browser::GoForward()
|
|
{
|
|
_browser->GoForward();
|
|
}
|
|
|
|
///
|
|
// Returns true if the browser is currently loading.
|
|
///
|
|
/*--cef()--*/
|
|
bool Browser::IsLoading::get()
|
|
{
|
|
return _browser->IsLoading();
|
|
}
|
|
|
|
void Browser::CloseBrowser(bool forceClose)
|
|
{
|
|
throw gcnew NotImplementedException("Browser process only");
|
|
}
|
|
|
|
///
|
|
// Reload the current page.
|
|
///
|
|
/*--cef()--*/
|
|
void Browser::Reload(bool ignoreCache)
|
|
{
|
|
if (ignoreCache)
|
|
{
|
|
_browser->ReloadIgnoreCache();
|
|
}
|
|
else
|
|
{
|
|
_browser->Reload();
|
|
}
|
|
}
|
|
|
|
///
|
|
// Stop loading the page.
|
|
///
|
|
/*--cef()--*/
|
|
void Browser::StopLoad()
|
|
{
|
|
_browser->StopLoad();
|
|
}
|
|
|
|
///
|
|
// Returns the globally unique identifier for this browser.
|
|
///
|
|
/*--cef()--*/
|
|
int Browser::Identifier::get()
|
|
{
|
|
return _browser->GetIdentifier();
|
|
}
|
|
|
|
///
|
|
// Returns true if this object is pointing to the same handle as |that|
|
|
// object.
|
|
///
|
|
/*--cef()--*/
|
|
bool Browser::IsSame(IBrowser^ that)
|
|
{
|
|
return _browser->IsSame(dynamic_cast<Browser^>(that)->_browser.get());
|
|
}
|
|
|
|
///
|
|
// Returns true if the window is a popup window.
|
|
///
|
|
/*--cef()--*/
|
|
bool Browser::IsPopup::get()
|
|
{
|
|
return _browser->IsPopup();
|
|
}
|
|
|
|
///
|
|
// Returns true if a document has been loaded in the browser.
|
|
///
|
|
/*--cef()--*/
|
|
bool Browser::HasDocument::get()
|
|
{
|
|
return _browser->HasDocument();
|
|
}
|
|
|
|
IFrame^ Browser::MainFrame::get()
|
|
{
|
|
auto frame = _browser->GetMainFrame();
|
|
return gcnew Frame(frame);
|
|
}
|
|
|
|
///
|
|
// Returns the focused frame for the browser window.
|
|
///
|
|
/*--cef()--*/
|
|
IFrame^ Browser::FocusedFrame::get()
|
|
{
|
|
return gcnew Frame(_browser->GetFocusedFrame());
|
|
}
|
|
|
|
///
|
|
// Returns the frame with the specified identifier, or NULL if not found.
|
|
///
|
|
/*--cef(capi_name=get_frame_byident)--*/
|
|
IFrame^ Browser::GetFrame(Int64 identifier)
|
|
{
|
|
auto frame = _browser->GetFrame(identifier);
|
|
|
|
if (frame.get())
|
|
{
|
|
return gcnew Frame(frame);
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
///
|
|
// Returns the frame with the specified name, or NULL if not found.
|
|
///
|
|
/*--cef(optional_param=name)--*/
|
|
IFrame^ Browser::GetFrame(String^ name)
|
|
{
|
|
auto frame = _browser->GetFrame(StringUtils::ToNative(name));
|
|
|
|
if (frame.get())
|
|
{
|
|
return gcnew Frame(frame);
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
///
|
|
// Returns the number of frames that currently exist.
|
|
///
|
|
/*--cef()--*/
|
|
int Browser::GetFrameCount()
|
|
{
|
|
return _browser->GetFrameCount();
|
|
}
|
|
|
|
///
|
|
// Returns the identifiers of all existing frames.
|
|
///
|
|
/*--cef(count_func=identifiers:GetFrameCount)--*/
|
|
List<Int64>^ Browser::GetFrameIdentifiers()
|
|
{
|
|
std::vector<Int64> identifiers;
|
|
_browser->GetFrameIdentifiers(identifiers);
|
|
List<Int64>^ results = gcnew List<Int64>(identifiers.size());
|
|
for (UINT i = 0; i < identifiers.size(); i++)
|
|
{
|
|
results->Add(identifiers[i]);
|
|
}
|
|
return results;
|
|
}
|
|
|
|
///
|
|
// Returns the names of all existing frames.
|
|
///
|
|
/*--cef()--*/
|
|
List<String^>^ Browser::GetFrameNames()
|
|
{
|
|
std::vector<CefString> names;
|
|
|
|
_browser->GetFrameNames(names);
|
|
return StringUtils::ToClr(names);
|
|
}
|
|
|
|
bool Browser::IsDisposed::get()
|
|
{
|
|
return _disposed;
|
|
}
|