| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/history/history.h" | 8 #include "chrome/browser/history/history.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 void FaviconTabHelper::FetchFavicon(const GURL& url) { | 36 void FaviconTabHelper::FetchFavicon(const GURL& url) { |
| 37 favicon_handler_->FetchFavicon(url); | 37 favicon_handler_->FetchFavicon(url); |
| 38 if (touch_icon_handler_.get()) | 38 if (touch_icon_handler_.get()) |
| 39 touch_icon_handler_->FetchFavicon(url); | 39 touch_icon_handler_->FetchFavicon(url); |
| 40 } | 40 } |
| 41 | 41 |
| 42 SkBitmap FaviconTabHelper::GetFavicon() const { | 42 SkBitmap FaviconTabHelper::GetFavicon() const { |
| 43 // Like GetTitle(), we also want to use the favicon for the last committed | 43 // Like GetTitle(), we also want to use the favicon for the last committed |
| 44 // entry rather than a pending navigation entry. | 44 // entry rather than a pending navigation entry. |
| 45 const NavigationController& controller = tab_contents()->controller(); | 45 const NavigationController& controller = tab_contents()->GetController(); |
| 46 NavigationEntry* entry = controller.GetTransientEntry(); | 46 NavigationEntry* entry = controller.GetTransientEntry(); |
| 47 if (entry) | 47 if (entry) |
| 48 return entry->favicon().bitmap(); | 48 return entry->favicon().bitmap(); |
| 49 | 49 |
| 50 entry = controller.GetLastCommittedEntry(); | 50 entry = controller.GetLastCommittedEntry(); |
| 51 if (entry) | 51 if (entry) |
| 52 return entry->favicon().bitmap(); | 52 return entry->favicon().bitmap(); |
| 53 return SkBitmap(); | 53 return SkBitmap(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool FaviconTabHelper::FaviconIsValid() const { | 56 bool FaviconTabHelper::FaviconIsValid() const { |
| 57 const NavigationController& controller = tab_contents()->controller(); | 57 const NavigationController& controller = tab_contents()->GetController(); |
| 58 NavigationEntry* entry = controller.GetTransientEntry(); | 58 NavigationEntry* entry = controller.GetTransientEntry(); |
| 59 if (entry) | 59 if (entry) |
| 60 return entry->favicon().is_valid(); | 60 return entry->favicon().is_valid(); |
| 61 | 61 |
| 62 entry = controller.GetLastCommittedEntry(); | 62 entry = controller.GetLastCommittedEntry(); |
| 63 if (entry) | 63 if (entry) |
| 64 return entry->favicon().is_valid(); | 64 return entry->favicon().is_valid(); |
| 65 | 65 |
| 66 return false; | 66 return false; |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool FaviconTabHelper::ShouldDisplayFavicon() { | 69 bool FaviconTabHelper::ShouldDisplayFavicon() { |
| 70 // Always display a throbber during pending loads. | 70 // Always display a throbber during pending loads. |
| 71 const NavigationController& controller = tab_contents()->controller(); | 71 const NavigationController& controller = tab_contents()->GetController(); |
| 72 if (controller.GetLastCommittedEntry() && controller.pending_entry()) | 72 if (controller.GetLastCommittedEntry() && controller.pending_entry()) |
| 73 return true; | 73 return true; |
| 74 | 74 |
| 75 WebUI* web_ui = tab_contents()->GetWebUIForCurrentState(); | 75 WebUI* web_ui = tab_contents()->GetWebUIForCurrentState(); |
| 76 if (web_ui) | 76 if (web_ui) |
| 77 return !web_ui->hide_favicon(); | 77 return !web_ui->hide_favicon(); |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 | 80 |
| 81 void FaviconTabHelper::SaveFavicon() { | 81 void FaviconTabHelper::SaveFavicon() { |
| 82 NavigationEntry* entry = tab_contents()->controller().GetActiveEntry(); | 82 NavigationEntry* entry = tab_contents()->GetController().GetActiveEntry(); |
| 83 if (!entry || entry->url().is_empty()) | 83 if (!entry || entry->url().is_empty()) |
| 84 return; | 84 return; |
| 85 | 85 |
| 86 // Make sure the page is in history, otherwise adding the favicon does | 86 // Make sure the page is in history, otherwise adding the favicon does |
| 87 // nothing. | 87 // nothing. |
| 88 HistoryService* history = profile_-> | 88 HistoryService* history = profile_-> |
| 89 GetOriginalProfile()->GetHistoryService(Profile::IMPLICIT_ACCESS); | 89 GetOriginalProfile()->GetHistoryService(Profile::IMPLICIT_ACCESS); |
| 90 if (!history) | 90 if (!history) |
| 91 return; | 91 return; |
| 92 history->AddPageNoVisitForBookmark(entry->url()); | 92 history->AddPageNoVisitForBookmark(entry->url()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 121 | 121 |
| 122 void FaviconTabHelper::OnUpdateFaviconURL( | 122 void FaviconTabHelper::OnUpdateFaviconURL( |
| 123 int32 page_id, | 123 int32 page_id, |
| 124 const std::vector<FaviconURL>& candidates) { | 124 const std::vector<FaviconURL>& candidates) { |
| 125 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); | 125 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); |
| 126 if (touch_icon_handler_.get()) | 126 if (touch_icon_handler_.get()) |
| 127 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); | 127 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); |
| 128 } | 128 } |
| 129 | 129 |
| 130 NavigationEntry* FaviconTabHelper::GetActiveEntry() { | 130 NavigationEntry* FaviconTabHelper::GetActiveEntry() { |
| 131 return tab_contents()->controller().GetActiveEntry(); | 131 return tab_contents()->GetController().GetActiveEntry(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void FaviconTabHelper::StartDownload(int id, const GURL& url, int image_size) { | 134 void FaviconTabHelper::StartDownload(int id, const GURL& url, int image_size) { |
| 135 RenderViewHost* host = tab_contents()->GetRenderViewHost(); | 135 RenderViewHost* host = tab_contents()->GetRenderViewHost(); |
| 136 host->Send(new IconMsg_DownloadFavicon( | 136 host->Send(new IconMsg_DownloadFavicon( |
| 137 host->routing_id(), id, url, image_size)); | 137 host->routing_id(), id, url, image_size)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void FaviconTabHelper::NotifyFaviconUpdated() { | 140 void FaviconTabHelper::NotifyFaviconUpdated() { |
| 141 content::NotificationService::current()->Notify( | 141 content::NotificationService::current()->Notify( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 void FaviconTabHelper::OnDidDownloadFavicon(int id, | 177 void FaviconTabHelper::OnDidDownloadFavicon(int id, |
| 178 const GURL& image_url, | 178 const GURL& image_url, |
| 179 bool errored, | 179 bool errored, |
| 180 const SkBitmap& image) { | 180 const SkBitmap& image) { |
| 181 gfx::Image favicon(new SkBitmap(image)); | 181 gfx::Image favicon(new SkBitmap(image)); |
| 182 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); | 182 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); |
| 183 if (touch_icon_handler_.get()) | 183 if (touch_icon_handler_.get()) |
| 184 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); | 184 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); |
| 185 } | 185 } |
| OLD | NEW |