| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "headless/lib/browser/headless_devtools_manager_delegate.h" | 5 #include "headless/lib/browser/headless_devtools_manager_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/devtools_agent_host.h" | |
| 12 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 13 #include "headless/lib/browser/headless_browser_context_impl.h" | 12 #include "headless/lib/browser/headless_browser_context_impl.h" |
| 14 #include "headless/lib/browser/headless_browser_impl.h" | 13 #include "headless/lib/browser/headless_browser_impl.h" |
| 15 #include "headless/lib/browser/headless_web_contents_impl.h" | 14 #include "headless/lib/browser/headless_web_contents_impl.h" |
| 16 #include "headless/public/domains/browser.h" | 15 #include "headless/public/domains/browser.h" |
| 17 | 16 |
| 18 namespace headless { | 17 namespace headless { |
| 19 | 18 |
| 20 HeadlessDevToolsManagerDelegate::HeadlessDevToolsManagerDelegate( | 19 HeadlessDevToolsManagerDelegate::HeadlessDevToolsManagerDelegate( |
| 21 base::WeakPtr<HeadlessBrowserImpl> browser) | 20 base::WeakPtr<HeadlessBrowserImpl> browser) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 std::unique_ptr<base::Value> cmd_result(((this)->*command_fn_ptr)(params)); | 54 std::unique_ptr<base::Value> cmd_result(((this)->*command_fn_ptr)(params)); |
| 56 if (!cmd_result) | 55 if (!cmd_result) |
| 57 return nullptr; | 56 return nullptr; |
| 58 | 57 |
| 59 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 58 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 60 result->SetInteger("id", id); | 59 result->SetInteger("id", id); |
| 61 result->Set("result", std::move(cmd_result)); | 60 result->Set("result", std::move(cmd_result)); |
| 62 return result.release(); | 61 return result.release(); |
| 63 } | 62 } |
| 64 | 63 |
| 65 std::string HeadlessDevToolsManagerDelegate::GetTargetType( | |
| 66 content::RenderFrameHost* host) { | |
| 67 return content::DevToolsAgentHost::kTypePage; | |
| 68 } | |
| 69 | |
| 70 std::string HeadlessDevToolsManagerDelegate::GetTargetTitle( | |
| 71 content::RenderFrameHost* host) { | |
| 72 return ""; | |
| 73 } | |
| 74 | |
| 75 std::unique_ptr<base::Value> HeadlessDevToolsManagerDelegate::CreateTarget( | 64 std::unique_ptr<base::Value> HeadlessDevToolsManagerDelegate::CreateTarget( |
| 76 const base::DictionaryValue* params) { | 65 const base::DictionaryValue* params) { |
| 77 std::string url; | 66 std::string url; |
| 78 std::string browser_context_id; | 67 std::string browser_context_id; |
| 79 int width = browser_->options()->window_size.width(); | 68 int width = browser_->options()->window_size.width(); |
| 80 int height = browser_->options()->window_size.height(); | 69 int height = browser_->options()->window_size.height(); |
| 81 params->GetString("url", &url); | 70 params->GetString("url", &url); |
| 82 params->GetString("browserContextId", &browser_context_id); | 71 params->GetString("browserContextId", &browser_context_id); |
| 83 params->GetInteger("width", &width); | 72 params->GetInteger("width", &width); |
| 84 params->GetInteger("height", &height); | 73 params->GetInteger("height", &height); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 context->Close(); | 144 context->Close(); |
| 156 } | 145 } |
| 157 | 146 |
| 158 return browser::DisposeBrowserContextResult::Builder() | 147 return browser::DisposeBrowserContextResult::Builder() |
| 159 .SetSuccess(success) | 148 .SetSuccess(success) |
| 160 .Build() | 149 .Build() |
| 161 ->Serialize(); | 150 ->Serialize(); |
| 162 } | 151 } |
| 163 | 152 |
| 164 } // namespace headless | 153 } // namespace headless |
| OLD | NEW |