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

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

Issue 10828127: Use hi-resolution favicon variants if available. (Closed) Base URL: svn://svn.chromium.org/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_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_util.h" 8 #include "chrome/browser/favicon/favicon_util.h"
9 #include "chrome/browser/favicon/select_favicon_frames.h"
9 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
10 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_constants.h" 13 #include "chrome/common/chrome_constants.h"
13 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/icon_messages.h" 15 #include "chrome/common/icon_messages.h"
15 #include "content/public/browser/favicon_status.h" 16 #include "content/public/browser/favicon_status.h"
16 #include "content/public/browser/invalidate_type.h" 17 #include "content/public/browser/invalidate_type.h"
17 #include "content/public/browser/navigation_controller.h" 18 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/navigation_details.h" 19 #include "content/public/browser/navigation_details.h"
19 #include "content/public/browser/navigation_entry.h" 20 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_contents_delegate.h" 24 #include "content/public/browser/web_contents_delegate.h"
24 #include "content/public/browser/web_ui.h" 25 #include "content/public/browser/web_ui.h"
25 #include "ui/gfx/codec/png_codec.h" 26 #include "ui/gfx/codec/png_codec.h"
26 #include "ui/gfx/image/image.h" 27 #include "ui/gfx/image/image.h"
28 #include "ui/gfx/image/image_skia.h"
29 #include "ui/gfx/image/image_skia_rep.h"
27 30
28 using content::FaviconStatus; 31 using content::FaviconStatus;
29 using content::NavigationController; 32 using content::NavigationController;
30 using content::NavigationEntry; 33 using content::NavigationEntry;
31 using content::WebContents; 34 using content::WebContents;
32 35
33 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents) 36 FaviconTabHelper::FaviconTabHelper(WebContents* web_contents)
34 : content::WebContentsObserver(web_contents), 37 : content::WebContentsObserver(web_contents),
35 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { 38 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) {
36 favicon_handler_.reset(new FaviconHandler(profile_, this, 39 favicon_handler_.reset(new FaviconHandler(profile_, this,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) { 182 bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) {
180 bool message_handled = false; // Allow other handlers to receive these. 183 bool message_handled = false; // Allow other handlers to receive these.
181 IPC_BEGIN_MESSAGE_MAP(FaviconTabHelper, message) 184 IPC_BEGIN_MESSAGE_MAP(FaviconTabHelper, message)
182 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) 185 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon)
183 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) 186 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
184 IPC_MESSAGE_UNHANDLED(message_handled = false) 187 IPC_MESSAGE_UNHANDLED(message_handled = false)
185 IPC_END_MESSAGE_MAP() 188 IPC_END_MESSAGE_MAP()
186 return message_handled; 189 return message_handled;
187 } 190 }
188 191
189 void FaviconTabHelper::OnDidDownloadFavicon(int id, 192 void FaviconTabHelper::OnDidDownloadFavicon(
190 const GURL& image_url, 193 int id,
191 bool errored, 194 const GURL& image_url,
192 const SkBitmap& image) { 195 bool errored,
193 gfx::Image favicon(image); 196 int requested_size,
197 const std::vector<SkBitmap>& bitmaps) {
198 // TODO: Possibly do bitmap selection in FaviconHandler, so that it can score
199 // favicons better.
200 std::vector<ui::ScaleFactor> scale_factors;
201 #if defined(OS_MACOSX)
202 scale_factors = ui::GetSupportedScaleFactors();
203 #else
204 scale_factors.push_back(ui::SCALE_FACTOR_100P); // TODO: Aura?
Nico 2012/08/06 20:29:19 pkotwicz: How should this be done?
205 #endif
206 gfx::Image favicon(SelectFaviconFrames(bitmaps, scale_factors, requested_size) );
sky 2012/08/06 20:49:14 nit: > 80
194 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); 207 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon);
195 if (touch_icon_handler_.get()) 208 if (touch_icon_handler_.get())
196 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); 209 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon);
197 } 210 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper.h ('k') | chrome/browser/ui/views/ash/launcher/launcher_favicon_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698