// Copyright © 2021 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.
namespace CefSharp.WinForms.Handler
{
///
/// Fluent Builder
///
public class LifeSpanHandlerBuilder
{
private readonly LifeSpanHandler handler;
///
/// LifeSpanHandlerBuilder
///
///
/// When specified the delegate will be used to create the
/// instance. Allowing users to create their own custom instance that extends
///
public LifeSpanHandlerBuilder(CreatePopupChromiumHostControl chromiumHostControlCreatedDelegate)
{
handler = new LifeSpanHandler(chromiumHostControlCreatedDelegate);
}
///
/// The will be called before the popup has been created and
/// can be used to cancel popup creation if required, modify and disable javascript.
///
/// Action to be invoked before popup is created.
/// instance allowing you to chain method calls together
public LifeSpanHandlerBuilder OnBeforePopupCreated(OnBeforePopupCreatedDelegate onBeforePopupCreated)
{
handler.OnBeforePopupCreated(onBeforePopupCreated);
return this;
}
///
/// The will be called when the has been
/// created. When the is called you must add the control to it's intended parent
/// so the can be calculated to set the initial
/// size correctly.
///
/// Action to be invoked when the Popup is to be destroyed.
/// instance allowing you to chain method calls together
public LifeSpanHandlerBuilder OnPopupCreated(OnPopupCreatedDelegate onPopupCreated)
{
handler.OnPopupCreated(onPopupCreated);
return this;
}
///
/// The will be called when the has been
/// created. The instance is valid until
/// is called. provides low level access to the CEF Browser, you can access frames, view source,
/// perform navigation (via frame) etc.
///
/// Action to be invoked when the has been created.
/// instance allowing you to chain method calls together
public LifeSpanHandlerBuilder OnPopupBrowserCreated(OnPopupBrowserCreatedDelegate onPopupBrowserCreated)
{
handler.OnPopupBrowserCreated(onPopupBrowserCreated);
return this;
}
///
/// The will be called when the is to be
/// removed from it's parent.
/// When the is called you must remove/dispose of the .
///
/// Action to be invoked when the Popup is to be destroyed.
/// instance allowing you to chain method calls together
public LifeSpanHandlerBuilder OnPopupDestroyed(OnPopupDestroyedDelegate onPopupDestroyed)
{
handler.OnPopupDestroyed(onPopupDestroyed);
return this;
}
///
/// Creates an implementation
/// that can be used to host popups as tabs/controls. The resulting
/// returns true in
/// so no WM_CLOSE message is sent, this differs from the default CEF behaviour.
///
/// a instance
public ILifeSpanHandler Build()
{
return handler;
}
}
}