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/logging.h" | 9 #include "base/logging.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void IconHelper::DidUpdateFaviconURL(int32 page_id, | 53 void IconHelper::DidUpdateFaviconURL(int32 page_id, |
54 const std::vector<content::FaviconURL>& candidates) { | 54 const std::vector<content::FaviconURL>& candidates) { |
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
56 for (std::vector<content::FaviconURL>::const_iterator i = candidates.begin(); | 56 for (std::vector<content::FaviconURL>::const_iterator i = candidates.begin(); |
57 i != candidates.end(); ++i) { | 57 i != candidates.end(); ++i) { |
58 if (!i->icon_url.is_valid()) | 58 if (!i->icon_url.is_valid()) |
59 continue; | 59 continue; |
60 | 60 |
61 switch(i->icon_type) { | 61 switch(i->icon_type) { |
62 case content::FaviconURL::FAVICON: | 62 case content::FaviconURL::FAVICON: |
63 // TODO(acleung): only fetch the URL if favicon downloading is enabled. | 63 if (listener_ && !listener_->ShouldDownloadFavicon(i->icon_url)) break; |
64 // (currently that is, the app has called WebIconDatabase.open() | |
65 // but we should decouple that setting via a boolean setting) | |
66 web_contents()->DownloadImage(i->icon_url, | 64 web_contents()->DownloadImage(i->icon_url, |
67 true, // Is a favicon | 65 true, // Is a favicon |
68 0, // No maximum size | 66 0, // No maximum size |
69 base::Bind( | 67 base::Bind( |
70 &IconHelper::DownloadFaviconCallback, base::Unretained(this))); | 68 &IconHelper::DownloadFaviconCallback, base::Unretained(this))); |
71 break; | 69 break; |
72 case content::FaviconURL::TOUCH_ICON: | 70 case content::FaviconURL::TOUCH_ICON: |
73 if (listener_) | 71 if (listener_) |
74 listener_->OnReceivedTouchIconUrl(i->icon_url.spec(), false); | 72 listener_->OnReceivedTouchIconUrl(i->icon_url.spec(), false); |
75 break; | 73 break; |
76 case content::FaviconURL::TOUCH_PRECOMPOSED_ICON: | 74 case content::FaviconURL::TOUCH_PRECOMPOSED_ICON: |
77 if (listener_) | 75 if (listener_) |
78 listener_->OnReceivedTouchIconUrl(i->icon_url.spec(), true); | 76 listener_->OnReceivedTouchIconUrl(i->icon_url.spec(), true); |
79 break; | 77 break; |
80 case content::FaviconURL::INVALID_ICON: | 78 case content::FaviconURL::INVALID_ICON: |
81 // Silently ignore it. Only trigger a callback on valid icons. | 79 // Silently ignore it. Only trigger a callback on valid icons. |
82 break; | 80 break; |
83 default: | 81 default: |
84 NOTREACHED(); | 82 NOTREACHED(); |
85 break; | 83 break; |
86 } | 84 } |
87 } | 85 } |
88 } | 86 } |
89 | 87 |
90 } // namespace android_webview | 88 } // namespace android_webview |
OLD | NEW |