OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/favicon/core/favicon_driver_impl.h" | 5 #include "components/favicon/core/favicon_driver_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 if (large_icon_handler_.get()) { | 91 if (large_icon_handler_.get()) { |
92 large_icon_handler_->OnDidDownloadFavicon(id, image_url, bitmaps, | 92 large_icon_handler_->OnDidDownloadFavicon(id, image_url, bitmaps, |
93 original_bitmap_sizes); | 93 original_bitmap_sizes); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 bool FaviconDriverImpl::IsBookmarked(const GURL& url) { | 97 bool FaviconDriverImpl::IsBookmarked(const GURL& url) { |
98 return bookmark_model_ && bookmark_model_->IsBookmarked(url); | 98 return bookmark_model_ && bookmark_model_->IsBookmarked(url); |
99 } | 99 } |
100 | 100 |
101 void FaviconDriverImpl::OnFaviconAvailable(const gfx::Image& image, | 101 void FaviconDriverImpl::OnFaviconAvailable(const GURL& page_url, |
102 const GURL& icon_url, | 102 const GURL& icon_url, |
| 103 const gfx::Image& image, |
103 bool is_active_favicon) { | 104 bool is_active_favicon) { |
| 105 // Check whether the active URL has changed since FetchFavicon() was called. |
| 106 // On iOS only, the active URL can change between calls to FetchFavicon(). |
| 107 // For instance, FetchFavicon() is not synchronously called when the active |
| 108 // URL changes as a result of CRWSessionController::goToEntry(). |
| 109 if (page_url != GetActiveURL()) |
| 110 return; |
| 111 |
104 if (is_active_favicon) { | 112 if (is_active_favicon) { |
105 bool icon_url_changed = GetActiveFaviconURL() != icon_url; | 113 bool icon_url_changed = GetActiveFaviconURL() != icon_url; |
106 // No matter what happens, we need to mark the favicon as being set. | 114 // No matter what happens, we need to mark the favicon as being set. |
107 SetActiveFaviconValidity(true); | 115 SetActiveFaviconValidity(true); |
108 SetActiveFaviconURL(icon_url); | 116 SetActiveFaviconURL(icon_url); |
109 | 117 |
110 if (image.IsEmpty()) | 118 if (image.IsEmpty()) |
111 return; | 119 return; |
112 | 120 |
113 SetActiveFaviconImage(image); | 121 SetActiveFaviconImage(image); |
(...skipping 20 matching lines...) Expand all Loading... |
134 void FaviconDriverImpl::SetFaviconOutOfDateForPage(const GURL& url, | 142 void FaviconDriverImpl::SetFaviconOutOfDateForPage(const GURL& url, |
135 bool force_reload) { | 143 bool force_reload) { |
136 if (favicon_service_) { | 144 if (favicon_service_) { |
137 favicon_service_->SetFaviconOutOfDateForPage(url); | 145 favicon_service_->SetFaviconOutOfDateForPage(url); |
138 if (force_reload) | 146 if (force_reload) |
139 favicon_service_->ClearUnableToDownloadFavicons(); | 147 favicon_service_->ClearUnableToDownloadFavicons(); |
140 } | 148 } |
141 } | 149 } |
142 | 150 |
143 void FaviconDriverImpl::OnUpdateFaviconURL( | 151 void FaviconDriverImpl::OnUpdateFaviconURL( |
| 152 const GURL& page_url, |
144 const std::vector<FaviconURL>& candidates) { | 153 const std::vector<FaviconURL>& candidates) { |
145 DCHECK(!candidates.empty()); | 154 DCHECK(!candidates.empty()); |
146 favicon_handler_->OnUpdateFaviconURL(candidates); | 155 favicon_handler_->OnUpdateFaviconURL(page_url, candidates); |
147 if (touch_icon_handler_.get()) | 156 if (touch_icon_handler_.get()) |
148 touch_icon_handler_->OnUpdateFaviconURL(candidates); | 157 touch_icon_handler_->OnUpdateFaviconURL(page_url, candidates); |
149 if (large_icon_handler_.get()) | 158 if (large_icon_handler_.get()) |
150 large_icon_handler_->OnUpdateFaviconURL(candidates); | 159 large_icon_handler_->OnUpdateFaviconURL(page_url, candidates); |
151 } | 160 } |
152 | 161 |
153 } // namespace favicon | 162 } // namespace favicon |
OLD | NEW |