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

Side by Side Diff: chrome/browser/ui/webui/favicon_source.cc

Issue 6672065: Support touch icon in FaviconHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some style issues 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/ui/webui/favicon_source.h" 5 #include "chrome/browser/ui/webui/favicon_source.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "grit/app_resources.h" 10 #include "grit/app_resources.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 12
13 FaviconSource::FaviconSource(Profile* profile) 13 FaviconSource::FaviconSource(Profile* profile, const std::string& favicon_host)
14 : DataSource(chrome::kChromeUIFaviconHost, MessageLoop::current()), 14 : DataSource(favicon_host, MessageLoop::current()),
15 profile_(profile->GetOriginalProfile()) { 15 profile_(profile->GetOriginalProfile()),
16 icon_types_(favicon_host.compare(chrome::kChromeUIFaviconHost) == 0 ?
17 history::FAVICON :
18 history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON) {
16 } 19 }
17 20
18 FaviconSource::~FaviconSource() { 21 FaviconSource::~FaviconSource() {
19 } 22 }
20 23
21 void FaviconSource::StartDataRequest(const std::string& path, 24 void FaviconSource::StartDataRequest(const std::string& path,
22 bool is_off_the_record, 25 bool is_off_the_record,
23 int request_id) { 26 int request_id) {
24 FaviconService* favicon_service = 27 FaviconService* favicon_service =
25 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 28 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
26 if (favicon_service) { 29 if (favicon_service) {
27 FaviconService::Handle handle; 30 FaviconService::Handle handle;
28 if (path.empty()) { 31 if (path.empty()) {
29 SendDefaultResponse(request_id); 32 SendDefaultResponse(request_id);
30 return; 33 return;
31 } 34 }
32 35
33 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") { 36 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") {
37 // TODO : Change GetFavicon to support combination of IconType.
34 handle = favicon_service->GetFavicon( 38 handle = favicon_service->GetFavicon(
35 GURL(path.substr(8)), 39 GURL(path.substr(8)),
36 history::FAVICON, 40 history::FAVICON,
37 &cancelable_consumer_, 41 &cancelable_consumer_,
38 NewCallback(this, &FaviconSource::OnFaviconDataAvailable)); 42 NewCallback(this, &FaviconSource::OnFaviconDataAvailable));
39 } else { 43 } else {
40 handle = favicon_service->GetFaviconForURL( 44 handle = favicon_service->GetFaviconForURL(
41 GURL(path), 45 GURL(path),
42 history::FAVICON, 46 icon_types_,
43 &cancelable_consumer_, 47 &cancelable_consumer_,
44 NewCallback(this, &FaviconSource::OnFaviconDataAvailable)); 48 NewCallback(this, &FaviconSource::OnFaviconDataAvailable));
45 } 49 }
46 // Attach the ChromeURLDataManager request ID to the history request. 50 // Attach the ChromeURLDataManager request ID to the history request.
47 cancelable_consumer_.SetClientData(favicon_service, handle, request_id); 51 cancelable_consumer_.SetClientData(favicon_service, handle, request_id);
48 } else { 52 } else {
49 SendResponse(request_id, NULL); 53 SendResponse(request_id, NULL);
50 } 54 }
51 } 55 }
52 56
(...skipping 27 matching lines...) Expand all
80 84
81 void FaviconSource::SendDefaultResponse(int request_id) { 85 void FaviconSource::SendDefaultResponse(int request_id) {
82 if (!default_favicon_.get()) { 86 if (!default_favicon_.get()) {
83 default_favicon_ = 87 default_favicon_ =
84 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 88 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
85 IDR_DEFAULT_FAVICON); 89 IDR_DEFAULT_FAVICON);
86 } 90 }
87 91
88 SendResponse(request_id, default_favicon_); 92 SendResponse(request_id, default_favicon_);
89 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698