// Copyright © 2022 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.Wpf.Experimental
{
///
/// 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(LifeSpanHandlerCreatePopupChromiumWebBrowser chromiumWebBrowserCreatedDelegate)
{
handler = new LifeSpanHandler(chromiumWebBrowserCreatedDelegate);
}
///
/// 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(LifeSpanHandlerOnBeforePopupCreatedDelegate 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.
///
/// Action to be invoked when the Popup is to be destroyed.
/// instance allowing you to chain method calls together
public LifeSpanHandlerBuilder OnPopupCreated(LifeSpanHandlerOnPopupCreatedDelegate 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(LifeSpanHandlerOnPopupBrowserCreatedDelegate 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(LifeSpanHandlerOnPopupDestroyedDelegate onPopupDestroyed)
{
handler.OnPopupDestroyed(onPopupDestroyed);
return this;
}
///
/// Creates an implementation
/// that can be used to host popups as tabs/controls.
///
/// a instance
public ILifeSpanHandler Build()
{
return handler;
}
}
}