| 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 "chrome/browser/thumbnails/thumbnail_tab_helper.h" | 5 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/thumbnails/thumbnail_service.h" | 9 #include "chrome/browser/thumbnails/thumbnail_service.h" |
| 10 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" | 10 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 using thumbnails::ThumbnailingContext; | 51 using thumbnails::ThumbnailingContext; |
| 52 using thumbnails::ThumbnailingAlgorithm; | 52 using thumbnails::ThumbnailingAlgorithm; |
| 53 | 53 |
| 54 namespace { | 54 namespace { |
| 55 | 55 |
| 56 // Feed the constructed thumbnail to the thumbnail service. | 56 // Feed the constructed thumbnail to the thumbnail service. |
| 57 void UpdateThumbnail(const ThumbnailingContext& context, | 57 void UpdateThumbnail(const ThumbnailingContext& context, |
| 58 const SkBitmap& thumbnail) { | 58 const SkBitmap& thumbnail) { |
| 59 gfx::Image image = gfx::Image::CreateFrom1xBitmap(thumbnail); | 59 gfx::Image image = gfx::Image::CreateFrom1xBitmap(thumbnail); |
| 60 context.service->SetPageThumbnail(context, image); | 60 context.service->SetPageThumbnail(context, image); |
| 61 VLOG(1) << "Thumbnail taken for " << context.url << ": " | 61 DVLOG(1) << "Thumbnail taken for " << context.url << ": " |
| 62 << context.score.ToString(); | 62 << context.score.ToString(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void ProcessCapturedBitmap(scoped_refptr<ThumbnailingContext> context, | 65 void ProcessCapturedBitmap(scoped_refptr<ThumbnailingContext> context, |
| 66 scoped_refptr<ThumbnailingAlgorithm> algorithm, | 66 scoped_refptr<ThumbnailingAlgorithm> algorithm, |
| 67 bool succeeded, | 67 bool succeeded, |
| 68 const SkBitmap& bitmap) { | 68 const SkBitmap& bitmap) { |
| 69 if (!succeeded) | 69 if (!succeeded) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 // On success, we must be on the UI thread (on failure because of shutdown we | 72 // On success, we must be on the UI thread (on failure because of shutdown we |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, | 220 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, |
| 221 content::Source<RenderWidgetHost>(renderer)); | 221 content::Source<RenderWidgetHost>(renderer)); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 void ThumbnailTabHelper::WidgetHidden(RenderWidgetHost* widget) { | 225 void ThumbnailTabHelper::WidgetHidden(RenderWidgetHost* widget) { |
| 226 if (!enabled_) | 226 if (!enabled_) |
| 227 return; | 227 return; |
| 228 UpdateThumbnailIfNecessary(web_contents()); | 228 UpdateThumbnailIfNecessary(web_contents()); |
| 229 } | 229 } |
| OLD | NEW |