| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 static int downloaded_image_count = 0; | 73 static int downloaded_image_count = 0; |
| 74 int local_download_id = ++downloaded_image_count; | 74 int local_download_id = ++downloaded_image_count; |
| 75 | 75 |
| 76 GURL local_url(url); | 76 GURL local_url(url); |
| 77 | 77 |
| 78 image_fetcher::IOSImageDataFetcherCallback local_callback = | 78 image_fetcher::IOSImageDataFetcherCallback local_callback = |
| 79 ^(NSData* data, const image_fetcher::RequestMetadata& metadata) { | 79 ^(NSData* data, const image_fetcher::RequestMetadata& metadata) { |
| 80 if (metadata.response_code == | 80 if (metadata.http_response_code == |
| 81 image_fetcher::ImageDataFetcher::RESPONSE_CODE_INVALID) | 81 image_fetcher::RequestMetadata::RESPONSE_CODE_INVALID) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 std::vector<SkBitmap> frames; | 84 std::vector<SkBitmap> frames; |
| 85 std::vector<gfx::Size> sizes; | 85 std::vector<gfx::Size> sizes; |
| 86 if (data) { | 86 if (data) { |
| 87 frames = skia::ImageDataToSkBitmaps(data); | 87 frames = skia::ImageDataToSkBitmaps(data); |
| 88 for (const auto& frame : frames) { | 88 for (const auto& frame : frames) { |
| 89 sizes.push_back(gfx::Size(frame.width(), frame.height())); | 89 sizes.push_back(gfx::Size(frame.width(), frame.height())); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 callback.Run(local_download_id, metadata.response_code, local_url, | 92 callback.Run(local_download_id, metadata.http_response_code, local_url, |
| 93 frames, sizes); | 93 frames, sizes); |
| 94 }; | 94 }; |
| 95 image_fetcher_.FetchImageDataWebpDecoded(url, local_callback); | 95 image_fetcher_.FetchImageDataWebpDecoded(url, local_callback); |
| 96 | 96 |
| 97 return downloaded_image_count; | 97 return downloaded_image_count; |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool WebFaviconDriver::IsOffTheRecord() { | 100 bool WebFaviconDriver::IsOffTheRecord() { |
| 101 DCHECK(web_state()); | 101 DCHECK(web_state()); |
| 102 return web_state()->GetBrowserState()->IsOffTheRecord(); | 102 return web_state()->GetBrowserState()->IsOffTheRecord(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 133 WebFaviconDriver::~WebFaviconDriver() { | 133 WebFaviconDriver::~WebFaviconDriver() { |
| 134 } | 134 } |
| 135 | 135 |
| 136 void WebFaviconDriver::FaviconUrlUpdated( | 136 void WebFaviconDriver::FaviconUrlUpdated( |
| 137 const std::vector<web::FaviconURL>& candidates) { | 137 const std::vector<web::FaviconURL>& candidates) { |
| 138 DCHECK(!candidates.empty()); | 138 DCHECK(!candidates.empty()); |
| 139 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates)); | 139 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace favicon | 142 } // namespace favicon |
| OLD | NEW |