| 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_download_helper.h" |
| 7 #include "chrome/browser/favicon/favicon_handler.h" | 8 #include "chrome/browser/favicon/favicon_handler.h" |
| 8 #include "chrome/browser/favicon/favicon_service_factory.h" | 9 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 9 #include "chrome/browser/favicon/favicon_util.h" | 10 #include "chrome/browser/favicon/favicon_util.h" |
| 10 #include "chrome/browser/history/history.h" | 11 #include "chrome/browser/history/history.h" |
| 11 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/common/icon_messages.h" | 16 #include "chrome/common/icon_messages.h" |
| 16 #include "content/public/browser/favicon_status.h" | 17 #include "content/public/browser/favicon_status.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); | 139 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); |
| 139 if (touch_icon_handler_.get()) | 140 if (touch_icon_handler_.get()) |
| 140 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); | 141 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); |
| 141 } | 142 } |
| 142 | 143 |
| 143 NavigationEntry* FaviconTabHelper::GetActiveEntry() { | 144 NavigationEntry* FaviconTabHelper::GetActiveEntry() { |
| 144 return web_contents()->GetController().GetActiveEntry(); | 145 return web_contents()->GetController().GetActiveEntry(); |
| 145 } | 146 } |
| 146 | 147 |
| 147 int FaviconTabHelper::StartDownload(const GURL& url, int image_size) { | 148 int FaviconTabHelper::StartDownload(const GURL& url, int image_size) { |
| 148 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | 149 FaviconDownloadHelper::CreateForWebContentsAndDelegate(web_contents(), this); |
| 149 int id = FaviconUtil::DownloadFavicon(host, url, image_size); | 150 FaviconDownloadHelper* helper = |
| 151 FaviconDownloadHelper::FromWebContents(web_contents()); |
| 152 int id = -1; |
| 153 |
| 154 if (helper) { |
| 155 id = helper->DownloadFavicon(url, image_size); |
| 156 } |
| 150 return id; | 157 return id; |
| 151 } | 158 } |
| 152 | 159 |
| 153 void FaviconTabHelper::NotifyFaviconUpdated() { | 160 void FaviconTabHelper::NotifyFaviconUpdated() { |
| 154 content::NotificationService::current()->Notify( | 161 content::NotificationService::current()->Notify( |
| 155 chrome::NOTIFICATION_FAVICON_UPDATED, | 162 chrome::NOTIFICATION_FAVICON_UPDATED, |
| 156 content::Source<WebContents>(web_contents()), | 163 content::Source<WebContents>(web_contents()), |
| 157 content::NotificationService::NoDetails()); | 164 content::NotificationService::NoDetails()); |
| 158 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); | 165 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
| 159 } | 166 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 173 void FaviconTabHelper::DidNavigateMainFrame( | 180 void FaviconTabHelper::DidNavigateMainFrame( |
| 174 const content::LoadCommittedDetails& details, | 181 const content::LoadCommittedDetails& details, |
| 175 const content::FrameNavigateParams& params) { | 182 const content::FrameNavigateParams& params) { |
| 176 // Get the favicon, either from history or request it from the net. | 183 // Get the favicon, either from history or request it from the net. |
| 177 FetchFavicon(details.entry->GetURL()); | 184 FetchFavicon(details.entry->GetURL()); |
| 178 } | 185 } |
| 179 | 186 |
| 180 bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) { | 187 bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) { |
| 181 bool message_handled = false; // Allow other handlers to receive these. | 188 bool message_handled = false; // Allow other handlers to receive these. |
| 182 IPC_BEGIN_MESSAGE_MAP(FaviconTabHelper, message) | 189 IPC_BEGIN_MESSAGE_MAP(FaviconTabHelper, message) |
| 183 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) | |
| 184 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 190 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 185 IPC_MESSAGE_UNHANDLED(message_handled = false) | 191 IPC_MESSAGE_UNHANDLED(message_handled = false) |
| 186 IPC_END_MESSAGE_MAP() | 192 IPC_END_MESSAGE_MAP() |
| 187 return message_handled; | 193 return message_handled; |
| 188 } | 194 } |
| 189 | 195 |
| 190 void FaviconTabHelper::OnDidDownloadFavicon( | 196 void FaviconTabHelper::OnDidDownloadFavicon( |
| 191 int id, | 197 int id, |
| 192 const GURL& image_url, | 198 const GURL& image_url, |
| 193 bool errored, | 199 bool errored, |
| 194 int requested_size, | 200 int requested_size, |
| 195 const std::vector<SkBitmap>& bitmaps) { | 201 const std::vector<SkBitmap>& bitmaps) { |
| 196 favicon_handler_->OnDidDownloadFavicon( | 202 favicon_handler_->OnDidDownloadFavicon( |
| 197 id, image_url, errored, requested_size, bitmaps); | 203 id, image_url, errored, requested_size, bitmaps); |
| 198 if (touch_icon_handler_.get()) { | 204 if (touch_icon_handler_.get()) { |
| 199 touch_icon_handler_->OnDidDownloadFavicon( | 205 touch_icon_handler_->OnDidDownloadFavicon( |
| 200 id, image_url, errored, requested_size, bitmaps); | 206 id, image_url, errored, requested_size, bitmaps); |
| 201 } | 207 } |
| 202 } | 208 } |
| OLD | NEW |