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

Side by Side Diff: chrome/browser/favicon_delegate.cc

Issue 6672065: Support touch icon in FaviconHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only update the FAVICON data to the NavigationEntry. Created 9 years, 9 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/favicon_delegate.h"
6
7 #include "content/browser/tab_contents/navigation_entry.h"
8 #include "content/browser/tab_contents/tab_contents.h"
9 #include "ui/gfx/favicon_size.h"
10
11 FaviconDelegate::FaviconDelegate(TabContents* tab_contents)
12 : IconDelegate(),
13 tab_contents_(tab_contents) {
14 }
15
16 FaviconDelegate::~FaviconDelegate() {
17 }
18
19 void FaviconDelegate::UpdateFaviconImageData(
20 NavigationEntry* entry,
21 const GURL& icon_url,
22 scoped_refptr<RefCountedMemory> data) {
23 if (entry->favicon().is_valid() && icon_url != entry->favicon().url())
24 return;
25 UpdateFaviconImageData(entry, data);
26 }
27
28 void FaviconDelegate::UpdateFaviconImageData(NavigationEntry* entry,
29 const SkBitmap& image) {
30 // No matter what happens, we need to mark the favicon as being set.
31 entry->favicon().set_is_valid(true);
32
33 if (image.empty())
34 return;
35
36 entry->favicon().set_bitmap(image);
37 tab_contents_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB);
38 }
39
40 void FaviconDelegate::UpdateFaviconURL(NavigationEntry* entry,
41 const GURL& url) {
42 entry->favicon().set_url(url);
43 }
44
45 SkBitmap FaviconDelegate::ConvertToFaviconSize(const SkBitmap& image) {
46 int width = image.width();
47 int height = image.height();
48
49 if (width > 0 && width != kFaviconSize && height > 0
50 && height != kFaviconSize) {
51 calc_favicon_target_size(&width, &height);
52 return skia::ImageOperations::Resize(
53 image, skia::ImageOperations::RESIZE_LANCZOS3,
54 width, height);
55 }
56 return image;
57 }
58
59 int FaviconDelegate::GetIconSize() {
60 return kFaviconSize;
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698