Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigation_entry_screenshot_manager.h" | 5 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/task_scheduler/post_task.h" | 9 #include "base/task_scheduler/post_task.h" |
| 10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 int count = owner_->GetEntryCount(); | 106 int count = owner_->GetEntryCount(); |
| 107 for (int i = 0; i < count; ++i) { | 107 for (int i = 0; i < count; ++i) { |
| 108 ClearScreenshot(owner_->GetEntryAtIndex(i)); | 108 ClearScreenshot(owner_->GetEntryAtIndex(i)); |
| 109 } | 109 } |
| 110 DCHECK_EQ(GetScreenshotCount(), 0); | 110 DCHECK_EQ(GetScreenshotCount(), 0); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void NavigationEntryScreenshotManager::TakeScreenshotImpl( | 113 void NavigationEntryScreenshotManager::TakeScreenshotImpl( |
| 114 RenderViewHost* host, | 114 RenderViewHost* host, |
| 115 NavigationEntryImpl* entry) { | 115 NavigationEntryImpl* entry) { |
| 116 DCHECK(host && host->GetWidget()->GetView()); | 116 DCHECK(host && host->GetWidget()); |
| 117 DCHECK(entry); | 117 DCHECK(entry); |
| 118 host->GetWidget()->CopyFromBackingStore( | 118 if (auto* view = host->GetWidget()->GetView()) { |
|
alexmos
2017/02/28 19:44:09
Do you need this check? It looks like NavigationE
miu
2017/03/01 01:17:02
Done. Plus, things were simpler when I just dumped
alexmos
2017/03/01 01:30:05
Sounds good, but looks like there's another test i
miu
2017/03/01 21:57:18
Ah, yes. Fixed. I had to add back a "notification"
| |
| 119 gfx::Rect(), host->GetWidget()->GetView()->GetViewBounds().size(), | 119 // This screenshot is destined for the UI, so size the result to the actual |
| 120 base::Bind(&NavigationEntryScreenshotManager::OnScreenshotTaken, | 120 // on-screen size of the view (and not its device-rendering size). |
| 121 screenshot_factory_.GetWeakPtr(), entry->GetUniqueID()), | 121 const gfx::Size view_size_on_screen = view->GetViewBounds().size(); |
| 122 kAlpha_8_SkColorType); | 122 view->CopyFromSurface( |
| 123 gfx::Rect(), view_size_on_screen, | |
| 124 base::Bind(&NavigationEntryScreenshotManager::OnScreenshotTaken, | |
| 125 screenshot_factory_.GetWeakPtr(), entry->GetUniqueID()), | |
| 126 kAlpha_8_SkColorType); | |
| 127 } else { | |
| 128 OnScreenshotTaken(entry->GetUniqueID(), SkBitmap(), | |
| 129 READBACK_SURFACE_UNAVAILABLE); | |
| 130 } | |
| 123 } | 131 } |
| 124 | 132 |
| 125 void NavigationEntryScreenshotManager::SetMinScreenshotIntervalMS( | 133 void NavigationEntryScreenshotManager::SetMinScreenshotIntervalMS( |
| 126 int interval_ms) { | 134 int interval_ms) { |
| 127 DCHECK_GE(interval_ms, 0); | 135 DCHECK_GE(interval_ms, 0); |
| 128 min_screenshot_interval_ms_ = interval_ms; | 136 min_screenshot_interval_ms_ = interval_ms; |
| 129 } | 137 } |
| 130 | 138 |
| 131 void NavigationEntryScreenshotManager::OnScreenshotTaken( | 139 void NavigationEntryScreenshotManager::OnScreenshotTaken( |
| 132 int unique_id, | 140 int unique_id, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 NavigationEntryImpl* entry = owner_->GetEntryAtIndex(forward); | 251 NavigationEntryImpl* entry = owner_->GetEntryAtIndex(forward); |
| 244 if (ClearScreenshot(entry)) | 252 if (ClearScreenshot(entry)) |
| 245 --screenshot_count; | 253 --screenshot_count; |
| 246 ++forward; | 254 ++forward; |
| 247 } | 255 } |
| 248 CHECK_GE(screenshot_count, 0); | 256 CHECK_GE(screenshot_count, 0); |
| 249 CHECK_LE(screenshot_count, kMaxScreenshots); | 257 CHECK_LE(screenshot_count, kMaxScreenshots); |
| 250 } | 258 } |
| 251 | 259 |
| 252 } // namespace content | 260 } // namespace content |
| OLD | NEW |