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 <iostream> | 5 #include <iostream> |
6 #include <memory> | 6 #include <memory> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 void FetchDom() { | 205 void FetchDom() { |
206 devtools_client_->GetRuntime()->Evaluate( | 206 devtools_client_->GetRuntime()->Evaluate( |
207 "document.body.innerHTML", | 207 "document.body.innerHTML", |
208 base::Bind(&HeadlessShell::OnDomFetched, base::Unretained(this))); | 208 base::Bind(&HeadlessShell::OnDomFetched, base::Unretained(this))); |
209 } | 209 } |
210 | 210 |
211 void OnDomFetched(std::unique_ptr<runtime::EvaluateResult> result) { | 211 void OnDomFetched(std::unique_ptr<runtime::EvaluateResult> result) { |
212 if (result->GetWasThrown()) { | 212 if (result->GetExceptionDetails()) { |
213 LOG(ERROR) << "Failed to evaluate document.body.innerHTML"; | 213 LOG(ERROR) << "Failed to evaluate document.body.innerHTML"; |
214 } else { | 214 } else { |
215 std::string dom; | 215 std::string dom; |
216 if (result->GetResult()->GetValue()->GetAsString(&dom)) { | 216 if (result->GetResult()->GetValue()->GetAsString(&dom)) { |
217 std::cout << dom << std::endl; | 217 std::cout << dom << std::endl; |
218 } | 218 } |
219 } | 219 } |
220 Shutdown(); | 220 Shutdown(); |
221 } | 221 } |
222 | 222 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 LOG(ERROR) << "Malformed window size"; | 407 LOG(ERROR) << "Malformed window size"; |
408 return EXIT_FAILURE; | 408 return EXIT_FAILURE; |
409 } | 409 } |
410 builder.SetWindowSize(parsed_window_size); | 410 builder.SetWindowSize(parsed_window_size); |
411 } | 411 } |
412 | 412 |
413 return HeadlessBrowserMain( | 413 return HeadlessBrowserMain( |
414 builder.Build(), | 414 builder.Build(), |
415 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); | 415 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); |
416 } | 416 } |
OLD | NEW |