blob: da3ec21064bfe32303173dd0f56003bb684f21e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_MANAGER_H_
#define CONTENT_PUBLIC_BROWSER_DEVTOOLS_MANAGER_H_
#pragma once
#include <string>
#include "content/common/content_export.h"
#include "content/public/common/console_message_level.h"
class TabContents;
namespace IPC {
class Message;
}
namespace content {
class DevToolsAgentHost;
class DevToolsClientHost;
// DevToolsManager connects a devtools client to inspected agent and routes
// devtools messages between the inspected instance represented by the agent
// and devtools front-end represented by the client. If inspected agent
// gets terminated DevToolsManager will notify corresponding client and
// remove it from the map.
class CONTENT_EXPORT DevToolsManager {
public:
static DevToolsManager* GetInstance();
// Routes devtools message from |from| client to corresponding
// DevToolsAgentHost.
virtual bool DispatchOnInspectorBackend(DevToolsClientHost* from,
const std::string& message) = 0;
// Invoked when a tab is replaced by another tab. This is triggered by
// TabStripModel::ReplaceTabContentsAt.
virtual void TabReplaced(WebContents* old_tab, WebContents* new_tab) = 0;
// Closes all open developer tools windows.
virtual void CloseAllClientHosts() = 0;
// Returns client attached to the |agent_host| if there is one.
virtual DevToolsClientHost* GetDevToolsClientHostFor(
DevToolsAgentHost* agent_host) = 0;
// Returns agent that has |client_host| attachd to it if there is one.
virtual DevToolsAgentHost* GetDevToolsAgentHostFor(
DevToolsClientHost* client_host) = 0;
// Registers new DevToolsClientHost for inspected |agent_host|. There must be
// no other DevToolsClientHosts registered for the |agent_host| at the moment.
virtual void RegisterDevToolsClientHostFor(
DevToolsAgentHost* agent_host,
DevToolsClientHost* client_host) = 0;
// Unregisters given |agent_host|. DevToolsManager will notify corresponding
// client if one is attached.
virtual void UnregisterDevToolsClientHostFor(
DevToolsAgentHost* agent_host) = 0;
// Detaches client from |from_agent| and returns a cookie that allows to
// reattach that client to another agent later. Returns -1 if there is no
// client attached to |from_agent|.
virtual int DetachClientHost(DevToolsAgentHost* from_agent) = 0;
// Reattaches client host detached with DetachClientHost method above
// to |to_agent|.
virtual void AttachClientHost(int client_host_cookie,
DevToolsAgentHost* to_agent) = 0;
// This method will remove all references from the manager to the
// DevToolsClientHost and unregister all listeners related to the
// DevToolsClientHost. Called by closing client.
virtual void ClientHostClosing(DevToolsClientHost* client_host) = 0;
// Starts inspecting element at position (x, y) in the specified page.
virtual void InspectElement(DevToolsAgentHost* agent_host, int x, int y) = 0;
// Logs given |message| on behalf of the given |agent_host|.
virtual void AddMessageToConsole(DevToolsAgentHost* agent_host,
ConsoleMessageLevel level,
const std::string& message) = 0;
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_MANAGER_H_
|