| 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 "components/favicon/core/favicon_url.h" | 8 #include "components/favicon/core/favicon_url.h" |
| 9 #include "components/favicon/ios/favicon_url_util.h" | 9 #include "components/favicon/ios/favicon_url_util.h" |
| 10 #include "ios/web/public/browser_state.h" | 10 #include "ios/web/public/browser_state.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 web_state()->GetNavigationManager()->GetLastCommittedItem(); | 42 web_state()->GetNavigationManager()->GetLastCommittedItem(); |
| 43 return item ? item->GetFavicon().image : gfx::Image(); | 43 return item ? item->GetFavicon().image : gfx::Image(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool WebFaviconDriver::FaviconIsValid() const { | 46 bool WebFaviconDriver::FaviconIsValid() const { |
| 47 web::NavigationItem* item = | 47 web::NavigationItem* item = |
| 48 web_state()->GetNavigationManager()->GetLastCommittedItem(); | 48 web_state()->GetNavigationManager()->GetLastCommittedItem(); |
| 49 return item ? item->GetFavicon().valid : false; | 49 return item ? item->GetFavicon().valid : false; |
| 50 } | 50 } |
| 51 | 51 |
| 52 int WebFaviconDriver::StartDownload(const GURL& url, int max_image_size) { | 52 int WebFaviconDriver::DownloadImage(const GURL& url, |
| 53 int max_image_size, |
| 54 ImageDownloadCallback callback) { |
| 53 if (WasUnableToDownloadFavicon(url)) { | 55 if (WasUnableToDownloadFavicon(url)) { |
| 54 DVLOG(1) << "Skip Failed FavIcon: " << url; | 56 DVLOG(1) << "Skip Failed FavIcon: " << url; |
| 55 return 0; | 57 return 0; |
| 56 } | 58 } |
| 57 | 59 |
| 58 return web_state()->DownloadImage( | 60 return web_state()->DownloadImage(url, true, max_image_size, false, callback); |
| 59 url, true, max_image_size, false, | |
| 60 base::Bind(&FaviconDriverImpl::DidDownloadFavicon, | |
| 61 base::Unretained(this))); | |
| 62 } | 61 } |
| 63 | 62 |
| 64 bool WebFaviconDriver::IsOffTheRecord() { | 63 bool WebFaviconDriver::IsOffTheRecord() { |
| 65 DCHECK(web_state()); | 64 DCHECK(web_state()); |
| 66 return web_state()->GetBrowserState()->IsOffTheRecord(); | 65 return web_state()->GetBrowserState()->IsOffTheRecord(); |
| 67 } | 66 } |
| 68 | 67 |
| 69 GURL WebFaviconDriver::GetActiveURL() { | 68 GURL WebFaviconDriver::GetActiveURL() { |
| 70 web::NavigationItem* item = | 69 web::NavigationItem* item = |
| 71 web_state()->GetNavigationManager()->GetVisibleItem(); | 70 web_state()->GetNavigationManager()->GetVisibleItem(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 102 WebFaviconDriver::~WebFaviconDriver() { | 101 WebFaviconDriver::~WebFaviconDriver() { |
| 103 } | 102 } |
| 104 | 103 |
| 105 void WebFaviconDriver::FaviconUrlUpdated( | 104 void WebFaviconDriver::FaviconUrlUpdated( |
| 106 const std::vector<web::FaviconURL>& candidates) { | 105 const std::vector<web::FaviconURL>& candidates) { |
| 107 DCHECK(!candidates.empty()); | 106 DCHECK(!candidates.empty()); |
| 108 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates)); | 107 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates)); |
| 109 } | 108 } |
| 110 | 109 |
| 111 } // namespace favicon | 110 } // namespace favicon |
| OLD | NEW |