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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h" | 10 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h" |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 if (web_contents->GetController().GetPendingEntry()) | 334 if (web_contents->GetController().GetPendingEntry()) |
335 return; | 335 return; |
336 const GURL& url = web_contents->GetURL(); | 336 const GURL& url = web_contents->GetURL(); |
337 Profile* profile = | 337 Profile* profile = |
338 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 338 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
339 | 339 |
340 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service = | 340 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service = |
341 ThumbnailServiceFactory::GetForProfile(profile); | 341 ThumbnailServiceFactory::GetForProfile(profile); |
342 | 342 |
343 // Skip if we don't need to update the thumbnail. | 343 // Skip if we don't need to update the thumbnail. |
344 if (thumbnail_service == NULL || | 344 if (thumbnail_service.get() == NULL || |
345 !thumbnail_service->ShouldAcquirePageThumbnail(url)) { | 345 !thumbnail_service->ShouldAcquirePageThumbnail(url)) { |
346 return; | 346 return; |
347 } | 347 } |
348 | 348 |
349 AsyncUpdateThumbnail(web_contents); | 349 AsyncUpdateThumbnail(web_contents); |
350 } | 350 } |
351 | 351 |
352 void ThumbnailTabHelper::UpdateThumbnail( | 352 void ThumbnailTabHelper::UpdateThumbnail( |
353 WebContents* web_contents, const SkBitmap& thumbnail, | 353 WebContents* web_contents, const SkBitmap& thumbnail, |
354 const ClipResult& clip_result) { | 354 const ClipResult& clip_result) { |
355 Profile* profile = | 355 Profile* profile = |
356 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 356 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
357 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service = | 357 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service = |
358 ThumbnailServiceFactory::GetForProfile(profile); | 358 ThumbnailServiceFactory::GetForProfile(profile); |
359 | 359 |
360 if (!thumbnail_service) | 360 if (!thumbnail_service.get()) |
361 return; | 361 return; |
362 | 362 |
363 // Compute the thumbnail score. | 363 // Compute the thumbnail score. |
364 ThumbnailScore score; | 364 ThumbnailScore score; |
365 score.at_top = | 365 score.at_top = |
366 (web_contents->GetRenderViewHost()->GetLastScrollOffset().y() == 0); | 366 (web_contents->GetRenderViewHost()->GetLastScrollOffset().y() == 0); |
367 score.boring_score = ThumbnailTabHelper::CalculateBoringScore(thumbnail); | 367 score.boring_score = ThumbnailTabHelper::CalculateBoringScore(thumbnail); |
368 score.good_clipping = | 368 score.good_clipping = |
369 (clip_result == ThumbnailTabHelper::kWiderThanTall || | 369 (clip_result == ThumbnailTabHelper::kWiderThanTall || |
370 clip_result == ThumbnailTabHelper::kTallerThanWide || | 370 clip_result == ThumbnailTabHelper::kTallerThanWide || |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 void ThumbnailTabHelper::DidStartLoading( | 457 void ThumbnailTabHelper::DidStartLoading( |
458 content::RenderViewHost* render_view_host) { | 458 content::RenderViewHost* render_view_host) { |
459 load_interrupted_ = false; | 459 load_interrupted_ = false; |
460 } | 460 } |
461 | 461 |
462 void ThumbnailTabHelper::StopNavigation() { | 462 void ThumbnailTabHelper::StopNavigation() { |
463 // This function gets called when the page loading is interrupted by the | 463 // This function gets called when the page loading is interrupted by the |
464 // stop button. | 464 // stop button. |
465 load_interrupted_ = true; | 465 load_interrupted_ = true; |
466 } | 466 } |
OLD | NEW |