Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/favicon/favicon_tab_helper.cc

Issue 10828263: Moving FaviconService to a ProfileKeyedService. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: resyncing with library after revert Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_util.h" 9 #include "chrome/browser/favicon/favicon_util.h"
9 #include "chrome/browser/favicon/select_favicon_frames.h" 10 #include "chrome/browser/favicon/select_favicon_frames.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"
17 #include "content/public/browser/invalidate_type.h" 18 #include "content/public/browser/invalidate_type.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return; 98 return;
98 99
99 // Make sure the page is in history, otherwise adding the favicon does 100 // Make sure the page is in history, otherwise adding the favicon does
100 // nothing. 101 // nothing.
101 HistoryService* history = HistoryServiceFactory::GetForProfile( 102 HistoryService* history = HistoryServiceFactory::GetForProfile(
102 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); 103 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
103 if (!history) 104 if (!history)
104 return; 105 return;
105 history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle()); 106 history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle());
106 107
107 FaviconService* service = profile_-> 108 FaviconService* service = FaviconServiceFactory::GetForProfile(
108 GetOriginalProfile()->GetFaviconService(Profile::IMPLICIT_ACCESS); 109 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
109 if (!service) 110 if (!service)
110 return; 111 return;
111 const FaviconStatus& favicon(entry->GetFavicon()); 112 const FaviconStatus& favicon(entry->GetFavicon());
112 if (!favicon.valid || favicon.url.is_empty() || 113 if (!favicon.valid || favicon.url.is_empty() ||
113 favicon.image.IsEmpty()) { 114 favicon.image.IsEmpty()) {
114 return; 115 return;
115 } 116 }
116 std::vector<unsigned char> image_data; 117 std::vector<unsigned char> image_data;
117 // TODO: Save all representations. 118 // TODO: Save all representations.
118 gfx::PNGCodec::EncodeBGRASkBitmap( 119 gfx::PNGCodec::EncodeBGRASkBitmap(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 content::Source<WebContents>(web_contents()), 159 content::Source<WebContents>(web_contents()),
159 content::NotificationService::NoDetails()); 160 content::NotificationService::NoDetails());
160 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); 161 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB);
161 } 162 }
162 163
163 void FaviconTabHelper::NavigateToPendingEntry( 164 void FaviconTabHelper::NavigateToPendingEntry(
164 const GURL& url, 165 const GURL& url,
165 NavigationController::ReloadType reload_type) { 166 NavigationController::ReloadType reload_type) {
166 if (reload_type != NavigationController::NO_RELOAD && 167 if (reload_type != NavigationController::NO_RELOAD &&
167 !profile_->IsOffTheRecord()) { 168 !profile_->IsOffTheRecord()) {
168 FaviconService* favicon_service = 169 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
169 profile_->GetFaviconService(Profile::IMPLICIT_ACCESS); 170 profile_, Profile::IMPLICIT_ACCESS);
170 if (favicon_service) 171 if (favicon_service)
171 favicon_service->SetFaviconOutOfDateForPage(url); 172 favicon_service->SetFaviconOutOfDateForPage(url);
172 } 173 }
173 } 174 }
174 175
175 void FaviconTabHelper::DidNavigateMainFrame( 176 void FaviconTabHelper::DidNavigateMainFrame(
176 const content::LoadCommittedDetails& details, 177 const content::LoadCommittedDetails& details,
177 const content::FrameNavigateParams& params) { 178 const content::FrameNavigateParams& params) {
178 // Get the favicon, either from history or request it from the net. 179 // Get the favicon, either from history or request it from the net.
179 FetchFavicon(details.entry->GetURL()); 180 FetchFavicon(details.entry->GetURL());
(...skipping 22 matching lines...) Expand all
202 scale_factors = ui::GetSupportedScaleFactors(); 203 scale_factors = ui::GetSupportedScaleFactors();
203 gfx::Image favicon(SelectFaviconFrames( 204 gfx::Image favicon(SelectFaviconFrames(
204 bitmaps, scale_factors, requested_size, &score)); 205 bitmaps, scale_factors, requested_size, &score));
205 favicon_handler_->OnDidDownloadFavicon( 206 favicon_handler_->OnDidDownloadFavicon(
206 id, image_url, errored, favicon, score); 207 id, image_url, errored, favicon, score);
207 if (touch_icon_handler_.get()) { 208 if (touch_icon_handler_.get()) {
208 touch_icon_handler_->OnDidDownloadFavicon( 209 touch_icon_handler_->OnDidDownloadFavicon(
209 id, image_url, errored, favicon, score); 210 id, image_url, errored, favicon, score);
210 } 211 }
211 } 212 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_service_factory.cc ('k') | chrome/browser/importer/profile_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698