| 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/history/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2233 // TODO(pkotwicz): Select bitmap results from multiple favicons once | 2233 // TODO(pkotwicz): Select bitmap results from multiple favicons once |
| 2234 // content::FaviconStatus supports multiple icon URLs. | 2234 // content::FaviconStatus supports multiple icon URLs. |
| 2235 FaviconID best_favicon_id = 0; | 2235 FaviconID best_favicon_id = 0; |
| 2236 std::vector<FaviconBitmapID> best_bitmap_ids; | 2236 std::vector<FaviconBitmapID> best_bitmap_ids; |
| 2237 float highest_score = kSelectFaviconFramesInvalidScore; | 2237 float highest_score = kSelectFaviconFramesInvalidScore; |
| 2238 for (size_t i = 0; i < candidate_favicon_ids.size(); ++i) { | 2238 for (size_t i = 0; i < candidate_favicon_ids.size(); ++i) { |
| 2239 std::vector<FaviconBitmapIDSize> bitmap_id_sizes; | 2239 std::vector<FaviconBitmapIDSize> bitmap_id_sizes; |
| 2240 thumbnail_db_->GetFaviconBitmapIDSizes(candidate_favicon_ids[i], | 2240 thumbnail_db_->GetFaviconBitmapIDSizes(candidate_favicon_ids[i], |
| 2241 &bitmap_id_sizes); | 2241 &bitmap_id_sizes); |
| 2242 | 2242 |
| 2243 std::vector<FaviconBitmapID> candidate_bitmap_ids; | 2243 // Build vector of gfx::Size from |bitmap_id_sizes|. |
| 2244 std::vector<gfx::Size> sizes; |
| 2245 for (size_t j = 0; j < bitmap_id_sizes.size(); ++j) |
| 2246 sizes.push_back(bitmap_id_sizes[j].pixel_size); |
| 2247 |
| 2248 std::vector<size_t> candidate_bitmap_indices; |
| 2244 float score = 0; | 2249 float score = 0; |
| 2245 SelectFaviconBitmapIDs(bitmap_id_sizes, | 2250 SelectFaviconFrameIndices(sizes, |
| 2246 desired_scale_factors, | 2251 desired_scale_factors, |
| 2247 desired_size_in_dip, | 2252 desired_size_in_dip, |
| 2248 &candidate_bitmap_ids, | 2253 &candidate_bitmap_indices, |
| 2249 &score); | 2254 &score); |
| 2250 if (score > highest_score) { | 2255 if (score > highest_score) { |
| 2256 highest_score = score; |
| 2251 best_favicon_id = candidate_favicon_ids[i], | 2257 best_favicon_id = candidate_favicon_ids[i], |
| 2252 best_bitmap_ids.swap(candidate_bitmap_ids); | 2258 best_bitmap_ids.clear(); |
| 2253 highest_score = score; | 2259 for (size_t j = 0; j < candidate_bitmap_indices.size(); ++j) { |
| 2260 size_t candidate_index = candidate_bitmap_indices[j]; |
| 2261 best_bitmap_ids.push_back( |
| 2262 bitmap_id_sizes[candidate_index].bitmap_id); |
| 2263 } |
| 2254 } | 2264 } |
| 2255 } | 2265 } |
| 2256 | 2266 |
| 2257 // Construct FaviconBitmapResults from |best_favicon_id| and | 2267 // Construct FaviconBitmapResults from |best_favicon_id| and |
| 2258 // |best_bitmap_ids|. | 2268 // |best_bitmap_ids|. |
| 2259 GURL icon_url; | 2269 GURL icon_url; |
| 2260 IconType icon_type; | 2270 IconType icon_type; |
| 2261 if (!thumbnail_db_->GetFaviconHeader(best_favicon_id, &icon_url, | 2271 if (!thumbnail_db_->GetFaviconHeader(best_favicon_id, &icon_url, |
| 2262 &icon_type, NULL)) { | 2272 &icon_type, NULL)) { |
| 2263 return false; | 2273 return false; |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2783 info.url_id = visit.url_id; | 2793 info.url_id = visit.url_id; |
| 2784 info.time = visit.visit_time; | 2794 info.time = visit.visit_time; |
| 2785 info.transition = visit.transition; | 2795 info.transition = visit.transition; |
| 2786 // If we don't have a delegate yet during setup or shutdown, we will drop | 2796 // If we don't have a delegate yet during setup or shutdown, we will drop |
| 2787 // these notifications. | 2797 // these notifications. |
| 2788 if (delegate_.get()) | 2798 if (delegate_.get()) |
| 2789 delegate_->NotifyVisitDBObserversOnAddVisit(info); | 2799 delegate_->NotifyVisitDBObserversOnAddVisit(info); |
| 2790 } | 2800 } |
| 2791 | 2801 |
| 2792 } // namespace history | 2802 } // namespace history |
| OLD | NEW |