| 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_service.h" | 5 #include "chrome/browser/favicon/favicon_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/history/history.h" | 7 #include "chrome/browser/history/history.h" |
| 8 #include "chrome/browser/history/history_backend.h" | 8 #include "chrome/browser/history/history_backend.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 63 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
| 64 profile_, Profile::EXPLICIT_ACCESS); | 64 profile_, Profile::EXPLICIT_ACCESS); |
| 65 if (hs) | 65 if (hs) |
| 66 hs->GetFaviconForURL(request, page_url, icon_types); | 66 hs->GetFaviconForURL(request, page_url, icon_types); |
| 67 else | 67 else |
| 68 ForwardEmptyResultAsync(request); | 68 ForwardEmptyResultAsync(request); |
| 69 } | 69 } |
| 70 return handle; | 70 return handle; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Requests the favicon for |favicon_id|. The |consumer| is notified when the | |
| 74 // bits have been fetched. | |
| 75 FaviconService::Handle FaviconService::GetFaviconForID( | |
| 76 history::FaviconID favicon_id, | |
| 77 CancelableRequestConsumerBase* consumer, | |
| 78 const FaviconDataCallback& callback) { | |
| 79 GetFaviconRequest* request = new GetFaviconRequest(callback); | |
| 80 AddRequest(request, consumer); | |
| 81 FaviconService::Handle handle = request->handle(); | |
| 82 HistoryService* hs = | |
| 83 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | |
| 84 if (hs) | |
| 85 hs->GetFaviconForID(request, favicon_id); | |
| 86 else | |
| 87 ForwardEmptyResultAsync(request); | |
| 88 | |
| 89 return handle; | |
| 90 } | |
| 91 | |
| 92 | |
| 93 void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) { | 73 void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) { |
| 94 HistoryService* hs = | 74 HistoryService* hs = |
| 95 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 75 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 96 if (hs) | 76 if (hs) |
| 97 hs->SetFaviconOutOfDateForPage(page_url); | 77 hs->SetFaviconOutOfDateForPage(page_url); |
| 98 } | 78 } |
| 99 | 79 |
| 100 void FaviconService::CloneFavicon(const GURL& old_page_url, | 80 void FaviconService::CloneFavicon(const GURL& old_page_url, |
| 101 const GURL& new_page_url) { | 81 const GURL& new_page_url) { |
| 102 HistoryService* hs = | 82 HistoryService* hs = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 120 HistoryService* hs = | 100 HistoryService* hs = |
| 121 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 101 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 122 if (hs) | 102 if (hs) |
| 123 hs->SetFavicon(page_url, icon_url, image_data, icon_type); | 103 hs->SetFavicon(page_url, icon_url, image_data, icon_type); |
| 124 } | 104 } |
| 125 | 105 |
| 126 FaviconService::~FaviconService() { | 106 FaviconService::~FaviconService() { |
| 127 } | 107 } |
| 128 | 108 |
| 129 void FaviconService::ForwardEmptyResultAsync(GetFaviconRequest* request) { | 109 void FaviconService::ForwardEmptyResultAsync(GetFaviconRequest* request) { |
| 130 request->ForwardResultAsync(request->handle(), history::FaviconData()); | 110 request->ForwardResultAsync(request->handle(), history::FaviconData(), |
| 111 std::vector<GURL>()); |
| 131 } | 112 } |
| OLD | NEW |