// Copyright © 2019 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. using System; using CefSharp.ModelBinding; namespace CefSharp { /// /// Calling CefSharp.PostMessage in Javascript triggers the JavascriptMessageReceived /// This event args contains the frame, browser and message corrisponding to that call /// public class JavascriptMessageReceivedEventArgs : EventArgs { private static readonly IBinder Binder = new DefaultBinder(); /// /// The frame that called CefSharp.PostMessage in Javascript /// public IFrame Frame { get; private set; } /// /// The browser that hosts the /// public IBrowser Browser { get; private set; } /// /// Message can be a primative type or a simple object that represents a copy /// of the data sent from the browser /// public object Message { get; private set; } /// /// Constructor. /// /// The browser that hosts the /// The frame that called CefSharp.PostMessage in Javascript. /// Message can be a primative type or a simple object that represents a copy of the data sent from the /// browser. public JavascriptMessageReceivedEventArgs(IBrowser browser, IFrame frame, object message) { Browser = browser; Frame = frame; Message = message; } /// /// Converts the to a specific type using the /// that CefSharp provides /// /// Type /// Type public T ConvertMessageTo() { if (Message == null) { return default(T); } return (T)Binder.Bind(Message, typeof(T)); } } }