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/tab_contents/thumbnail_generator.h" | 5 #include "chrome/browser/tab_contents/thumbnail_generator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 ThumbnailScore score; | 464 ThumbnailScore score; |
465 score.at_top = | 465 score.at_top = |
466 (web_contents->GetRenderViewHost()->GetLastScrollOffset().y() == 0); | 466 (web_contents->GetRenderViewHost()->GetLastScrollOffset().y() == 0); |
467 score.boring_score = ThumbnailGenerator::CalculateBoringScore(thumbnail); | 467 score.boring_score = ThumbnailGenerator::CalculateBoringScore(thumbnail); |
468 score.good_clipping = | 468 score.good_clipping = |
469 (clip_result == ThumbnailGenerator::kWiderThanTall || | 469 (clip_result == ThumbnailGenerator::kWiderThanTall || |
470 clip_result == ThumbnailGenerator::kTallerThanWide || | 470 clip_result == ThumbnailGenerator::kTallerThanWide || |
471 clip_result == ThumbnailGenerator::kNotClipped); | 471 clip_result == ThumbnailGenerator::kNotClipped); |
472 score.load_completed = (!load_interrupted_ && !web_contents->IsLoading()); | 472 score.load_completed = (!load_interrupted_ && !web_contents->IsLoading()); |
473 | 473 |
474 gfx::Image image(new SkBitmap(thumbnail)); | 474 gfx::Image image(thumbnail); |
475 const GURL& url = web_contents->GetURL(); | 475 const GURL& url = web_contents->GetURL(); |
476 top_sites->SetPageThumbnail(url, &image, score); | 476 top_sites->SetPageThumbnail(url, &image, score); |
477 VLOG(1) << "Thumbnail taken for " << url << ": " << score.ToString(); | 477 VLOG(1) << "Thumbnail taken for " << url << ": " << score.ToString(); |
478 } | 478 } |
479 | 479 |
480 void ThumbnailGenerator::AsyncUpdateThumbnail( | 480 void ThumbnailGenerator::AsyncUpdateThumbnail( |
481 WebContents* web_contents) { | 481 WebContents* web_contents) { |
482 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 482 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
483 RenderWidgetHost* render_widget_host = web_contents->GetRenderViewHost(); | 483 RenderWidgetHost* render_widget_host = web_contents->GetRenderViewHost(); |
484 content::RenderWidgetHostView* view = render_widget_host->GetView(); | 484 content::RenderWidgetHostView* view = render_widget_host->GetView(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 | 553 |
554 void ThumbnailGenerator::DidStartLoading() { | 554 void ThumbnailGenerator::DidStartLoading() { |
555 load_interrupted_ = false; | 555 load_interrupted_ = false; |
556 } | 556 } |
557 | 557 |
558 void ThumbnailGenerator::StopNavigation() { | 558 void ThumbnailGenerator::StopNavigation() { |
559 // This function gets called when the page loading is interrupted by the | 559 // This function gets called when the page loading is interrupted by the |
560 // stop button. | 560 // stop button. |
561 load_interrupted_ = true; | 561 load_interrupted_ = true; |
562 } | 562 } |
OLD | NEW |