forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchrome_devtools_manager_delegate.cc
54 lines (46 loc) · 1.95 KB
/
chrome_devtools_manager_delegate.cc
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
// Copyright 2014 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.
#include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
#include "build/build_config.h"
#include "chrome/browser/devtools/devtools_network_protocol_handler.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/devtools_agent_host.h"
#endif // !defined(OS_ANDROID)
ChromeDevToolsManagerDelegate::ChromeDevToolsManagerDelegate()
: network_protocol_handler_(new DevToolsNetworkProtocolHandler()) {
}
ChromeDevToolsManagerDelegate::~ChromeDevToolsManagerDelegate() {
}
void ChromeDevToolsManagerDelegate::Inspect(
content::BrowserContext* browser_context,
content::DevToolsAgentHost* agent_host) {
#if !defined(OS_ANDROID)
Profile* profile = Profile::FromBrowserContext(browser_context);
if (!profile)
return;
content::DevToolsAgentHost::Type type = agent_host->GetType();
if (type == content::DevToolsAgentHost::TYPE_SHARED_WORKER ||
type == content::DevToolsAgentHost::TYPE_SERVICE_WORKER) {
DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host);
return;
}
if (type == content::DevToolsAgentHost::TYPE_WEB_CONTENTS) {
content::WebContents* web_contents = agent_host->GetWebContents();
DCHECK(web_contents);
DevToolsWindow::OpenDevToolsWindow(web_contents);
}
#endif // !defined(OS_ANDROID)
}
base::DictionaryValue* ChromeDevToolsManagerDelegate::HandleCommand(
content::DevToolsAgentHost* agent_host,
base::DictionaryValue* command_dict) {
return network_protocol_handler_->HandleCommand(agent_host, command_dict);
}
void ChromeDevToolsManagerDelegate::DevToolsAgentStateChanged(
content::DevToolsAgentHost* agent_host,
bool attached) {
network_protocol_handler_->DevToolsAgentStateChanged(agent_host, attached);
}