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

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

Issue 10828263: Moving FaviconService to a ProfileKeyedService. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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_handler.h" 5 #include "chrome/browser/favicon/favicon_handler.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.h"
14 #include "chrome/browser/bookmarks/bookmark_model.h" 14 #include "chrome/browser/bookmarks/bookmark_model.h"
15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
16 #include "chrome/browser/favicon/favicon_service_factory.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/icon_messages.h" 18 #include "chrome/common/icon_messages.h"
18 #include "content/public/browser/favicon_status.h" 19 #include "content/public/browser/favicon_status.h"
19 #include "content/public/browser/navigation_entry.h" 20 #include "content/public/browser/navigation_entry.h"
20 #include "skia/ext/image_operations.h" 21 #include "skia/ext/image_operations.h"
21 #include "ui/gfx/codec/png_codec.h" 22 #include "ui/gfx/codec/png_codec.h"
22 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
23 #include "ui/gfx/image/image_util.h" 24 #include "ui/gfx/image/image_util.h"
24 25
25 using content::NavigationEntry; 26 using content::NavigationEntry;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 151
151 int FaviconHandler::DownloadImage( 152 int FaviconHandler::DownloadImage(
152 const GURL& image_url, 153 const GURL& image_url,
153 int image_size, 154 int image_size,
154 history::IconType icon_type, 155 history::IconType icon_type,
155 const FaviconTabHelper::ImageDownloadCallback& callback) { 156 const FaviconTabHelper::ImageDownloadCallback& callback) {
156 return ScheduleDownload(GURL(), image_url, image_size, icon_type, callback); 157 return ScheduleDownload(GURL(), image_url, image_size, icon_type, callback);
157 } 158 }
158 159
159 FaviconService* FaviconHandler::GetFaviconService() { 160 FaviconService* FaviconHandler::GetFaviconService() {
160 return profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 161 return FaviconServiceFactory::GetForProfile(
162 profile_, Profile::EXPLICIT_ACCESS);
161 } 163 }
162 164
163 bool FaviconHandler::UpdateFaviconCandidate(const GURL& url, 165 bool FaviconHandler::UpdateFaviconCandidate(const GURL& url,
164 const GURL& image_url, 166 const GURL& image_url,
165 const gfx::Image& image, 167 const gfx::Image& image,
166 history::IconType icon_type) { 168 history::IconType icon_type) {
167 bool update_candidate = false; 169 bool update_candidate = false;
168 SkBitmap bitmap = *(image.ToSkBitmap()); 170 SkBitmap bitmap = *(image.ToSkBitmap());
169 int bitmap_size = std::max(bitmap.width(), bitmap.height()); 171 int bitmap_size = std::max(bitmap.width(), bitmap.height());
170 bool exact_match = (bitmap_size == preferred_icon_size()); 172 bool exact_match = (bitmap_size == preferred_icon_size());
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 int height = bitmap.height(); 536 int height = bitmap.height();
535 if (width > 0 && height > 0) { 537 if (width > 0 && height > 0) {
536 gfx::CalculateFaviconTargetSize(&width, &height); 538 gfx::CalculateFaviconTargetSize(&width, &height);
537 return gfx::Image(skia::ImageOperations::Resize( 539 return gfx::Image(skia::ImageOperations::Resize(
538 bitmap, skia::ImageOperations::RESIZE_LANCZOS3, 540 bitmap, skia::ImageOperations::RESIZE_LANCZOS3,
539 width, height)); 541 width, height));
540 } 542 }
541 543
542 return image; 544 return image;
543 } 545 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698