| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/devtools/protocol/page_handler.h" | 5 #include "content/browser/devtools/protocol/page_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 8 #include <memory> |
| 7 #include <string> | 9 #include <string> |
| 10 #include <utility> |
| 11 #include <vector> |
| 8 | 12 |
| 9 #include "base/base64.h" | 13 #include "base/base64.h" |
| 10 #include "base/bind.h" | 14 #include "base/bind.h" |
| 11 #include "base/location.h" | 15 #include "base/location.h" |
| 12 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
| 14 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/task_scheduler/post_task.h" | 21 #include "base/task_scheduler/post_task.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 return Response::OK(); | 281 return Response::OK(); |
| 278 } | 282 } |
| 279 } | 283 } |
| 280 | 284 |
| 281 return Response::InvalidParams("No entry with passed id"); | 285 return Response::InvalidParams("No entry with passed id"); |
| 282 } | 286 } |
| 283 | 287 |
| 284 void PageHandler::CaptureScreenshot( | 288 void PageHandler::CaptureScreenshot( |
| 285 Maybe<std::string> format, | 289 Maybe<std::string> format, |
| 286 Maybe<int> quality, | 290 Maybe<int> quality, |
| 291 Maybe<bool> from_surface, |
| 287 std::unique_ptr<CaptureScreenshotCallback> callback) { | 292 std::unique_ptr<CaptureScreenshotCallback> callback) { |
| 288 if (!host_ || !host_->GetRenderWidgetHost()) { | 293 if (!host_ || !host_->GetRenderWidgetHost()) { |
| 289 callback->sendFailure(Response::InternalError()); | 294 callback->sendFailure(Response::InternalError()); |
| 290 return; | 295 return; |
| 291 } | 296 } |
| 292 | 297 |
| 293 std::string screenshot_format = format.fromMaybe(kPng); | 298 std::string screenshot_format = format.fromMaybe(kPng); |
| 294 int screenshot_quality = quality.fromMaybe(kDefaultScreenshotQuality); | 299 int screenshot_quality = quality.fromMaybe(kDefaultScreenshotQuality); |
| 295 | 300 |
| 296 host_->GetRenderWidgetHost()->GetSnapshotFromBrowser( | 301 host_->GetRenderWidgetHost()->GetSnapshotFromBrowser( |
| 297 base::Bind(&PageHandler::ScreenshotCaptured, weak_factory_.GetWeakPtr(), | 302 base::Bind(&PageHandler::ScreenshotCaptured, weak_factory_.GetWeakPtr(), |
| 298 base::Passed(std::move(callback)), screenshot_format, | 303 base::Passed(std::move(callback)), screenshot_format, |
| 299 screenshot_quality)); | 304 screenshot_quality), |
| 305 from_surface.fromMaybe(false)); |
| 300 } | 306 } |
| 301 | 307 |
| 302 void PageHandler::PrintToPDF(std::unique_ptr<PrintToPDFCallback> callback) { | 308 void PageHandler::PrintToPDF(std::unique_ptr<PrintToPDFCallback> callback) { |
| 303 callback->sendFailure(Response::Error("PrintToPDF is not implemented")); | 309 callback->sendFailure(Response::Error("PrintToPDF is not implemented")); |
| 304 return; | 310 return; |
| 305 } | 311 } |
| 306 | 312 |
| 307 Response PageHandler::StartScreencast(Maybe<std::string> format, | 313 Response PageHandler::StartScreencast(Maybe<std::string> format, |
| 308 Maybe<int> quality, | 314 Maybe<int> quality, |
| 309 Maybe<int> max_width, | 315 Maybe<int> max_width, |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 Response PageHandler::StopLoading() { | 595 Response PageHandler::StopLoading() { |
| 590 WebContentsImpl* web_contents = GetWebContents(); | 596 WebContentsImpl* web_contents = GetWebContents(); |
| 591 if (!web_contents) | 597 if (!web_contents) |
| 592 return Response::InternalError(); | 598 return Response::InternalError(); |
| 593 web_contents->Stop(); | 599 web_contents->Stop(); |
| 594 return Response::OK(); | 600 return Response::OK(); |
| 595 } | 601 } |
| 596 | 602 |
| 597 } // namespace protocol | 603 } // namespace protocol |
| 598 } // namespace content | 604 } // namespace content |
| OLD | NEW |