Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Side by Side Diff: headless/lib/browser/headless_devtools_manager_delegate.cc

Issue 2735943005: Override CreateNewTarget in the HeadlessDevToolsManagerDelegate to be able to create new tabs in he… (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « headless/lib/browser/headless_devtools_manager_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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", &params); 105 command->GetDictionary("params", &params);
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
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
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_devtools_manager_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698