| 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" | |
| 9 #include "chrome/browser/favicon/favicon_util.h" | 8 #include "chrome/browser/favicon/favicon_util.h" |
| 10 #include "chrome/browser/favicon/select_favicon_frames.h" | 9 #include "chrome/browser/favicon/select_favicon_frames.h" |
| 11 #include "chrome/browser/history/history.h" | 10 #include "chrome/browser/history/history.h" |
| 12 #include "chrome/browser/history/history_service_factory.h" | 11 #include "chrome/browser/history/history_service_factory.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/icon_messages.h" | 15 #include "chrome/common/icon_messages.h" |
| 17 #include "content/public/browser/favicon_status.h" | 16 #include "content/public/browser/favicon_status.h" |
| 18 #include "content/public/browser/invalidate_type.h" | 17 #include "content/public/browser/invalidate_type.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 return; | 97 return; |
| 99 | 98 |
| 100 // Make sure the page is in history, otherwise adding the favicon does | 99 // Make sure the page is in history, otherwise adding the favicon does |
| 101 // nothing. | 100 // nothing. |
| 102 HistoryService* history = HistoryServiceFactory::GetForProfile( | 101 HistoryService* history = HistoryServiceFactory::GetForProfile( |
| 103 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); | 102 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); |
| 104 if (!history) | 103 if (!history) |
| 105 return; | 104 return; |
| 106 history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle()); | 105 history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle()); |
| 107 | 106 |
| 108 FaviconService* service = FaviconServiceFactory::GetForProfile( | 107 FaviconService* service = profile_-> |
| 109 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); | 108 GetOriginalProfile()->GetFaviconService(Profile::IMPLICIT_ACCESS); |
| 110 if (!service) | 109 if (!service) |
| 111 return; | 110 return; |
| 112 const FaviconStatus& favicon(entry->GetFavicon()); | 111 const FaviconStatus& favicon(entry->GetFavicon()); |
| 113 if (!favicon.valid || favicon.url.is_empty() || | 112 if (!favicon.valid || favicon.url.is_empty() || |
| 114 favicon.image.IsEmpty()) { | 113 favicon.image.IsEmpty()) { |
| 115 return; | 114 return; |
| 116 } | 115 } |
| 117 std::vector<unsigned char> image_data; | 116 std::vector<unsigned char> image_data; |
| 118 // TODO: Save all representations. | 117 // TODO: Save all representations. |
| 119 gfx::PNGCodec::EncodeBGRASkBitmap( | 118 gfx::PNGCodec::EncodeBGRASkBitmap( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 content::Source<WebContents>(web_contents()), | 158 content::Source<WebContents>(web_contents()), |
| 160 content::NotificationService::NoDetails()); | 159 content::NotificationService::NoDetails()); |
| 161 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); | 160 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
| 162 } | 161 } |
| 163 | 162 |
| 164 void FaviconTabHelper::NavigateToPendingEntry( | 163 void FaviconTabHelper::NavigateToPendingEntry( |
| 165 const GURL& url, | 164 const GURL& url, |
| 166 NavigationController::ReloadType reload_type) { | 165 NavigationController::ReloadType reload_type) { |
| 167 if (reload_type != NavigationController::NO_RELOAD && | 166 if (reload_type != NavigationController::NO_RELOAD && |
| 168 !profile_->IsOffTheRecord()) { | 167 !profile_->IsOffTheRecord()) { |
| 169 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 168 FaviconService* favicon_service = |
| 170 profile_, Profile::IMPLICIT_ACCESS); | 169 profile_->GetFaviconService(Profile::IMPLICIT_ACCESS); |
| 171 if (favicon_service) | 170 if (favicon_service) |
| 172 favicon_service->SetFaviconOutOfDateForPage(url); | 171 favicon_service->SetFaviconOutOfDateForPage(url); |
| 173 } | 172 } |
| 174 } | 173 } |
| 175 | 174 |
| 176 void FaviconTabHelper::DidNavigateMainFrame( | 175 void FaviconTabHelper::DidNavigateMainFrame( |
| 177 const content::LoadCommittedDetails& details, | 176 const content::LoadCommittedDetails& details, |
| 178 const content::FrameNavigateParams& params) { | 177 const content::FrameNavigateParams& params) { |
| 179 // Get the favicon, either from history or request it from the net. | 178 // Get the favicon, either from history or request it from the net. |
| 180 FetchFavicon(details.entry->GetURL()); | 179 FetchFavicon(details.entry->GetURL()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 203 scale_factors = ui::GetSupportedScaleFactors(); | 202 scale_factors = ui::GetSupportedScaleFactors(); |
| 204 gfx::Image favicon(SelectFaviconFrames( | 203 gfx::Image favicon(SelectFaviconFrames( |
| 205 bitmaps, scale_factors, requested_size, &score)); | 204 bitmaps, scale_factors, requested_size, &score)); |
| 206 favicon_handler_->OnDidDownloadFavicon( | 205 favicon_handler_->OnDidDownloadFavicon( |
| 207 id, image_url, errored, favicon, score); | 206 id, image_url, errored, favicon, score); |
| 208 if (touch_icon_handler_.get()) { | 207 if (touch_icon_handler_.get()) { |
| 209 touch_icon_handler_->OnDidDownloadFavicon( | 208 touch_icon_handler_->OnDidDownloadFavicon( |
| 210 id, image_url, errored, favicon, score); | 209 id, image_url, errored, favicon, score); |
| 211 } | 210 } |
| 212 } | 211 } |
| OLD | NEW |