| Index: content/shell/browser/shell_devtools_manager_delegate.cc
|
| diff --git a/content/shell/browser/shell_devtools_manager_delegate.cc b/content/shell/browser/shell_devtools_manager_delegate.cc
|
| index 2d3837a31854f8ba508ff7462a4aee290f3916fa..8ab636652de4a40bc6ee4f12912998022a54f19f 100644
|
| --- a/content/shell/browser/shell_devtools_manager_delegate.cc
|
| +++ b/content/shell/browser/shell_devtools_manager_delegate.cc
|
| @@ -17,7 +17,6 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "build/build_config.h"
|
| -#include "components/devtools_discovery/devtools_discovery_manager.h"
|
| #include "components/devtools_http_handler/devtools_http_handler.h"
|
| #include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/devtools_agent_host.h"
|
| @@ -134,21 +133,12 @@ CreateSocketFactory() {
|
| #endif
|
| }
|
|
|
| -scoped_refptr<content::DevToolsAgentHost>
|
| -CreateNewShellTarget(BrowserContext* browser_context, const GURL& url) {
|
| - Shell* shell = Shell::CreateNewWindow(browser_context,
|
| - url,
|
| - nullptr,
|
| - gfx::Size());
|
| - return DevToolsAgentHost::GetOrCreateFor(shell->web_contents());
|
| -}
|
| -
|
| // ShellDevToolsDelegate ----------------------------------------------------
|
|
|
| class ShellDevToolsDelegate :
|
| public devtools_http_handler::DevToolsHttpHandlerDelegate {
|
| public:
|
| - explicit ShellDevToolsDelegate(BrowserContext* browser_context);
|
| + explicit ShellDevToolsDelegate();
|
| ~ShellDevToolsDelegate() override;
|
|
|
| // devtools_http_handler::DevToolsHttpHandlerDelegate implementation.
|
| @@ -162,16 +152,10 @@ class ShellDevToolsDelegate :
|
| DISALLOW_COPY_AND_ASSIGN(ShellDevToolsDelegate);
|
| };
|
|
|
| -ShellDevToolsDelegate::ShellDevToolsDelegate(BrowserContext* browser_context) {
|
| - devtools_discovery::DevToolsDiscoveryManager::GetInstance()->
|
| - SetCreateCallback(base::Bind(&CreateNewShellTarget,
|
| - base::Unretained(browser_context)));
|
| +ShellDevToolsDelegate::ShellDevToolsDelegate() {
|
| }
|
|
|
| ShellDevToolsDelegate::~ShellDevToolsDelegate() {
|
| - devtools_discovery::DevToolsDiscoveryManager::GetInstance()->
|
| - SetCreateCallback(
|
| - devtools_discovery::DevToolsDiscoveryManager::CreateCallback());
|
| }
|
|
|
| std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() {
|
| @@ -212,14 +196,16 @@ ShellDevToolsManagerDelegate::CreateHttpHandler(
|
| return new DevToolsHttpHandler(
|
| CreateSocketFactory(),
|
| frontend_url,
|
| - new ShellDevToolsDelegate(browser_context),
|
| + new ShellDevToolsDelegate(),
|
| browser_context->GetPath(),
|
| base::FilePath(),
|
| std::string(),
|
| GetShellUserAgent());
|
| }
|
|
|
| -ShellDevToolsManagerDelegate::ShellDevToolsManagerDelegate() {
|
| +ShellDevToolsManagerDelegate::ShellDevToolsManagerDelegate(
|
| + BrowserContext* browser_context)
|
| + : browser_context_(browser_context) {
|
| }
|
|
|
| ShellDevToolsManagerDelegate::~ShellDevToolsManagerDelegate() {
|
| @@ -228,10 +214,7 @@ ShellDevToolsManagerDelegate::~ShellDevToolsManagerDelegate() {
|
| base::DictionaryValue* ShellDevToolsManagerDelegate::HandleCommand(
|
| DevToolsAgentHost* agent_host,
|
| base::DictionaryValue* command_dict) {
|
| - std::unique_ptr<base::DictionaryValue> result =
|
| - devtools_discovery::DevToolsDiscoveryManager::GetInstance()
|
| - ->HandleCreateTargetCommand(command_dict);
|
| - return result.release(); // Caller takes ownership.
|
| + return HandleCreateTargetCommand(command_dict).release();
|
| }
|
|
|
| std::string ShellDevToolsManagerDelegate::GetTargetType(RenderFrameHost* host) {
|
| @@ -243,4 +226,41 @@ std::string ShellDevToolsManagerDelegate::GetTargetTitle(
|
| return "";
|
| }
|
|
|
| +
|
| +scoped_refptr<DevToolsAgentHost>
|
| +ShellDevToolsManagerDelegate::CreateNewTarget(const GURL& url) {
|
| + Shell* shell = Shell::CreateNewWindow(browser_context_,
|
| + url,
|
| + nullptr,
|
| + gfx::Size());
|
| + return DevToolsAgentHost::GetOrCreateFor(shell->web_contents());
|
| +}
|
| +
|
| +std::unique_ptr<base::DictionaryValue>
|
| +ShellDevToolsManagerDelegate::HandleCreateTargetCommand(
|
| + base::DictionaryValue* command_dict) {
|
| + int id;
|
| + std::string method;
|
| + std::string url;
|
| + const base::DictionaryValue* params_dict = nullptr;
|
| + if (command_dict->GetInteger("id", &id) &&
|
| + command_dict->GetString("method", &method) &&
|
| + method == "Browser.createTarget" &&
|
| + command_dict->GetDictionary("params", ¶ms_dict) &&
|
| + params_dict->GetString("url", &url)) {
|
| + scoped_refptr<content::DevToolsAgentHost> agent_host =
|
| + CreateNewTarget(GURL(url));
|
| + if (!agent_host)
|
| + return nullptr;
|
| + std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
|
| + result->SetInteger("id", id);
|
| + std::unique_ptr<base::DictionaryValue> cmd_result(
|
| + new base::DictionaryValue());
|
| + cmd_result->SetString("targetId", agent_host->GetId());
|
| + result->Set("result", std::move(cmd_result));
|
| + return result;
|
| + }
|
| + return nullptr;
|
| +}
|
| +
|
| } // namespace content
|
|
|