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/favicon/favicon_tab_helper.h" | 5 #include "chrome/browser/favicon/favicon_tab_helper.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/favicon/favicon_service_factory.h" | 10 #include "chrome/browser/favicon/favicon_service_factory.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 | 250 |
251 void FaviconTabHelper::SetActiveFaviconImage(const gfx::Image& image) { | 251 void FaviconTabHelper::SetActiveFaviconImage(const gfx::Image& image) { |
252 GetFaviconStatus().image = image; | 252 GetFaviconStatus().image = image; |
253 } | 253 } |
254 | 254 |
255 void FaviconTabHelper::OnFaviconAvailable(const gfx::Image& image, | 255 void FaviconTabHelper::OnFaviconAvailable(const gfx::Image& image, |
256 const GURL& icon_url, | 256 const GURL& icon_url, |
257 bool is_active_favicon) { | 257 bool is_active_favicon) { |
258 if (is_active_favicon) { | 258 if (is_active_favicon) { |
| 259 bool icon_url_changed = GetActiveFaviconURL() != icon_url; |
259 // No matter what happens, we need to mark the favicon as being set. | 260 // No matter what happens, we need to mark the favicon as being set. |
260 SetActiveFaviconValidity(true); | 261 SetActiveFaviconValidity(true); |
261 bool icon_url_changed = GetActiveFaviconURL() != icon_url; | |
262 SetActiveFaviconURL(icon_url); | 262 SetActiveFaviconURL(icon_url); |
263 | 263 |
264 if (image.IsEmpty()) | 264 if (image.IsEmpty()) |
265 return; | 265 return; |
266 | 266 |
267 SetActiveFaviconImage(image); | 267 SetActiveFaviconImage(image); |
268 content::NotificationService::current()->Notify( | 268 NotifyFaviconUpdated(icon_url_changed); |
269 chrome::NOTIFICATION_FAVICON_UPDATED, | |
270 content::Source<WebContents>(web_contents()), | |
271 content::Details<bool>(&icon_url_changed)); | |
272 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); | |
273 } | 269 } |
274 if (!image.IsEmpty()) { | 270 if (!image.IsEmpty()) { |
275 FOR_EACH_OBSERVER(favicon::FaviconDriverObserver, observer_list_, | 271 FOR_EACH_OBSERVER(favicon::FaviconDriverObserver, observer_list_, |
276 OnFaviconAvailable(image)); | 272 OnFaviconAvailable(image)); |
277 } | 273 } |
278 } | 274 } |
279 | 275 |
| 276 void FaviconTabHelper::NotifyFaviconUpdated(bool icon_url_changed) { |
| 277 FOR_EACH_OBSERVER(favicon::FaviconDriverObserver, observer_list_, |
| 278 OnFaviconUpdated(this, icon_url_changed)); |
| 279 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
| 280 } |
| 281 |
280 void FaviconTabHelper::DidDownloadFavicon( | 282 void FaviconTabHelper::DidDownloadFavicon( |
281 int id, | 283 int id, |
282 int http_status_code, | 284 int http_status_code, |
283 const GURL& image_url, | 285 const GURL& image_url, |
284 const std::vector<SkBitmap>& bitmaps, | 286 const std::vector<SkBitmap>& bitmaps, |
285 const std::vector<gfx::Size>& original_bitmap_sizes) { | 287 const std::vector<gfx::Size>& original_bitmap_sizes) { |
286 if (bitmaps.empty() && http_status_code == 404) { | 288 if (bitmaps.empty() && http_status_code == 404) { |
287 DVLOG(1) << "Failed to Download Favicon:" << image_url; | 289 DVLOG(1) << "Failed to Download Favicon:" << image_url; |
288 if (favicon_service_) | 290 if (favicon_service_) |
289 favicon_service_->UnableToDownloadFavicon(image_url); | 291 favicon_service_->UnableToDownloadFavicon(image_url); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 DCHECK(!candidates.empty()); | 348 DCHECK(!candidates.empty()); |
347 favicon_urls_ = candidates; | 349 favicon_urls_ = candidates; |
348 std::vector<favicon::FaviconURL> favicon_urls = | 350 std::vector<favicon::FaviconURL> favicon_urls = |
349 favicon::FaviconURLsFromContentFaviconURLs(candidates); | 351 favicon::FaviconURLsFromContentFaviconURLs(candidates); |
350 favicon_handler_->OnUpdateFaviconURL(favicon_urls); | 352 favicon_handler_->OnUpdateFaviconURL(favicon_urls); |
351 if (touch_icon_handler_.get()) | 353 if (touch_icon_handler_.get()) |
352 touch_icon_handler_->OnUpdateFaviconURL(favicon_urls); | 354 touch_icon_handler_->OnUpdateFaviconURL(favicon_urls); |
353 if (large_icon_handler_.get()) | 355 if (large_icon_handler_.get()) |
354 large_icon_handler_->OnUpdateFaviconURL(favicon_urls); | 356 large_icon_handler_->OnUpdateFaviconURL(favicon_urls); |
355 } | 357 } |
OLD | NEW |