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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/favicon_delegate.cc
diff --git a/chrome/browser/favicon_delegate.cc b/chrome/browser/favicon_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4ef2580f6e82fa87749db5c4f36b9e6b71985cb2
--- /dev/null
+++ b/chrome/browser/favicon_delegate.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/favicon_delegate.h"
+
+#include "content/browser/tab_contents/navigation_entry.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "ui/gfx/favicon_size.h"
+
+FaviconDelegate::FaviconDelegate(TabContents* tab_contents)
+ : IconDelegate(),
+ tab_contents_(tab_contents) {
+}
+
+FaviconDelegate::~FaviconDelegate() {
+}
+
+void FaviconDelegate::UpdateFaviconImageData(
+ NavigationEntry* entry,
+ const GURL& icon_url,
+ scoped_refptr<RefCountedMemory> data) {
+ if (entry->favicon().is_valid() && icon_url != entry->favicon().url())
+ return;
+ UpdateFaviconImageData(entry, data);
+}
+
+void FaviconDelegate::UpdateFaviconImageData(NavigationEntry* entry,
+ const SkBitmap& image) {
+ // No matter what happens, we need to mark the favicon as being set.
+ entry->favicon().set_is_valid(true);
+
+ if (image.empty())
+ return;
+
+ entry->favicon().set_bitmap(image);
+ tab_contents_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB);
+}
+
+void FaviconDelegate::UpdateFaviconURL(NavigationEntry* entry,
+ const GURL& url) {
+ entry->favicon().set_url(url);
+}
+
+SkBitmap FaviconDelegate::ConvertToFaviconSize(const SkBitmap& image) {
+ int width = image.width();
+ int height = image.height();
+
+ if (width > 0 && width != kFaviconSize && height > 0
+ && height != kFaviconSize) {
+ calc_favicon_target_size(&width, &height);
+ return skia::ImageOperations::Resize(
+ image, skia::ImageOperations::RESIZE_LANCZOS3,
+ width, height);
+ }
+ return image;
+}
+
+int FaviconDelegate::GetIconSize() {
+ return kFaviconSize;
+}

Powered by Google App Engine
This is Rietveld 408576698