// Copyright © 2020 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 System.IO; namespace CefSharp.Callback { /// /// Callback interface for . /// The methods of this class will be called on the CEF UI thread. /// public interface IDevToolsMessageObserver : IDisposable { /// /// Method that will be called on receipt of a DevTools protocol message. /// Method result dictionaries include an "id" (int) value that identifies the /// orginating method call sent from IBrowserHost.SendDevToolsMessage, and /// optionally either a "result" (dictionary) or "error" (dictionary) value. /// The "error" dictionary will contain "code" (int) and "message" (string) /// values. Event dictionaries include a "method" (string) value and optionally /// a "params" (dictionary) value. See the DevTools protocol documentation at /// https://chromedevtools.github.io/devtools-protocol/ for details of /// supported method calls and the expected "result" or "params" dictionary /// contents. JSON dictionaries can be parsed using the CefParseJSON function /// if desired, however be aware of performance considerations when parsing /// large messages (some of which may exceed 1MB in size). /// /// is the originating browser instance /// is a UTF8-encoded JSON dictionary representing either a method result or an event. /// is only valid for the scope of this callback and should be copied if necessary /// /// Return true if the message was handled or false if the message /// should be further processed and passed to the OnDevToolsMethodResult or /// OnDevToolsEvent methods as appropriate. bool OnDevToolsMessage(IBrowser browser, Stream message); /// /// Method that will be called after attempted execution of a DevTools protocol /// /// is the originating browser instance /// is the id value that identifies the originating method call message /// If the method succeeded will be true and will be the /// UTF8-encoded JSON "result" dictionary value (which may be empty). /// If the method failed will be false and will be the UTF8-encoded /// JSON "error" dictionary value. /// /// The stream is only valid for the scope of this /// callback and should be copied if necessary. See the OnDevToolsMessage /// documentation for additional details on contents void OnDevToolsMethodResult(IBrowser browser, int messageId, bool success, Stream result); /// /// Method that will be called on receipt of a DevTools protocol event. /// /// is the originating browser instance /// is the method value /// is the UTF8-encoded JSON "params" dictionary value (which /// may be empty). This stream is only valid for the scope of this callback and /// should be copied if necessary. See the OnDevToolsMessage documentation for /// additional details on contents. /// void OnDevToolsEvent(IBrowser browser, string method, Stream parameters); /// /// Method that will be called when the DevTools agent has attached. /// This will generally occur in response to the first message sent while the agent is detached. /// /// is the originating browser instance void OnDevToolsAgentAttached(IBrowser browser); /// /// Method that will be called when the DevTools agent has detached. /// Any method results that were pending before the agent became detached will not be delivered, and any active /// event subscriptions will be canceled. /// /// is the originating browser instance void OnDevToolsAgentDetached(IBrowser browser); } }