Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: chrome/browser/history/top_sites.cc

Issue 8631002: [ntp4] Use highest quality jpeg compression for thumbnail images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/history/top_sites.h" 5 #include "chrome/browser/history/top_sites.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // temp_images_ for details. 52 // temp_images_ for details.
53 static const size_t kMaxTempTopImages = 8; 53 static const size_t kMaxTempTopImages = 8;
54 54
55 static const int kDaysOfHistory = 90; 55 static const int kDaysOfHistory = 90;
56 // Time from startup to first HistoryService query. 56 // Time from startup to first HistoryService query.
57 static const int64 kUpdateIntervalSecs = 15; 57 static const int64 kUpdateIntervalSecs = 15;
58 // Intervals between requests to HistoryService. 58 // Intervals between requests to HistoryService.
59 static const int64 kMinUpdateIntervalMinutes = 1; 59 static const int64 kMinUpdateIntervalMinutes = 1;
60 static const int64 kMaxUpdateIntervalMinutes = 60; 60 static const int64 kMaxUpdateIntervalMinutes = 60;
61 61
62 // Use 100 quality (highest quality) because we're very sensitive to
63 // artifacts for these small sized, highly detailed images.
64 static const int kTopSitesImageQuality = 100;
65
62 const TopSites::PrepopulatedPage kPrepopulatedPages[] = { 66 const TopSites::PrepopulatedPage kPrepopulatedPages[] = {
63 { IDS_CHROME_WELCOME_URL, IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE, 67 { IDS_CHROME_WELCOME_URL, IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE,
64 IDR_PRODUCT_LOGO_16, IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL, 68 IDR_PRODUCT_LOGO_16, IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL,
65 SkColorSetRGB(0, 147, 60) }, 69 SkColorSetRGB(0, 147, 60) },
66 { IDS_WEBSTORE_URL, IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE, 70 { IDS_WEBSTORE_URL, IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE,
67 IDR_WEBSTORE_ICON_16, IDR_NEWTAB_WEBSTORE_THUMBNAIL, 71 IDR_WEBSTORE_ICON_16, IDR_NEWTAB_WEBSTORE_THUMBNAIL,
68 SkColorSetRGB(63, 132, 197) } 72 SkColorSetRGB(63, 132, 197) }
69 }; 73 };
70 74
71 namespace { 75 namespace {
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 return true; 616 return true;
613 } 617 }
614 618
615 // static 619 // static
616 bool TopSites::EncodeBitmap(gfx::Image* bitmap, 620 bool TopSites::EncodeBitmap(gfx::Image* bitmap,
617 scoped_refptr<RefCountedBytes>* bytes) { 621 scoped_refptr<RefCountedBytes>* bytes) {
618 if (!bitmap) 622 if (!bitmap)
619 return false; 623 return false;
620 *bytes = new RefCountedBytes(); 624 *bytes = new RefCountedBytes();
621 std::vector<unsigned char> data; 625 std::vector<unsigned char> data;
622 if (!gfx::JPEGEncodedDataFromImage(*bitmap, &data)) 626 if (!gfx::JPEGEncodedDataFromImage(*bitmap, kTopSitesImageQuality, &data))
623 return false; 627 return false;
624 628
625 // As we're going to cache this data, make sure the vector is only as big as 629 // As we're going to cache this data, make sure the vector is only as big as
626 // it needs to be, as JPEGCodec::Encode() over-allocates data.capacity(). 630 // it needs to be, as JPEGCodec::Encode() over-allocates data.capacity().
627 // (In a C++0x future, we can just call shrink_to_fit() in Encode()) 631 // (In a C++0x future, we can just call shrink_to_fit() in Encode())
628 (*bytes)->data() = data; 632 (*bytes)->data() = data;
629 return true; 633 return true;
630 } 634 }
631 635
632 void TopSites::RemoveTemporaryThumbnailByURL(const GURL& url) { 636 void TopSites::RemoveTemporaryThumbnailByURL(const GURL& url) {
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 SetTopSites(pages); 1036 SetTopSites(pages);
1033 1037
1034 // Used only in testing. 1038 // Used only in testing.
1035 content::NotificationService::current()->Notify( 1039 content::NotificationService::current()->Notify(
1036 chrome::NOTIFICATION_TOP_SITES_UPDATED, 1040 chrome::NOTIFICATION_TOP_SITES_UPDATED,
1037 content::Source<TopSites>(this), 1041 content::Source<TopSites>(this),
1038 content::Details<CancelableRequestProvider::Handle>(&handle)); 1042 content::Details<CancelableRequestProvider::Handle>(&handle));
1039 } 1043 }
1040 1044
1041 } // namespace history 1045 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698