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_service_factory.h" | 8 #include "chrome/browser/favicon/favicon_service_factory.h" |
9 #include "chrome/browser/favicon/favicon_util.h" | 9 #include "chrome/browser/favicon/favicon_util.h" |
10 #include "chrome/browser/history/history.h" | 10 #include "chrome/browser/history/history.h" |
11 #include "chrome/browser/history/history_service_factory.h" | 11 #include "chrome/browser/history/history_service_factory.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
14 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
15 #include "chrome/common/icon_messages.h" | 15 #include "chrome/common/icon_messages.h" |
16 #include "content/public/browser/favicon_status.h" | 16 #include "content/public/browser/favicon_status.h" |
17 #include "content/public/browser/invalidate_type.h" | 17 #include "content/public/browser/invalidate_type.h" |
18 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
19 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "content/public/browser/web_contents_delegate.h" | 24 #include "content/public/browser/web_contents_delegate.h" |
25 #include "content/public/browser/web_ui.h" | 25 #include "content/public/browser/web_ui.h" |
26 #include "content/public/common/frame_navigate_params.h" | |
26 #include "ui/gfx/codec/png_codec.h" | 27 #include "ui/gfx/codec/png_codec.h" |
27 #include "ui/gfx/image/image.h" | 28 #include "ui/gfx/image/image.h" |
28 #include "ui/gfx/image/image_skia.h" | 29 #include "ui/gfx/image/image_skia.h" |
29 #include "ui/gfx/image/image_skia_rep.h" | 30 #include "ui/gfx/image/image_skia_rep.h" |
30 | 31 |
31 using content::FaviconStatus; | 32 using content::FaviconStatus; |
32 using content::NavigationController; | 33 using content::NavigationController; |
33 using content::NavigationEntry; | 34 using content::NavigationEntry; |
34 using content::WebContents; | 35 using content::WebContents; |
35 | 36 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) { |
177 | |
178 // The NavigationEntry may be reused from the previously navigated page in | |
sky
2012/10/17 16:07:34
Is the real bug that we're reusing favicons on cli
| |
179 // the case of a client redirect. Clear the favicon as it should never be | |
180 // carried over from the previous page. Do not clear the favicon in the case | |
181 // of back and forward transitions to avoid negative interaction with the | |
182 // BackForwardMenuModel. | |
183 if ((params.transition & content::PAGE_TRANSITION_FORWARD_BACK) == 0) | |
184 details.entry->GetFavicon() = FaviconStatus(); | |
185 | |
176 // Get the favicon, either from history or request it from the net. | 186 // Get the favicon, either from history or request it from the net. |
177 FetchFavicon(details.entry->GetURL()); | 187 FetchFavicon(details.entry->GetURL()); |
178 } | 188 } |
179 | 189 |
180 bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) { | 190 bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) { |
181 bool message_handled = false; // Allow other handlers to receive these. | 191 bool message_handled = false; // Allow other handlers to receive these. |
182 IPC_BEGIN_MESSAGE_MAP(FaviconTabHelper, message) | 192 IPC_BEGIN_MESSAGE_MAP(FaviconTabHelper, message) |
183 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) | 193 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) |
184 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 194 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
185 IPC_MESSAGE_UNHANDLED(message_handled = false) | 195 IPC_MESSAGE_UNHANDLED(message_handled = false) |
186 IPC_END_MESSAGE_MAP() | 196 IPC_END_MESSAGE_MAP() |
187 return message_handled; | 197 return message_handled; |
188 } | 198 } |
189 | 199 |
190 void FaviconTabHelper::OnDidDownloadFavicon( | 200 void FaviconTabHelper::OnDidDownloadFavicon( |
191 int id, | 201 int id, |
192 const GURL& image_url, | 202 const GURL& image_url, |
193 bool errored, | 203 bool errored, |
194 int requested_size, | 204 int requested_size, |
195 const std::vector<SkBitmap>& bitmaps) { | 205 const std::vector<SkBitmap>& bitmaps) { |
196 favicon_handler_->OnDidDownloadFavicon( | 206 favicon_handler_->OnDidDownloadFavicon( |
197 id, image_url, errored, requested_size, bitmaps); | 207 id, image_url, errored, requested_size, bitmaps); |
198 if (touch_icon_handler_.get()) { | 208 if (touch_icon_handler_.get()) { |
199 touch_icon_handler_->OnDidDownloadFavicon( | 209 touch_icon_handler_->OnDidDownloadFavicon( |
200 id, image_url, errored, requested_size, bitmaps); | 210 id, image_url, errored, requested_size, bitmaps); |
201 } | 211 } |
202 } | 212 } |
OLD | NEW |