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

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: Disabled test on MacOS >=10.11, added ref to bug. 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_ANDROID) 95 #if defined(OS_ANDROID)
95 #include "ui/android/view_android.h" 96 #include "ui/android/view_android.h"
96 #endif 97 #endif
97 98
98 #if defined(OS_MACOSX) 99 #if defined(OS_MACOSX)
99 #include "device/power_save_blocker/power_save_blocker.h" 100 #include "device/power_save_blocker/power_save_blocker.h"
(...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 2368
2368 #if defined(OS_ANDROID) 2369 #if defined(OS_ANDROID)
2369 // On Android, call sites should pass in the bounds with correct offset 2370 // On Android, call sites should pass in the bounds with correct offset
2370 // to capture the intended content area. 2371 // to capture the intended content area.
2371 gfx::Rect snapshot_bounds(GetView()->GetViewBounds()); 2372 gfx::Rect snapshot_bounds(GetView()->GetViewBounds());
2372 snapshot_bounds.Offset(0, GetView()->GetNativeView()->content_offset().y()); 2373 snapshot_bounds.Offset(0, GetView()->GetNativeView()->content_offset().y());
2373 #else 2374 #else
2374 gfx::Rect snapshot_bounds(GetView()->GetViewBounds().size()); 2375 gfx::Rect snapshot_bounds(GetView()->GetViewBounds().size());
2375 #endif 2376 #endif
2376 2377
2377 std::vector<unsigned char> png; 2378 gfx::Image image;
2378 if (ui::GrabViewSnapshot( 2379 if (ui::GrabViewSnapshot(GetView()->GetNativeView(), snapshot_bounds,
2379 GetView()->GetNativeView(), &png, snapshot_bounds)) { 2380 &image)) {
2380 OnSnapshotDataReceived(snapshot_id, &png.front(), png.size()); 2381 OnSnapshotReceived(snapshot_id, image);
2381 return; 2382 return;
2382 } 2383 }
2383 2384
2384 ui::GrabViewSnapshotAsync( 2385 ui::GrabViewSnapshotAsync(
2385 GetView()->GetNativeView(), 2386 GetView()->GetNativeView(), snapshot_bounds,
2386 snapshot_bounds, 2387 base::Bind(&RenderWidgetHostImpl::OnSnapshotReceived,
2387 base::ThreadTaskRunnerHandle::Get(), 2388 weak_factory_.GetWeakPtr(), snapshot_id));
2388 base::Bind(&RenderWidgetHostImpl::OnSnapshotDataReceivedAsync,
2389 weak_factory_.GetWeakPtr(),
2390 snapshot_id));
2391 } 2389 }
2392 2390
2393 void RenderWidgetHostImpl::OnSnapshotDataReceived(int snapshot_id, 2391 void RenderWidgetHostImpl::OnSnapshotReceived(int snapshot_id,
2394 const unsigned char* data, 2392 const gfx::Image& image) {
2395 size_t size) {
2396 // Any pending snapshots with a lower ID than the one received are considered 2393 // Any pending snapshots with a lower ID than the one received are considered
2397 // to be implicitly complete, and returned the same snapshot data. 2394 // to be implicitly complete, and returned the same snapshot data.
2398 PendingSnapshotMap::iterator it = pending_browser_snapshots_.begin(); 2395 PendingSnapshotMap::iterator it = pending_browser_snapshots_.begin();
2399 while (it != pending_browser_snapshots_.end()) { 2396 while (it != pending_browser_snapshots_.end()) {
2400 if (it->first <= snapshot_id) { 2397 if (it->first <= snapshot_id) {
2401 it->second.Run(data, size); 2398 it->second.Run(image);
2402 pending_browser_snapshots_.erase(it++); 2399 pending_browser_snapshots_.erase(it++);
2403 } else { 2400 } else {
2404 ++it; 2401 ++it;
2405 } 2402 }
2406 } 2403 }
2407 #if defined(OS_MACOSX) 2404 #if defined(OS_MACOSX)
2408 if (pending_browser_snapshots_.empty()) 2405 if (pending_browser_snapshots_.empty())
2409 power_save_blocker_.reset(); 2406 power_save_blocker_.reset();
2410 #endif 2407 #endif
2411 } 2408 }
2412 2409
2413 void RenderWidgetHostImpl::OnSnapshotDataReceivedAsync(
2414 int snapshot_id,
2415 scoped_refptr<base::RefCountedBytes> png_data) {
2416 if (png_data.get())
2417 OnSnapshotDataReceived(snapshot_id, png_data->front(), png_data->size());
2418 else
2419 OnSnapshotDataReceived(snapshot_id, NULL, 0);
2420 }
2421
2422 // static 2410 // static
2423 void RenderWidgetHostImpl::CompositorFrameDrawn( 2411 void RenderWidgetHostImpl::CompositorFrameDrawn(
2424 const std::vector<ui::LatencyInfo>& latency_info) { 2412 const std::vector<ui::LatencyInfo>& latency_info) {
2425 for (size_t i = 0; i < latency_info.size(); i++) { 2413 for (size_t i = 0; i < latency_info.size(); i++) {
2426 std::set<RenderWidgetHostImpl*> rwhi_set; 2414 std::set<RenderWidgetHostImpl*> rwhi_set;
2427 for (const auto& lc : latency_info[i].latency_components()) { 2415 for (const auto& lc : latency_info[i].latency_components()) {
2428 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || 2416 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT ||
2429 lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT || 2417 lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT ||
2430 lc.first.first == ui::TAB_SHOW_COMPONENT) { 2418 lc.first.first == ui::TAB_SHOW_COMPONENT) {
2431 // Matches with GetLatencyComponentId 2419 // Matches with GetLatencyComponentId
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 // different from the receiver's. 2520 // different from the receiver's.
2533 file_system_file.url = 2521 file_system_file.url =
2534 GURL(storage::GetIsolatedFileSystemRootURIString( 2522 GURL(storage::GetIsolatedFileSystemRootURIString(
2535 file_system_url.origin(), filesystem_id, std::string()) 2523 file_system_url.origin(), filesystem_id, std::string())
2536 .append(register_name)); 2524 .append(register_name));
2537 file_system_file.filesystem_id = filesystem_id; 2525 file_system_file.filesystem_id = filesystem_id;
2538 } 2526 }
2539 } 2527 }
2540 2528
2541 } // namespace content 2529 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | testing/buildbot/chromium.linux.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698