1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
7 #if !defined(OS_ANDROID)
8 #include "chrome/browser/devtools/devtools_window.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/devtools_agent_host.h"
11 #endif // !defined(OS_ANDROID)
13 ChromeDevToolsManagerDelegate::ChromeDevToolsManagerDelegate()
14 : network_protocol_handler_(new DevToolsNetworkProtocolHandler()) {
17 ChromeDevToolsManagerDelegate::~ChromeDevToolsManagerDelegate() {
20 void ChromeDevToolsManagerDelegate::Inspect(
21 content::BrowserContext
* browser_context
,
22 content::DevToolsAgentHost
* agent_host
) {
23 #if !defined(OS_ANDROID)
24 content::DevToolsAgentHost::Type type
= agent_host
->GetType();
25 if (type
!= content::DevToolsAgentHost::TYPE_SHARED_WORKER
&&
26 type
!= content::DevToolsAgentHost::TYPE_SERVICE_WORKER
) {
27 // TODO(horo): Support other types of DevToolsAgentHost when necessary.
28 NOTREACHED() << "Inspect() only supports workers.";
30 if (Profile
* profile
= Profile::FromBrowserContext(browser_context
))
31 DevToolsWindow::OpenDevToolsWindowForWorker(profile
, agent_host
);
32 #endif // !defined(OS_ANDROID)
35 base::DictionaryValue
* ChromeDevToolsManagerDelegate::HandleCommand(
36 content::DevToolsAgentHost
* agent_host
,
37 base::DictionaryValue
* command_dict
) {
38 return network_protocol_handler_
->HandleCommand(agent_host
, command_dict
);
41 void ChromeDevToolsManagerDelegate::DevToolsAgentStateChanged(
42 content::DevToolsAgentHost
* agent_host
,
44 network_protocol_handler_
->DevToolsAgentStateChanged(agent_host
, attached
);