| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/test/ui_test_utils.h" | 5 #include "chrome/test/ui_test_utils.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 class SnapshotTaker { | 844 class SnapshotTaker { |
| 845 public: | 845 public: |
| 846 SnapshotTaker() : bitmap_(NULL) {} | 846 SnapshotTaker() : bitmap_(NULL) {} |
| 847 | 847 |
| 848 bool TakeRenderWidgetSnapshot(RenderWidgetHost* rwh, | 848 bool TakeRenderWidgetSnapshot(RenderWidgetHost* rwh, |
| 849 const gfx::Size& page_size, | 849 const gfx::Size& page_size, |
| 850 const gfx::Size& desired_size, | 850 const gfx::Size& desired_size, |
| 851 SkBitmap* bitmap) WARN_UNUSED_RESULT { | 851 SkBitmap* bitmap) WARN_UNUSED_RESULT { |
| 852 bitmap_ = bitmap; | 852 bitmap_ = bitmap; |
| 853 ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator(); | 853 ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator(); |
| 854 rwh->set_painting_observer(generator); | 854 generator->MonitorRenderer(rwh, true); |
| 855 snapshot_taken_ = false; | 855 snapshot_taken_ = false; |
| 856 generator->AskForSnapshot( | 856 generator->AskForSnapshot( |
| 857 rwh, | 857 rwh, |
| 858 false, // don't use backing_store | 858 false, // don't use backing_store |
| 859 NewCallback(this, &SnapshotTaker::OnSnapshotTaken), | 859 NewCallback(this, &SnapshotTaker::OnSnapshotTaken), |
| 860 page_size, | 860 page_size, |
| 861 desired_size); | 861 desired_size); |
| 862 ui_test_utils::RunMessageLoop(); | 862 ui_test_utils::RunMessageLoop(); |
| 863 return snapshot_taken_; | 863 return snapshot_taken_; |
| 864 } | 864 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); | 912 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); |
| 913 } | 913 } |
| 914 | 914 |
| 915 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { | 915 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { |
| 916 DCHECK(bitmap); | 916 DCHECK(bitmap); |
| 917 SnapshotTaker taker; | 917 SnapshotTaker taker; |
| 918 return taker.TakeEntirePageSnapshot(rvh, bitmap); | 918 return taker.TakeEntirePageSnapshot(rvh, bitmap); |
| 919 } | 919 } |
| 920 | 920 |
| 921 } // namespace ui_test_utils | 921 } // namespace ui_test_utils |
| OLD | NEW |