| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 261 } |
| 262 | 262 |
| 263 void FaviconTabHelper::SetActiveFaviconImage(const gfx::Image& image) { | 263 void FaviconTabHelper::SetActiveFaviconImage(const gfx::Image& image) { |
| 264 GetFaviconStatus().image = image; | 264 GetFaviconStatus().image = image; |
| 265 } | 265 } |
| 266 | 266 |
| 267 void FaviconTabHelper::OnFaviconAvailable(const gfx::Image& image, | 267 void FaviconTabHelper::OnFaviconAvailable(const gfx::Image& image, |
| 268 const GURL& icon_url, | 268 const GURL& icon_url, |
| 269 bool is_active_favicon) { | 269 bool is_active_favicon) { |
| 270 if (is_active_favicon) { | 270 if (is_active_favicon) { |
| 271 bool icon_url_changed = GetActiveFaviconURL() != icon_url; |
| 271 // No matter what happens, we need to mark the favicon as being set. | 272 // No matter what happens, we need to mark the favicon as being set. |
| 272 SetActiveFaviconValidity(true); | 273 SetActiveFaviconValidity(true); |
| 273 bool icon_url_changed = GetActiveFaviconURL() != icon_url; | |
| 274 SetActiveFaviconURL(icon_url); | 274 SetActiveFaviconURL(icon_url); |
| 275 | 275 |
| 276 if (image.IsEmpty()) | 276 if (image.IsEmpty()) |
| 277 return; | 277 return; |
| 278 | 278 |
| 279 SetActiveFaviconImage(image); | 279 SetActiveFaviconImage(image); |
| 280 content::NotificationService::current()->Notify( | 280 NotifyFaviconUpdated(icon_url_changed); |
| 281 chrome::NOTIFICATION_FAVICON_UPDATED, | |
| 282 content::Source<WebContents>(web_contents()), | |
| 283 content::Details<bool>(&icon_url_changed)); | |
| 284 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); | |
| 285 } | 281 } |
| 286 if (!image.IsEmpty()) { | 282 if (!image.IsEmpty()) { |
| 287 FOR_EACH_OBSERVER(favicon::FaviconDriverObserver, observer_list_, | 283 FOR_EACH_OBSERVER(favicon::FaviconDriverObserver, observer_list_, |
| 288 OnFaviconAvailable(image)); | 284 OnFaviconAvailable(image)); |
| 289 } | 285 } |
| 290 } | 286 } |
| 291 | 287 |
| 288 void FaviconTabHelper::NotifyFaviconUpdated(bool icon_url_changed) { |
| 289 FOR_EACH_OBSERVER(favicon::FaviconDriverObserver, observer_list_, |
| 290 OnFaviconUpdated(this, icon_url_changed)); |
| 291 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
| 292 } |
| 293 |
| 292 void FaviconTabHelper::DidDownloadFavicon( | 294 void FaviconTabHelper::DidDownloadFavicon( |
| 293 int id, | 295 int id, |
| 294 int http_status_code, | 296 int http_status_code, |
| 295 const GURL& image_url, | 297 const GURL& image_url, |
| 296 const std::vector<SkBitmap>& bitmaps, | 298 const std::vector<SkBitmap>& bitmaps, |
| 297 const std::vector<gfx::Size>& original_bitmap_sizes) { | 299 const std::vector<gfx::Size>& original_bitmap_sizes) { |
| 298 if (bitmaps.empty() && http_status_code == 404) { | 300 if (bitmaps.empty() && http_status_code == 404) { |
| 299 DVLOG(1) << "Failed to Download Favicon:" << image_url; | 301 DVLOG(1) << "Failed to Download Favicon:" << image_url; |
| 300 if (favicon_service_) | 302 if (favicon_service_) |
| 301 favicon_service_->UnableToDownloadFavicon(image_url); | 303 favicon_service_->UnableToDownloadFavicon(image_url); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 DCHECK(!candidates.empty()); | 360 DCHECK(!candidates.empty()); |
| 359 favicon_urls_ = candidates; | 361 favicon_urls_ = candidates; |
| 360 std::vector<favicon::FaviconURL> favicon_urls = | 362 std::vector<favicon::FaviconURL> favicon_urls = |
| 361 favicon::FaviconURLsFromContentFaviconURLs(candidates); | 363 favicon::FaviconURLsFromContentFaviconURLs(candidates); |
| 362 favicon_handler_->OnUpdateFaviconURL(favicon_urls); | 364 favicon_handler_->OnUpdateFaviconURL(favicon_urls); |
| 363 if (touch_icon_handler_.get()) | 365 if (touch_icon_handler_.get()) |
| 364 touch_icon_handler_->OnUpdateFaviconURL(favicon_urls); | 366 touch_icon_handler_->OnUpdateFaviconURL(favicon_urls); |
| 365 if (large_icon_handler_.get()) | 367 if (large_icon_handler_.get()) |
| 366 large_icon_handler_->OnUpdateFaviconURL(favicon_urls); | 368 large_icon_handler_->OnUpdateFaviconURL(favicon_urls); |
| 367 } | 369 } |
| OLD | NEW |