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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2592983002: [devtools] Support different encodings for Page.CaptureScreenshot. (Closed)
Patch Set: Wait for load in CaptureScreenshotTest to fix android bot. Created 3 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #include "skia/ext/platform_canvas.h" 80 #include "skia/ext/platform_canvas.h"
81 #include "storage/browser/fileapi/isolated_context.h" 81 #include "storage/browser/fileapi/isolated_context.h"
82 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 82 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
83 #include "ui/base/clipboard/clipboard.h" 83 #include "ui/base/clipboard/clipboard.h"
84 #include "ui/events/blink/web_input_event_traits.h" 84 #include "ui/events/blink/web_input_event_traits.h"
85 #include "ui/events/event.h" 85 #include "ui/events/event.h"
86 #include "ui/events/keycodes/keyboard_codes.h" 86 #include "ui/events/keycodes/keyboard_codes.h"
87 #include "ui/gfx/color_space.h" 87 #include "ui/gfx/color_space.h"
88 #include "ui/gfx/geometry/size_conversions.h" 88 #include "ui/gfx/geometry/size_conversions.h"
89 #include "ui/gfx/geometry/vector2d_conversions.h" 89 #include "ui/gfx/geometry/vector2d_conversions.h"
90 #include "ui/gfx/image/image.h"
90 #include "ui/gfx/image/image_skia.h" 91 #include "ui/gfx/image/image_skia.h"
91 #include "ui/gfx/skbitmap_operations.h" 92 #include "ui/gfx/skbitmap_operations.h"
92 #include "ui/snapshot/snapshot.h" 93 #include "ui/snapshot/snapshot.h"
93 94
94 #if defined(OS_MACOSX) 95 #if defined(OS_MACOSX)
95 #include "device/power_save_blocker/power_save_blocker.h" 96 #include "device/power_save_blocker/power_save_blocker.h"
96 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" 97 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
97 #endif 98 #endif
98 99
99 using base::Time; 100 using base::Time;
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 void RenderWidgetHostImpl::DidReceiveRendererFrame() { 2350 void RenderWidgetHostImpl::DidReceiveRendererFrame() {
2350 view_->DidReceiveRendererFrame(); 2351 view_->DidReceiveRendererFrame();
2351 } 2352 }
2352 2353
2353 void RenderWidgetHostImpl::WindowSnapshotReachedScreen(int snapshot_id) { 2354 void RenderWidgetHostImpl::WindowSnapshotReachedScreen(int snapshot_id) {
2354 DCHECK(base::MessageLoopForUI::IsCurrent()); 2355 DCHECK(base::MessageLoopForUI::IsCurrent());
2355 2356
2356 gfx::Rect view_bounds = GetView()->GetViewBounds(); 2357 gfx::Rect view_bounds = GetView()->GetViewBounds();
2357 gfx::Rect snapshot_bounds(view_bounds.size()); 2358 gfx::Rect snapshot_bounds(view_bounds.size());
2358 2359
2359 std::vector<unsigned char> png; 2360 gfx::Image image;
2360 if (ui::GrabViewSnapshot( 2361 if (ui::GrabViewSnapshot(GetView()->GetNativeView(), &image,
2361 GetView()->GetNativeView(), &png, snapshot_bounds)) { 2362 snapshot_bounds)) {
2362 OnSnapshotDataReceived(snapshot_id, &png.front(), png.size()); 2363 OnSnapshotReceived(snapshot_id, image);
2363 return; 2364 return;
2364 } 2365 }
2365 2366
2366 ui::GrabViewSnapshotAsync( 2367 ui::GrabViewSnapshotAsync(
2367 GetView()->GetNativeView(), 2368 GetView()->GetNativeView(), snapshot_bounds,
2368 snapshot_bounds, 2369 base::Bind(&RenderWidgetHostImpl::OnSnapshotReceived,
2369 base::ThreadTaskRunnerHandle::Get(), 2370 weak_factory_.GetWeakPtr(), snapshot_id));
2370 base::Bind(&RenderWidgetHostImpl::OnSnapshotDataReceivedAsync,
2371 weak_factory_.GetWeakPtr(),
2372 snapshot_id));
2373 } 2371 }
2374 2372
2375 void RenderWidgetHostImpl::OnSnapshotDataReceived(int snapshot_id, 2373 void RenderWidgetHostImpl::OnSnapshotReceived(int snapshot_id,
2376 const unsigned char* data, 2374 const gfx::Image& image) {
2377 size_t size) {
2378 // Any pending snapshots with a lower ID than the one received are considered 2375 // Any pending snapshots with a lower ID than the one received are considered
2379 // to be implicitly complete, and returned the same snapshot data. 2376 // to be implicitly complete, and returned the same snapshot data.
2380 PendingSnapshotMap::iterator it = pending_browser_snapshots_.begin(); 2377 PendingSnapshotMap::iterator it = pending_browser_snapshots_.begin();
2381 while (it != pending_browser_snapshots_.end()) { 2378 while (it != pending_browser_snapshots_.end()) {
2382 if (it->first <= snapshot_id) { 2379 if (it->first <= snapshot_id) {
2383 it->second.Run(data, size); 2380 it->second.Run(image);
2384 pending_browser_snapshots_.erase(it++); 2381 pending_browser_snapshots_.erase(it++);
2385 } else { 2382 } else {
2386 ++it; 2383 ++it;
2387 } 2384 }
2388 } 2385 }
2389 #if defined(OS_MACOSX) 2386 #if defined(OS_MACOSX)
2390 if (pending_browser_snapshots_.empty()) 2387 if (pending_browser_snapshots_.empty())
2391 power_save_blocker_.reset(); 2388 power_save_blocker_.reset();
2392 #endif 2389 #endif
2393 } 2390 }
2394 2391
2395 void RenderWidgetHostImpl::OnSnapshotDataReceivedAsync(
2396 int snapshot_id,
2397 scoped_refptr<base::RefCountedBytes> png_data) {
2398 if (png_data.get())
2399 OnSnapshotDataReceived(snapshot_id, png_data->front(), png_data->size());
2400 else
2401 OnSnapshotDataReceived(snapshot_id, NULL, 0);
2402 }
2403
2404 // static 2392 // static
2405 void RenderWidgetHostImpl::CompositorFrameDrawn( 2393 void RenderWidgetHostImpl::CompositorFrameDrawn(
2406 const std::vector<ui::LatencyInfo>& latency_info) { 2394 const std::vector<ui::LatencyInfo>& latency_info) {
2407 for (size_t i = 0; i < latency_info.size(); i++) { 2395 for (size_t i = 0; i < latency_info.size(); i++) {
2408 std::set<RenderWidgetHostImpl*> rwhi_set; 2396 std::set<RenderWidgetHostImpl*> rwhi_set;
2409 for (const auto& lc : latency_info[i].latency_components()) { 2397 for (const auto& lc : latency_info[i].latency_components()) {
2410 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || 2398 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT ||
2411 lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT || 2399 lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT ||
2412 lc.first.first == ui::TAB_SHOW_COMPONENT) { 2400 lc.first.first == ui::TAB_SHOW_COMPONENT) {
2413 // Matches with GetLatencyComponentId 2401 // Matches with GetLatencyComponentId
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 // different from the receiver's. 2502 // different from the receiver's.
2515 file_system_file.url = 2503 file_system_file.url =
2516 GURL(storage::GetIsolatedFileSystemRootURIString( 2504 GURL(storage::GetIsolatedFileSystemRootURIString(
2517 file_system_url.origin(), filesystem_id, std::string()) 2505 file_system_url.origin(), filesystem_id, std::string())
2518 .append(register_name)); 2506 .append(register_name));
2519 file_system_file.filesystem_id = filesystem_id; 2507 file_system_file.filesystem_id = filesystem_id;
2520 } 2508 }
2521 } 2509 }
2522 2510
2523 } // namespace content 2511 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698