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()); |
151 int id = -1; | |
152 | |
153 if (helper) { | |
sky
2012/10/24 16:38:10
return helper ? helper->... : -1;
Cait (Slow)
2012/10/24 17:31:20
Done.
| |
154 id = helper->DownloadFavicon(url, image_size); | |
155 } | |
150 return id; | 156 return id; |
151 } | 157 } |
152 | 158 |
153 void FaviconTabHelper::NotifyFaviconUpdated() { | 159 void FaviconTabHelper::NotifyFaviconUpdated() { |
154 content::NotificationService::current()->Notify( | 160 content::NotificationService::current()->Notify( |
155 chrome::NOTIFICATION_FAVICON_UPDATED, | 161 chrome::NOTIFICATION_FAVICON_UPDATED, |
156 content::Source<WebContents>(web_contents()), | 162 content::Source<WebContents>(web_contents()), |
157 content::NotificationService::NoDetails()); | 163 content::NotificationService::NoDetails()); |
158 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); | 164 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
159 } | 165 } |
(...skipping 10 matching lines...) Expand all Loading... | |
170 } | 176 } |
171 } | 177 } |
172 | 178 |
173 void FaviconTabHelper::DidNavigateMainFrame( | 179 void FaviconTabHelper::DidNavigateMainFrame( |
174 const content::LoadCommittedDetails& details, | 180 const content::LoadCommittedDetails& details, |
175 const content::FrameNavigateParams& params) { | 181 const content::FrameNavigateParams& params) { |
176 // Get the favicon, either from history or request it from the net. | 182 // Get the favicon, either from history or request it from the net. |
177 FetchFavicon(details.entry->GetURL()); | 183 FetchFavicon(details.entry->GetURL()); |
178 } | 184 } |
179 | 185 |
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( | 186 void FaviconTabHelper::OnDidDownloadFavicon( |
191 int id, | 187 int id, |
192 const GURL& image_url, | 188 const GURL& image_url, |
193 bool errored, | 189 bool errored, |
194 int requested_size, | 190 int requested_size, |
195 const std::vector<SkBitmap>& bitmaps) { | 191 const std::vector<SkBitmap>& bitmaps) { |
196 favicon_handler_->OnDidDownloadFavicon( | 192 favicon_handler_->OnDidDownloadFavicon( |
197 id, image_url, errored, requested_size, bitmaps); | 193 id, image_url, errored, requested_size, bitmaps); |
198 if (touch_icon_handler_.get()) { | 194 if (touch_icon_handler_.get()) { |
199 touch_icon_handler_->OnDidDownloadFavicon( | 195 touch_icon_handler_->OnDidDownloadFavicon( |
200 id, image_url, errored, requested_size, bitmaps); | 196 id, image_url, errored, requested_size, bitmaps); |
201 } | 197 } |
202 } | 198 } |
OLD | NEW |