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

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

Issue 6651014: Applied the IconType. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 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"
(...skipping 15 matching lines...) Expand all
26 if (favicon_service) { 26 if (favicon_service) {
27 FaviconService::Handle handle; 27 FaviconService::Handle handle;
28 if (path.empty()) { 28 if (path.empty()) {
29 SendDefaultResponse(request_id); 29 SendDefaultResponse(request_id);
30 return; 30 return;
31 } 31 }
32 32
33 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") { 33 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") {
34 handle = favicon_service->GetFavicon( 34 handle = favicon_service->GetFavicon(
35 GURL(path.substr(8)), 35 GURL(path.substr(8)),
36 history::FAV_ICON,
36 &cancelable_consumer_, 37 &cancelable_consumer_,
37 NewCallback(this, &FavIconSource::OnFavIconDataAvailable)); 38 NewCallback(this, &FavIconSource::OnFavIconDataAvailable));
38 } else { 39 } else {
39 handle = favicon_service->GetFaviconForURL( 40 handle = favicon_service->GetFaviconForURL(
40 GURL(path), 41 GURL(path),
42 history::FAV_ICON,
41 &cancelable_consumer_, 43 &cancelable_consumer_,
42 NewCallback(this, &FavIconSource::OnFavIconDataAvailable)); 44 NewCallback(this, &FavIconSource::OnFavIconDataAvailable));
43 } 45 }
44 // Attach the ChromeURLDataManager request ID to the history request. 46 // Attach the ChromeURLDataManager request ID to the history request.
45 cancelable_consumer_.SetClientData(favicon_service, handle, request_id); 47 cancelable_consumer_.SetClientData(favicon_service, handle, request_id);
46 } else { 48 } else {
47 SendResponse(request_id, NULL); 49 SendResponse(request_id, NULL);
48 } 50 }
49 } 51 }
50 52
51 std::string FavIconSource::GetMimeType(const std::string&) const { 53 std::string FavIconSource::GetMimeType(const std::string&) const {
52 // We need to explicitly return a mime type, otherwise if the user tries to 54 // We need to explicitly return a mime type, otherwise if the user tries to
53 // drag the image they get no extension. 55 // drag the image they get no extension.
54 return "image/png"; 56 return "image/png";
55 } 57 }
56 58
57 bool FavIconSource::ShouldReplaceExistingSource() const { 59 bool FavIconSource::ShouldReplaceExistingSource() const {
58 // Leave the existing DataSource in place, otherwise we'll drop any pending 60 // Leave the existing DataSource in place, otherwise we'll drop any pending
59 // requests on the floor. 61 // requests on the floor.
60 return false; 62 return false;
61 } 63 }
62 64
63 void FavIconSource::OnFavIconDataAvailable( 65 void FavIconSource::OnFavIconDataAvailable(
64 FaviconService::Handle request_handle, 66 FaviconService::Handle request_handle,
65 bool know_favicon, 67 bool know_favicon,
66 scoped_refptr<RefCountedMemory> data, 68 scoped_refptr<RefCountedMemory> data,
67 bool expired, 69 bool expired,
68 GURL icon_url) { 70 GURL icon_url,
71 history::IconType) {
sky 2011/03/09 21:41:08 name
michaelbai 2011/03/09 23:11:45 Done.
69 FaviconService* favicon_service = 72 FaviconService* favicon_service =
70 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 73 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
71 int request_id = cancelable_consumer_.GetClientData(favicon_service, 74 int request_id = cancelable_consumer_.GetClientData(favicon_service,
72 request_handle); 75 request_handle);
73 76
74 if (know_favicon && data.get() && data->size()) { 77 if (know_favicon && data.get() && data->size()) {
75 // Forward the data along to the networking system. 78 // Forward the data along to the networking system.
76 SendResponse(request_id, data); 79 SendResponse(request_id, data);
77 } else { 80 } else {
78 SendDefaultResponse(request_id); 81 SendDefaultResponse(request_id);
79 } 82 }
80 } 83 }
81 84
82 void FavIconSource::SendDefaultResponse(int request_id) { 85 void FavIconSource::SendDefaultResponse(int request_id) {
83 if (!default_favicon_.get()) { 86 if (!default_favicon_.get()) {
84 default_favicon_ = 87 default_favicon_ =
85 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 88 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
86 IDR_DEFAULT_FAVICON); 89 IDR_DEFAULT_FAVICON);
87 } 90 }
88 91
89 SendResponse(request_id, default_favicon_); 92 SendResponse(request_id, default_favicon_);
90 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698