OLD | NEW |
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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 gfx::Rect tab_contents_bounds; | 396 gfx::Rect tab_contents_bounds; |
397 chrome::GetActiveWebContents(browser())->GetContainerBounds( | 397 chrome::GetActiveWebContents(browser())->GetContainerBounds( |
398 &tab_contents_bounds); | 398 &tab_contents_bounds); |
399 | 399 |
400 gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), | 400 gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), |
401 tab_contents_bounds.y() - root_bounds.y(), | 401 tab_contents_bounds.y() - root_bounds.y(), |
402 tab_contents_bounds.width(), | 402 tab_contents_bounds.width(), |
403 tab_contents_bounds.height()); | 403 tab_contents_bounds.height()); |
404 | 404 |
405 gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); | 405 gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); |
406 if (!browser::GrabWindowSnapshot(native_window, &png, snapshot_bounds)) { | 406 if (!browser::GrabWindowSnapshotIfPermitted(native_window, &png, |
407 LOG(ERROR) << "browser::GrabWindowSnapShot() failed"; | 407 snapshot_bounds)) { |
| 408 LOG(ERROR) << "browser::GrabWindowSnapshotIfPermitted() failed"; |
408 return false; | 409 return false; |
409 } | 410 } |
410 | 411 |
411 if (!gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&*png.begin()), | 412 if (!gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&*png.begin()), |
412 png.size(), bitmap)) { | 413 png.size(), bitmap)) { |
413 LOG(ERROR) << "Decode PNG to a SkBitmap failed"; | 414 LOG(ERROR) << "Decode PNG to a SkBitmap failed"; |
414 return false; | 415 return false; |
415 } | 416 } |
416 return true; | 417 return true; |
417 } | 418 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 IN_PROC_BROWSER_TEST_F(Canvas2DPixelTestSD, Canvas2DRedBoxSD) { | 504 IN_PROC_BROWSER_TEST_F(Canvas2DPixelTestSD, Canvas2DRedBoxSD) { |
504 // If test baseline needs to be updated after a given revision, update the | 505 // If test baseline needs to be updated after a given revision, update the |
505 // following number. If no revision requirement, then 0. | 506 // following number. If no revision requirement, then 0. |
506 const int64 ref_img_revision_update = 123489; | 507 const int64 ref_img_revision_update = 123489; |
507 | 508 |
508 gfx::Size container_size(400, 300); | 509 gfx::Size container_size(400, 300); |
509 FilePath url = | 510 FilePath url = |
510 test_data_dir().AppendASCII("pixel_canvas2d.html"); | 511 test_data_dir().AppendASCII("pixel_canvas2d.html"); |
511 RunPixelTest(container_size, url, ref_img_revision_update); | 512 RunPixelTest(container_size, url, ref_img_revision_update); |
512 } | 513 } |
OLD | NEW |