mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 09:35:59 -04:00
cdp: add console enable/disable commands
This commit is contained in:
@@ -236,6 +236,7 @@ fn dispatchCommand(command: *Command, method: []const u8) !void {
|
||||
asUint(u56, "Runtime") => return @import("domains/runtime.zig").processMessage(command),
|
||||
asUint(u56, "Network") => return @import("domains/network.zig").processMessage(command),
|
||||
asUint(u56, "Storage") => return @import("domains/storage.zig").processMessage(command),
|
||||
asUint(u56, "Console") => return @import("domains/console.zig").processMessage(command),
|
||||
else => {},
|
||||
},
|
||||
8 => switch (@as(u64, @bitCast(domain[0..8].*))) {
|
||||
@@ -632,6 +633,9 @@ pub const BrowserContext = struct {
|
||||
self.notification.unregister(.frame_network_almost_idle, self);
|
||||
}
|
||||
|
||||
pub fn consoleEnable(_: *BrowserContext) !void {}
|
||||
pub fn consoleDisable(_: *BrowserContext) void {}
|
||||
|
||||
pub fn onFrameRemove(ctx: *anyopaque, _: Notification.FrameRemove) !void {
|
||||
const self: *BrowserContext = @ptrCast(@alignCast(ctx));
|
||||
@import("domains/page.zig").frameRemove(self);
|
||||
|
||||
45
src/cdp/domains/console.zig
Normal file
45
src/cdp/domains/console.zig
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
|
||||
//
|
||||
// Francis Bouvier <francis@lightpanda.io>
|
||||
// Pierre Tachoire <pierre@lightpanda.io>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
const CDP = @import("../CDP.zig");
|
||||
|
||||
pub fn processMessage(cmd: *CDP.Command) !void {
|
||||
const action = std.meta.stringToEnum(enum {
|
||||
enable,
|
||||
disable,
|
||||
}, cmd.input.action) orelse return error.UnknownMethod;
|
||||
|
||||
switch (action) {
|
||||
.enable => return enable(cmd),
|
||||
.disable => return disable(cmd),
|
||||
}
|
||||
}
|
||||
|
||||
fn enable(cmd: *CDP.Command) !void {
|
||||
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
|
||||
try bc.consoleEnable();
|
||||
return cmd.sendResult(null, .{});
|
||||
}
|
||||
|
||||
fn disable(cmd: *CDP.Command) !void {
|
||||
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
|
||||
bc.consoleDisable();
|
||||
return cmd.sendResult(null, .{});
|
||||
}
|
||||
Reference in New Issue
Block a user