| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/favicon_downloader.h" | 5 #include "chrome/browser/extensions/favicon_downloader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/favicon/favicon_tab_helper.h" | 8 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/common/favicon_url.h" | 10 #include "content/public/common/favicon_url.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 got_favicon_urls_ = true; | 35 got_favicon_urls_ = true; |
| 36 FetchIcons(favicon_tab_helper_urls); | 36 FetchIcons(favicon_tab_helper_urls); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 int FaviconDownloader::DownloadImage(const GURL& url) { | 40 int FaviconDownloader::DownloadImage(const GURL& url) { |
| 41 return web_contents()->DownloadImage( | 41 return web_contents()->DownloadImage( |
| 42 url, | 42 url, |
| 43 true, // is_favicon | 43 true, // is_favicon |
| 44 0, // no max size | 44 0, // no max size |
| 45 blink::WebURLRequest::UseProtocolCachePolicy, |
| 45 base::Bind(&FaviconDownloader::DidDownloadFavicon, | 46 base::Bind(&FaviconDownloader::DidDownloadFavicon, |
| 46 weak_ptr_factory_.GetWeakPtr())); | 47 weak_ptr_factory_.GetWeakPtr())); |
| 47 } | 48 } |
| 48 | 49 |
| 49 std::vector<content::FaviconURL> | 50 std::vector<content::FaviconURL> |
| 50 FaviconDownloader::GetFaviconURLsFromWebContents() { | 51 FaviconDownloader::GetFaviconURLsFromWebContents() { |
| 51 FaviconTabHelper* favicon_tab_helper = | 52 FaviconTabHelper* favicon_tab_helper = |
| 52 web_contents() ? FaviconTabHelper::FromWebContents(web_contents()) : NULL; | 53 web_contents() ? FaviconTabHelper::FromWebContents(web_contents()) : NULL; |
| 53 // If favicon_urls() is empty, we are guaranteed that DidUpdateFaviconURLs has | 54 // If favicon_urls() is empty, we are guaranteed that DidUpdateFaviconURLs has |
| 54 // not yet been called for the current page's navigation. | 55 // not yet been called for the current page's navigation. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 void FaviconDownloader::DidUpdateFaviconURL( | 115 void FaviconDownloader::DidUpdateFaviconURL( |
| 115 const std::vector<content::FaviconURL>& candidates) { | 116 const std::vector<content::FaviconURL>& candidates) { |
| 116 // Only consider the first candidates we are given. This prevents pages that | 117 // Only consider the first candidates we are given. This prevents pages that |
| 117 // change their favicon from spamming us. | 118 // change their favicon from spamming us. |
| 118 if (got_favicon_urls_) | 119 if (got_favicon_urls_) |
| 119 return; | 120 return; |
| 120 | 121 |
| 121 got_favicon_urls_ = true; | 122 got_favicon_urls_ = true; |
| 122 FetchIcons(candidates); | 123 FetchIcons(candidates); |
| 123 } | 124 } |
| OLD | NEW |