| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 NOTIMPLEMENTED(); | 225 NOTIMPLEMENTED(); |
| 226 return; | 226 return; |
| 227 #else | 227 #else |
| 228 | 228 |
| 229 #if defined(OS_WIN) | 229 #if defined(OS_WIN) |
| 230 // Duplicate the handle to the DIB here because the renderer process does not | 230 // Duplicate the handle to the DIB here because the renderer process does not |
| 231 // have permission. The duplicated handle is owned by the renderer process, | 231 // have permission. The duplicated handle is owned by the renderer process, |
| 232 // which is responsible for closing it. | 232 // which is responsible for closing it. |
| 233 TransportDIB::Handle renderer_dib_handle; | 233 TransportDIB::Handle renderer_dib_handle; |
| 234 DuplicateHandle(GetCurrentProcess(), thumbnail_dib->handle(), | 234 DuplicateHandle(GetCurrentProcess(), thumbnail_dib->handle(), |
| 235 renderer->process()->GetHandle(), &renderer_dib_handle, | 235 renderer->GetProcess()->GetHandle(), &renderer_dib_handle, |
| 236 STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ | FILE_MAP_WRITE, | 236 STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ | FILE_MAP_WRITE, |
| 237 FALSE, 0); | 237 FALSE, 0); |
| 238 if (!renderer_dib_handle) { | 238 if (!renderer_dib_handle) { |
| 239 LOG(WARNING) << "Could not duplicate dib handle for renderer"; | 239 LOG(WARNING) << "Could not duplicate dib handle for renderer"; |
| 240 return; | 240 return; |
| 241 } | 241 } |
| 242 #else | 242 #else |
| 243 TransportDIB::Handle renderer_dib_handle = thumbnail_dib->handle(); | 243 TransportDIB::Handle renderer_dib_handle = thumbnail_dib->handle(); |
| 244 #endif | 244 #endif |
| 245 | 245 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 460 |
| 461 Profile* profile = | 461 Profile* profile = |
| 462 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 462 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 463 history::TopSites* top_sites = profile->GetTopSites(); | 463 history::TopSites* top_sites = profile->GetTopSites(); |
| 464 if (!top_sites) | 464 if (!top_sites) |
| 465 return; | 465 return; |
| 466 | 466 |
| 467 // Compute the thumbnail score. | 467 // Compute the thumbnail score. |
| 468 ThumbnailScore score; | 468 ThumbnailScore score; |
| 469 score.at_top = | 469 score.at_top = |
| 470 (web_contents->GetRenderViewHost()->last_scroll_offset().y() == 0); | 470 (web_contents->GetRenderViewHost()->GetLastScrollOffset().y() == 0); |
| 471 score.boring_score = ThumbnailGenerator::CalculateBoringScore(&thumbnail); | 471 score.boring_score = ThumbnailGenerator::CalculateBoringScore(&thumbnail); |
| 472 score.good_clipping = | 472 score.good_clipping = |
| 473 (clip_result == ThumbnailGenerator::kTallerThanWide || | 473 (clip_result == ThumbnailGenerator::kTallerThanWide || |
| 474 clip_result == ThumbnailGenerator::kNotClipped); | 474 clip_result == ThumbnailGenerator::kNotClipped); |
| 475 score.load_completed = (!load_interrupted_ && !web_contents->IsLoading()); | 475 score.load_completed = (!load_interrupted_ && !web_contents->IsLoading()); |
| 476 | 476 |
| 477 gfx::Image image(new SkBitmap(thumbnail)); | 477 gfx::Image image(new SkBitmap(thumbnail)); |
| 478 const GURL& url = web_contents->GetURL(); | 478 const GURL& url = web_contents->GetURL(); |
| 479 top_sites->SetPageThumbnail(url, &image, score); | 479 top_sites->SetPageThumbnail(url, &image, score); |
| 480 VLOG(1) << "Thumbnail taken for " << url << ": " << score.ToString(); | 480 VLOG(1) << "Thumbnail taken for " << url << ": " << score.ToString(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 511 | 511 |
| 512 void ThumbnailGenerator::DidStartLoading() { | 512 void ThumbnailGenerator::DidStartLoading() { |
| 513 load_interrupted_ = false; | 513 load_interrupted_ = false; |
| 514 } | 514 } |
| 515 | 515 |
| 516 void ThumbnailGenerator::StopNavigation() { | 516 void ThumbnailGenerator::StopNavigation() { |
| 517 // This function gets called when the page loading is interrupted by the | 517 // This function gets called when the page loading is interrupted by the |
| 518 // stop button. | 518 // stop button. |
| 519 load_interrupted_ = true; | 519 load_interrupted_ = true; |
| 520 } | 520 } |
| OLD | NEW |