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* helper = |
149 int id = FaviconUtil::DownloadFavicon(host, url, image_size); | 150 FaviconDownloadHelper::FromWebContents(web_contents()); |
joth
2012/10/30 14:17:46
I think it maybe clearer to either DCHECK the resu
Cait (Slow)
2012/10/30 18:05:55
Done.
| |
150 return id; | 151 return helper ? helper->DownloadFavicon(url, image_size) : -1; |
151 } | 152 } |
152 | 153 |
153 void FaviconTabHelper::NotifyFaviconUpdated() { | 154 void FaviconTabHelper::NotifyFaviconUpdated() { |
154 content::NotificationService::current()->Notify( | 155 content::NotificationService::current()->Notify( |
155 chrome::NOTIFICATION_FAVICON_UPDATED, | 156 chrome::NOTIFICATION_FAVICON_UPDATED, |
156 content::Source<WebContents>(web_contents()), | 157 content::Source<WebContents>(web_contents()), |
157 content::NotificationService::NoDetails()); | 158 content::NotificationService::NoDetails()); |
158 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); | 159 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
159 } | 160 } |
160 | 161 |
161 void FaviconTabHelper::NavigateToPendingEntry( | 162 void FaviconTabHelper::NavigateToPendingEntry( |
162 const GURL& url, | 163 const GURL& url, |
163 NavigationController::ReloadType reload_type) { | 164 NavigationController::ReloadType reload_type) { |
164 if (reload_type != NavigationController::NO_RELOAD && | 165 if (reload_type != NavigationController::NO_RELOAD && |
165 !profile_->IsOffTheRecord()) { | 166 !profile_->IsOffTheRecord()) { |
166 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 167 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
167 profile_, Profile::IMPLICIT_ACCESS); | 168 profile_, Profile::IMPLICIT_ACCESS); |
168 if (favicon_service) | 169 if (favicon_service) |
169 favicon_service->SetFaviconOutOfDateForPage(url); | 170 favicon_service->SetFaviconOutOfDateForPage(url); |
170 } | 171 } |
171 } | 172 } |
172 | 173 |
173 void FaviconTabHelper::DidNavigateMainFrame( | 174 void FaviconTabHelper::DidNavigateMainFrame( |
174 const content::LoadCommittedDetails& details, | 175 const content::LoadCommittedDetails& details, |
175 const content::FrameNavigateParams& params) { | 176 const content::FrameNavigateParams& params) { |
176 // Get the favicon, either from history or request it from the net. | 177 // Get the favicon, either from history or request it from the net. |
177 FetchFavicon(details.entry->GetURL()); | 178 FetchFavicon(details.entry->GetURL()); |
178 } | 179 } |
179 | 180 |
180 bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) { | |
181 bool message_handled = false; // Allow other handlers to receive these. | |
182 IPC_BEGIN_MESSAGE_MAP(FaviconTabHelper, message) | |
183 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) | |
184 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | |
185 IPC_MESSAGE_UNHANDLED(message_handled = false) | |
186 IPC_END_MESSAGE_MAP() | |
187 return message_handled; | |
188 } | |
189 | |
190 void FaviconTabHelper::OnDidDownloadFavicon( | 181 void FaviconTabHelper::OnDidDownloadFavicon( |
191 int id, | 182 int id, |
192 const GURL& image_url, | 183 const GURL& image_url, |
193 bool errored, | 184 bool errored, |
194 int requested_size, | 185 int requested_size, |
195 const std::vector<SkBitmap>& bitmaps) { | 186 const std::vector<SkBitmap>& bitmaps) { |
196 favicon_handler_->OnDidDownloadFavicon( | 187 favicon_handler_->OnDidDownloadFavicon( |
197 id, image_url, errored, requested_size, bitmaps); | 188 id, image_url, errored, requested_size, bitmaps); |
198 if (touch_icon_handler_.get()) { | 189 if (touch_icon_handler_.get()) { |
199 touch_icon_handler_->OnDidDownloadFavicon( | 190 touch_icon_handler_->OnDidDownloadFavicon( |
200 id, image_url, errored, requested_size, bitmaps); | 191 id, image_url, errored, requested_size, bitmaps); |
201 } | 192 } |
202 } | 193 } |
OLD | NEW |