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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 void IconHelper::DidUpdateFaviconURL( | 60 void IconHelper::DidUpdateFaviconURL( |
61 const std::vector<content::FaviconURL>& candidates) { | 61 const std::vector<content::FaviconURL>& candidates) { |
62 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 62 DCHECK_CURRENTLY_ON(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::IconType::kFavicon: |
70 if ((listener_ && !listener_->ShouldDownloadFavicon(i->icon_url)) || | 70 if ((listener_ && !listener_->ShouldDownloadFavicon(i->icon_url)) || |
71 WasUnableToDownloadFavicon(i->icon_url)) { | 71 WasUnableToDownloadFavicon(i->icon_url)) { |
72 break; | 72 break; |
73 } | 73 } |
74 web_contents()->DownloadImage(i->icon_url, | 74 web_contents()->DownloadImage(i->icon_url, |
75 true, // Is a favicon | 75 true, // Is a favicon |
76 0, // No maximum size | 76 0, // No maximum size |
77 false, // Normal cache policy | 77 false, // Normal cache policy |
78 base::Bind( | 78 base::Bind( |
79 &IconHelper::DownloadFaviconCallback, base::Unretained(this))); | 79 &IconHelper::DownloadFaviconCallback, base::Unretained(this))); |
80 break; | 80 break; |
81 case content::FaviconURL::TOUCH_ICON: | 81 case content::FaviconURL::IconType::kTouchIcon: |
82 if (listener_) | 82 if (listener_) |
83 listener_->OnReceivedTouchIconUrl(i->icon_url.spec(), false); | 83 listener_->OnReceivedTouchIconUrl(i->icon_url.spec(), false); |
84 break; | 84 break; |
85 case content::FaviconURL::TOUCH_PRECOMPOSED_ICON: | 85 case content::FaviconURL::IconType::kTouchPrecomposedIcon: |
86 if (listener_) | 86 if (listener_) |
87 listener_->OnReceivedTouchIconUrl(i->icon_url.spec(), true); | 87 listener_->OnReceivedTouchIconUrl(i->icon_url.spec(), true); |
88 break; | 88 break; |
89 case content::FaviconURL::INVALID_ICON: | 89 case content::FaviconURL::IconType::kInvalid: |
90 // Silently ignore it. Only trigger a callback on valid icons. | 90 // Silently ignore it. Only trigger a callback on valid icons. |
91 break; | 91 break; |
92 default: | 92 default: |
93 NOTREACHED(); | 93 NOTREACHED(); |
94 break; | 94 break; |
95 } | 95 } |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 void IconHelper::DidStartNavigationToPendingEntry( | 99 void IconHelper::DidStartNavigationToPendingEntry( |
(...skipping 11 matching lines...) Expand all Loading... |
111 bool IconHelper::WasUnableToDownloadFavicon(const GURL& icon_url) const { | 111 bool IconHelper::WasUnableToDownloadFavicon(const GURL& icon_url) const { |
112 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); | 112 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); |
113 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); | 113 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); |
114 } | 114 } |
115 | 115 |
116 void IconHelper::ClearUnableToDownloadFavicons() { | 116 void IconHelper::ClearUnableToDownloadFavicons() { |
117 missing_favicon_urls_.clear(); | 117 missing_favicon_urls_.clear(); |
118 } | 118 } |
119 | 119 |
120 } // namespace android_webview | 120 } // namespace android_webview |
OLD | NEW |