| 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" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if (find_it == command_map_.end()) | 101 if (find_it == command_map_.end()) |
| 102 return nullptr; | 102 return nullptr; |
| 103 CommandMemberFnPtr command_fn_ptr = find_it->second; | 103 CommandMemberFnPtr command_fn_ptr = find_it->second; |
| 104 const base::DictionaryValue* params = nullptr; | 104 const base::DictionaryValue* params = nullptr; |
| 105 command->GetDictionary("params", ¶ms); | 105 command->GetDictionary("params", ¶ms); |
| 106 std::unique_ptr<base::DictionaryValue> cmd_result( | 106 std::unique_ptr<base::DictionaryValue> cmd_result( |
| 107 ((this)->*command_fn_ptr)(id, params)); | 107 ((this)->*command_fn_ptr)(id, params)); |
| 108 return cmd_result.release(); | 108 return cmd_result.release(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 scoped_refptr<content::DevToolsAgentHost> |
| 112 HeadlessDevToolsManagerDelegate::CreateNewTarget(const GURL& url) { |
| 113 HeadlessBrowserContext* context = browser_->GetDefaultBrowserContext(); |
| 114 HeadlessWebContentsImpl* web_contents_impl = HeadlessWebContentsImpl::From( |
| 115 context->CreateWebContentsBuilder() |
| 116 .SetInitialURL(url) |
| 117 .SetWindowSize(browser_->options()->window_size) |
| 118 .Build()); |
| 119 return content::DevToolsAgentHost::GetOrCreateFor( |
| 120 web_contents_impl->web_contents()); |
| 121 } |
| 122 |
| 111 std::string HeadlessDevToolsManagerDelegate::GetDiscoveryPageHTML() { | 123 std::string HeadlessDevToolsManagerDelegate::GetDiscoveryPageHTML() { |
| 112 return ResourceBundle::GetSharedInstance() | 124 return ResourceBundle::GetSharedInstance() |
| 113 .GetRawDataResource(IDR_HEADLESS_LIB_DEVTOOLS_DISCOVERY_PAGE) | 125 .GetRawDataResource(IDR_HEADLESS_LIB_DEVTOOLS_DISCOVERY_PAGE) |
| 114 .as_string(); | 126 .as_string(); |
| 115 } | 127 } |
| 116 | 128 |
| 117 std::string HeadlessDevToolsManagerDelegate::GetFrontendResource( | 129 std::string HeadlessDevToolsManagerDelegate::GetFrontendResource( |
| 118 const std::string& path) { | 130 const std::string& path) { |
| 119 return content::DevToolsFrontendHost::GetFrontendResource(path).as_string(); | 131 return content::DevToolsFrontendHost::GetFrontendResource(path).as_string(); |
| 120 } | 132 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 230 |
| 219 std::unique_ptr<base::Value> result( | 231 std::unique_ptr<base::Value> result( |
| 220 target::DisposeBrowserContextResult::Builder() | 232 target::DisposeBrowserContextResult::Builder() |
| 221 .SetSuccess(success) | 233 .SetSuccess(success) |
| 222 .Build() | 234 .Build() |
| 223 ->Serialize()); | 235 ->Serialize()); |
| 224 return CreateSuccessResponse(command_id, std::move(result)); | 236 return CreateSuccessResponse(command_id, std::move(result)); |
| 225 } | 237 } |
| 226 | 238 |
| 227 } // namespace headless | 239 } // namespace headless |
| OLD | NEW |