OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/favicon/favicon_tab_helper.h" | 5 #include "chrome/browser/favicon/favicon_tab_helper.h" |
6 | 6 |
7 #include "chrome/browser/favicon/favicon_handler.h" | 7 #include "chrome/browser/favicon/favicon_handler.h" |
8 #include "chrome/browser/favicon/favicon_util.h" | 8 #include "chrome/browser/favicon/favicon_util.h" |
9 #include "chrome/browser/history/history.h" | 9 #include "chrome/browser/history/history.h" |
10 #include "chrome/browser/history/history_service_factory.h" | 10 #include "chrome/browser/history/history_service_factory.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 FaviconHandler::FAVICON)); | 37 FaviconHandler::FAVICON)); |
38 if (chrome::kEnableTouchIcon) | 38 if (chrome::kEnableTouchIcon) |
39 touch_icon_handler_.reset(new FaviconHandler(profile_, this, | 39 touch_icon_handler_.reset(new FaviconHandler(profile_, this, |
40 FaviconHandler::TOUCH)); | 40 FaviconHandler::TOUCH)); |
41 } | 41 } |
42 | 42 |
43 FaviconTabHelper::~FaviconTabHelper() { | 43 FaviconTabHelper::~FaviconTabHelper() { |
44 } | 44 } |
45 | 45 |
46 void FaviconTabHelper::FetchFavicon(const GURL& url) { | 46 void FaviconTabHelper::FetchFavicon(const GURL& url) { |
| 47 // XXX query scale factor, pass to handler |
47 favicon_handler_->FetchFavicon(url); | 48 favicon_handler_->FetchFavicon(url); |
48 if (touch_icon_handler_.get()) | 49 if (touch_icon_handler_.get()) |
49 touch_icon_handler_->FetchFavicon(url); | 50 touch_icon_handler_->FetchFavicon(url); |
50 } | 51 } |
51 | 52 |
52 SkBitmap FaviconTabHelper::GetFavicon() const { | 53 SkBitmap FaviconTabHelper::GetFavicon() const { |
| 54 // XXX return the default favicon or empty gfx::ImageSkia till the bitmap for |
| 55 // the initial scale factor is loaded. Once that bitmap is loaded, |
| 56 // FaviconTabHelper::GetFavicon() should return a gfx::ImageSkia backed by an |
| 57 // ImageSkiaSource with any already loaded scale factors already cached. |
53 // Like GetTitle(), we also want to use the favicon for the last committed | 58 // Like GetTitle(), we also want to use the favicon for the last committed |
54 // entry rather than a pending navigation entry. | 59 // entry rather than a pending navigation entry. |
55 const NavigationController& controller = web_contents()->GetController(); | 60 const NavigationController& controller = web_contents()->GetController(); |
56 NavigationEntry* entry = controller.GetTransientEntry(); | 61 NavigationEntry* entry = controller.GetTransientEntry(); |
57 if (entry) | 62 if (entry) |
58 return entry->GetFavicon().bitmap; | 63 return entry->GetFavicon().bitmap; |
59 | 64 |
60 entry = controller.GetLastCommittedEntry(); | 65 entry = controller.GetLastCommittedEntry(); |
61 if (entry) | 66 if (entry) |
62 return entry->GetFavicon().bitmap; | 67 return entry->GetFavicon().bitmap; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 191 |
187 void FaviconTabHelper::OnDidDownloadFavicon(int id, | 192 void FaviconTabHelper::OnDidDownloadFavicon(int id, |
188 const GURL& image_url, | 193 const GURL& image_url, |
189 bool errored, | 194 bool errored, |
190 const SkBitmap& image) { | 195 const SkBitmap& image) { |
191 gfx::Image favicon(image); | 196 gfx::Image favicon(image); |
192 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); | 197 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); |
193 if (touch_icon_handler_.get()) | 198 if (touch_icon_handler_.get()) |
194 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); | 199 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); |
195 } | 200 } |
OLD | NEW |