OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "android_webview/browser/icon_helper.h" | 5 #include "android_webview/browser/icon_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 // We can protentially have multiple frames of the icon | 51 // We can protentially have multiple frames of the icon |
52 // in different sizes. We need more fine grain API spec | 52 // in different sizes. We need more fine grain API spec |
53 // to let clients pick out the frame they want. | 53 // to let clients pick out the frame they want. |
54 | 54 |
55 // TODO(acleung): Pick the best icon to return based on size. | 55 // TODO(acleung): Pick the best icon to return based on size. |
56 if (listener_) | 56 if (listener_) |
57 listener_->OnReceivedIcon(image_url, bitmaps[0]); | 57 listener_->OnReceivedIcon(image_url, bitmaps[0]); |
58 } | 58 } |
59 | 59 |
60 void IconHelper::DidUpdateFaviconURL(int32 page_id, | 60 void IconHelper::DidUpdateFaviconURL( |
61 const std::vector<content::FaviconURL>& candidates) { | 61 const std::vector<content::FaviconURL>& candidates) { |
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
63 for (std::vector<content::FaviconURL>::const_iterator i = candidates.begin(); | 63 for (std::vector<content::FaviconURL>::const_iterator i = candidates.begin(); |
64 i != candidates.end(); ++i) { | 64 i != candidates.end(); ++i) { |
65 if (!i->icon_url.is_valid()) | 65 if (!i->icon_url.is_valid()) |
66 continue; | 66 continue; |
67 | 67 |
68 switch(i->icon_type) { | 68 switch(i->icon_type) { |
69 case content::FaviconURL::FAVICON: | 69 case content::FaviconURL::FAVICON: |
70 if ((listener_ && !listener_->ShouldDownloadFavicon(i->icon_url)) || | 70 if ((listener_ && !listener_->ShouldDownloadFavicon(i->icon_url)) || |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 bool IconHelper::WasUnableToDownloadFavicon(const GURL& icon_url) const { | 110 bool IconHelper::WasUnableToDownloadFavicon(const GURL& icon_url) const { |
111 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); | 111 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); |
112 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); | 112 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); |
113 } | 113 } |
114 | 114 |
115 void IconHelper::ClearUnableToDownloadFavicons() { | 115 void IconHelper::ClearUnableToDownloadFavicons() { |
116 missing_favicon_urls_.clear(); | 116 missing_favicon_urls_.clear(); |
117 } | 117 } |
118 | 118 |
119 } // namespace android_webview | 119 } // namespace android_webview |
OLD | NEW |