| 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 "base/bind.h" | 5 #include "base/bind.h" | 
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" | 
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" | 
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" | 
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" | 
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" | 
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 159 | 159 | 
| 160   // Gets the thumbnail for |url| from TopSites. | 160   // Gets the thumbnail for |url| from TopSites. | 
| 161   SkBitmap GetThumbnail(const GURL& url) { | 161   SkBitmap GetThumbnail(const GURL& url) { | 
| 162     scoped_refptr<base::RefCountedMemory> data; | 162     scoped_refptr<base::RefCountedMemory> data; | 
| 163     return top_sites()->GetPageThumbnail(url, &data) ? | 163     return top_sites()->GetPageThumbnail(url, &data) ? | 
| 164         ExtractThumbnail(*data.get()) : SkBitmap(); | 164         ExtractThumbnail(*data.get()) : SkBitmap(); | 
| 165   } | 165   } | 
| 166 | 166 | 
| 167   // Creates a bitmap of the specified color. Caller takes ownership. | 167   // Creates a bitmap of the specified color. Caller takes ownership. | 
| 168   gfx::Image CreateBitmap(SkColor color) { | 168   gfx::Image CreateBitmap(SkColor color) { | 
| 169     SkBitmap* thumbnail = new SkBitmap; | 169     SkBitmap thumbnail; | 
| 170     thumbnail->setConfig(SkBitmap::kARGB_8888_Config, 4, 4); | 170     thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4); | 
| 171     thumbnail->allocPixels(); | 171     thumbnail.allocPixels(); | 
| 172     thumbnail->eraseColor(color); | 172     thumbnail.eraseColor(color); | 
| 173     return gfx::Image(thumbnail);  // takes ownership. | 173     return gfx::Image(thumbnail);  // adds ref. | 
| 174   } | 174   } | 
| 175 | 175 | 
| 176   // Forces top sites to load top sites from history, then recreates top sites. | 176   // Forces top sites to load top sites from history, then recreates top sites. | 
| 177   // Recreating top sites makes sure the changes from history are saved and | 177   // Recreating top sites makes sure the changes from history are saved and | 
| 178   // loaded from the db. | 178   // loaded from the db. | 
| 179   void RefreshTopSitesAndRecreate() { | 179   void RefreshTopSitesAndRecreate() { | 
| 180     StartQueryForMostVisited(); | 180     StartQueryForMostVisited(); | 
| 181     WaitForHistory(); | 181     WaitForHistory(); | 
| 182     RecreateTopSitesAndBlock(); | 182     RecreateTopSitesAndBlock(); | 
| 183   } | 183   } | 
| (...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1238   ui_test_utils::WindowedNotificationObserver observer( | 1238   ui_test_utils::WindowedNotificationObserver observer( | 
| 1239       chrome::NOTIFICATION_TOP_SITES_LOADED, | 1239       chrome::NOTIFICATION_TOP_SITES_LOADED, | 
| 1240       content::Source<Profile>(profile())); | 1240       content::Source<Profile>(profile())); | 
| 1241   profile()->CreateTopSites(); | 1241   profile()->CreateTopSites(); | 
| 1242   profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)->UnloadBackend(); | 1242   profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)->UnloadBackend(); | 
| 1243   profile()->BlockUntilHistoryProcessesPendingRequests(); | 1243   profile()->BlockUntilHistoryProcessesPendingRequests(); | 
| 1244   observer.Wait(); | 1244   observer.Wait(); | 
| 1245 } | 1245 } | 
| 1246 | 1246 | 
| 1247 }  // namespace history | 1247 }  // namespace history | 
| OLD | NEW | 
|---|