| 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/ios/web_favicon_driver.h" | 5 #include "components/favicon/ios/web_favicon_driver.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
| 9 #include "components/favicon/core/favicon_url.h" | 9 #include "components/favicon/core/favicon_url.h" |
| 10 #include "components/favicon/ios/favicon_url_util.h" | 10 #include "components/favicon/ios/favicon_url_util.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 GURL WebFaviconDriver::GetActiveURL() { | 64 GURL WebFaviconDriver::GetActiveURL() { |
| 65 web::NavigationItem* item = | 65 web::NavigationItem* item = |
| 66 web_state()->GetNavigationManager()->GetVisibleItem(); | 66 web_state()->GetNavigationManager()->GetVisibleItem(); |
| 67 return item ? item->GetURL() : GURL(); | 67 return item ? item->GetURL() : GURL(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 int WebFaviconDriver::DownloadImage(const GURL& url, | 70 int WebFaviconDriver::DownloadImage(const GURL& url, |
| 71 int max_image_size, | 71 int max_image_size, |
| 72 ImageDownloadCallback callback) { | 72 ImageDownloadCallback callback) { |
| 73 if (WasUnableToDownloadFavicon(url)) { | |
| 74 DVLOG(1) << "Skip Failed FavIcon: " << url; | |
| 75 return 0; | |
| 76 } | |
| 77 | |
| 78 static int downloaded_image_count = 0; | 73 static int downloaded_image_count = 0; |
| 79 int local_download_id = ++downloaded_image_count; | 74 int local_download_id = ++downloaded_image_count; |
| 80 | 75 |
| 81 GURL local_url(url); | 76 GURL local_url(url); |
| 82 | 77 |
| 83 image_fetcher::IOSImageDataFetcherCallback local_callback = | 78 image_fetcher::IOSImageDataFetcherCallback local_callback = |
| 84 ^(NSData* data, const image_fetcher::RequestMetadata& metadata) { | 79 ^(NSData* data, const image_fetcher::RequestMetadata& metadata) { |
| 85 if (metadata.response_code == | 80 if (metadata.response_code == |
| 86 image_fetcher::ImageDataFetcher::RESPONSE_CODE_INVALID) | 81 image_fetcher::ImageDataFetcher::RESPONSE_CODE_INVALID) |
| 87 return; | 82 return; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 WebFaviconDriver::~WebFaviconDriver() { | 133 WebFaviconDriver::~WebFaviconDriver() { |
| 139 } | 134 } |
| 140 | 135 |
| 141 void WebFaviconDriver::FaviconUrlUpdated( | 136 void WebFaviconDriver::FaviconUrlUpdated( |
| 142 const std::vector<web::FaviconURL>& candidates) { | 137 const std::vector<web::FaviconURL>& candidates) { |
| 143 DCHECK(!candidates.empty()); | 138 DCHECK(!candidates.empty()); |
| 144 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates)); | 139 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates)); |
| 145 } | 140 } |
| 146 | 141 |
| 147 } // namespace favicon | 142 } // namespace favicon |
| OLD | NEW |