| 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 "components/history/core/browser/history_backend.h" | 5 #include "components/history/core/browser/history_backend.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 const GURL& page_url, | 2078 const GURL& page_url, |
| 2079 favicon_base::IconType icon_type, | 2079 favicon_base::IconType icon_type, |
| 2080 const std::vector<favicon_base::FaviconID>& icon_ids) { | 2080 const std::vector<favicon_base::FaviconID>& icon_ids) { |
| 2081 if (!thumbnail_db_) | 2081 if (!thumbnail_db_) |
| 2082 return false; | 2082 return false; |
| 2083 | 2083 |
| 2084 // Find all the pages whose favicons we should set, we want to set it for | 2084 // Find all the pages whose favicons we should set, we want to set it for |
| 2085 // all the pages in the redirect chain if it redirected. | 2085 // all the pages in the redirect chain if it redirected. |
| 2086 RedirectList redirects; | 2086 RedirectList redirects; |
| 2087 GetCachedRecentRedirects(page_url, &redirects); | 2087 GetCachedRecentRedirects(page_url, &redirects); |
| 2088 bool mappings_changed = SetFaviconMappingsForPages(redirects, icon_type, |
| 2089 icon_ids); |
| 2090 if (page_url.has_ref()) { |
| 2091 // Refs often gets added by Javascript, but the redirect chain is keyed to |
| 2092 // the URL without a ref. |
| 2093 GURL::Replacements replacements; |
| 2094 replacements.ClearRef(); |
| 2095 GURL page_url_without_ref = page_url.ReplaceComponents(replacements); |
| 2096 GetCachedRecentRedirects(page_url_without_ref, &redirects); |
| 2097 mappings_changed |= SetFaviconMappingsForPages(redirects, icon_type, |
| 2098 icon_ids); |
| 2099 } |
| 2088 | 2100 |
| 2101 return mappings_changed; |
| 2102 } |
| 2103 |
| 2104 bool HistoryBackend::SetFaviconMappingsForPages( |
| 2105 const std::vector<GURL>& page_urls, |
| 2106 favicon_base::IconType icon_type, |
| 2107 const std::vector<favicon_base::FaviconID>& icon_ids) { |
| 2089 bool mappings_changed = false; | 2108 bool mappings_changed = false; |
| 2090 | 2109 for (auto i(page_urls.begin()); i != page_urls.end(); ++i) { |
| 2091 // Save page <-> favicon associations. | |
| 2092 for (RedirectList::const_iterator i(redirects.begin()); i != redirects.end(); | |
| 2093 ++i) { | |
| 2094 mappings_changed |= SetFaviconMappingsForPage(*i, icon_type, icon_ids); | 2110 mappings_changed |= SetFaviconMappingsForPage(*i, icon_type, icon_ids); |
| 2095 } | 2111 } |
| 2096 return mappings_changed; | 2112 return mappings_changed; |
| 2097 } | 2113 } |
| 2098 | 2114 |
| 2099 bool HistoryBackend::SetFaviconMappingsForPage( | 2115 bool HistoryBackend::SetFaviconMappingsForPage( |
| 2100 const GURL& page_url, | 2116 const GURL& page_url, |
| 2101 favicon_base::IconType icon_type, | 2117 favicon_base::IconType icon_type, |
| 2102 const std::vector<favicon_base::FaviconID>& icon_ids) { | 2118 const std::vector<favicon_base::FaviconID>& icon_ids) { |
| 2103 DCHECK_LE(icon_ids.size(), kMaxFaviconsPerPage); | 2119 DCHECK_LE(icon_ids.size(), kMaxFaviconsPerPage); |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2650 return true; | 2666 return true; |
| 2651 } | 2667 } |
| 2652 | 2668 |
| 2653 HistoryClient* HistoryBackend::GetHistoryClient() { | 2669 HistoryClient* HistoryBackend::GetHistoryClient() { |
| 2654 if (history_client_) | 2670 if (history_client_) |
| 2655 history_client_->BlockUntilBookmarksLoaded(); | 2671 history_client_->BlockUntilBookmarksLoaded(); |
| 2656 return history_client_; | 2672 return history_client_; |
| 2657 } | 2673 } |
| 2658 | 2674 |
| 2659 } // namespace history | 2675 } // namespace history |
| OLD | NEW |