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 <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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 270 } |
271 | 271 |
272 return Response::InvalidParams("No entry with passed id"); | 272 return Response::InvalidParams("No entry with passed id"); |
273 } | 273 } |
274 | 274 |
275 Response PageHandler::CaptureScreenshot(DevToolsCommandId command_id) { | 275 Response PageHandler::CaptureScreenshot(DevToolsCommandId command_id) { |
276 if (!host_ || !host_->GetRenderWidgetHost()) | 276 if (!host_ || !host_->GetRenderWidgetHost()) |
277 return Response::InternalError("Could not connect to view"); | 277 return Response::InternalError("Could not connect to view"); |
278 | 278 |
279 host_->GetRenderWidgetHost()->GetSnapshotFromBrowser( | 279 host_->GetRenderWidgetHost()->GetSnapshotFromBrowser( |
280 base::Bind(&PageHandler::ScreenshotCaptured, | 280 base::Bind(&PageHandler::ScreenshotCaptured, weak_factory_.GetWeakPtr(), |
281 weak_factory_.GetWeakPtr(), command_id)); | 281 command_id)); |
282 return Response::OK(); | 282 return Response::OK(); |
283 } | 283 } |
284 | 284 |
285 Response PageHandler::CanScreencast(bool* result) { | 285 Response PageHandler::CanScreencast(bool* result) { |
286 #if defined(OS_ANDROID) | 286 #if defined(OS_ANDROID) |
287 *result = true; | 287 *result = true; |
288 #else | 288 #else |
289 *result = false; | 289 *result = false; |
290 #endif // defined(OS_ANDROID) | 290 #endif // defined(OS_ANDROID) |
291 return Response::OK(); | 291 return Response::OK(); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 client_->SendError(command_id, | 498 client_->SendError(command_id, |
499 Response::InternalError("Unable to capture screenshot")); | 499 Response::InternalError("Unable to capture screenshot")); |
500 return; | 500 return; |
501 } | 501 } |
502 | 502 |
503 std::string base_64_data; | 503 std::string base_64_data; |
504 base::Base64Encode( | 504 base::Base64Encode( |
505 base::StringPiece(reinterpret_cast<const char*>(png_data), png_size), | 505 base::StringPiece(reinterpret_cast<const char*>(png_data), png_size), |
506 &base_64_data); | 506 &base_64_data); |
507 | 507 |
508 client_->SendCaptureScreenshotResponse(command_id, | 508 client_->SendCaptureScreenshotResponse( |
509 CaptureScreenshotResponse::Create()->set_data(base_64_data)); | 509 command_id, CaptureScreenshotResponse::Create()->set_data(base_64_data)); |
510 } | 510 } |
511 | 511 |
512 void PageHandler::OnColorPicked(int r, int g, int b, int a) { | 512 void PageHandler::OnColorPicked(int r, int g, int b, int a) { |
513 scoped_refptr<dom::RGBA> color = | 513 scoped_refptr<dom::RGBA> color = |
514 dom::RGBA::Create()->set_r(r)->set_g(g)->set_b(b)->set_a(a); | 514 dom::RGBA::Create()->set_r(r)->set_g(g)->set_b(b)->set_a(a); |
515 client_->ColorPicked(ColorPickedParams::Create()->set_color(color)); | 515 client_->ColorPicked(ColorPickedParams::Create()->set_color(color)); |
516 } | 516 } |
517 | 517 |
518 } // namespace page | 518 } // namespace page |
519 } // namespace devtools | 519 } // namespace devtools |
520 } // namespace content | 520 } // namespace content |
OLD | NEW |