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

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

Issue 10918065: Introduce structures to reduce the number of arguments in the FaviconService methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use copies rather than refs + fix nits. Created 8 years, 3 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/ui/webui/favicon_source.h" 5 #include "chrome/browser/ui/webui/favicon_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chrome/browser/favicon/favicon_service_factory.h" 9 #include "chrome/browser/favicon/favicon_service_factory.h"
10 #include "chrome/browser/history/top_sites.h" 10 #include "chrome/browser/history/top_sites.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 48 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
49 if (!favicon_service || path.empty()) { 49 if (!favicon_service || path.empty()) {
50 SendDefaultResponse(request_id); 50 SendDefaultResponse(request_id);
51 return; 51 return;
52 } 52 }
53 53
54 FaviconService::Handle handle; 54 FaviconService::Handle handle;
55 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") { 55 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") {
56 // TODO : Change GetFavicon to support combination of IconType. 56 // TODO : Change GetFavicon to support combination of IconType.
57 handle = favicon_service->GetRawFavicon( 57 handle = favicon_service->GetRawFavicon(
58 GURL(path.substr(8)), 58 FaviconService::FaviconParams(
59 history::FAVICON, 59 GURL(path.substr(8)),
60 gfx::kFaviconSize, 60 history::FAVICON,
61 gfx::kFaviconSize,
62 &cancelable_consumer_),
61 ui::SCALE_FACTOR_100P, 63 ui::SCALE_FACTOR_100P,
62 &cancelable_consumer_,
63 base::Bind(&FaviconSource::OnFaviconDataAvailable, 64 base::Bind(&FaviconSource::OnFaviconDataAvailable,
64 base::Unretained(this))); 65 base::Unretained(this)));
65 } else { 66 } else {
66 GURL url; 67 GURL url;
67 68
68 if (path.size() > 5 && path.substr(0, 5) == "size/") { 69 if (path.size() > 5 && path.substr(0, 5) == "size/") {
69 size_t slash = path.find("/", 5); 70 size_t slash = path.find("/", 5);
70 std::string size = path.substr(5, slash - 5); 71 std::string size = path.substr(5, slash - 5);
71 int pixel_size = atoi(size.c_str()); 72 int pixel_size = atoi(size.c_str());
72 CHECK(pixel_size == 32 || pixel_size == 16) << 73 CHECK(pixel_size == 32 || pixel_size == 16) <<
(...skipping 29 matching lines...) Expand all
102 SendResponse(request_id, 103 SendResponse(request_id,
103 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 104 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
104 history::kPrepopulatedPages[i].favicon_id, 105 history::kPrepopulatedPages[i].favicon_id,
105 ui::SCALE_FACTOR_100P)); 106 ui::SCALE_FACTOR_100P));
106 return; 107 return;
107 } 108 }
108 } 109 }
109 110
110 // TODO(estade): fetch the requested size. 111 // TODO(estade): fetch the requested size.
111 handle = favicon_service->GetRawFaviconForURL( 112 handle = favicon_service->GetRawFaviconForURL(
112 profile_, 113 FaviconService::FaviconForURLParams(
113 url, 114 profile_,
114 icon_types_, 115 url,
115 gfx::kFaviconSize, 116 icon_types_,
117 gfx::kFaviconSize,
118 &cancelable_consumer_),
116 ui::SCALE_FACTOR_100P, 119 ui::SCALE_FACTOR_100P,
117 &cancelable_consumer_,
118 base::Bind(&FaviconSource::OnFaviconDataAvailable, 120 base::Bind(&FaviconSource::OnFaviconDataAvailable,
119 base::Unretained(this))); 121 base::Unretained(this)));
120 } 122 }
121 123
122 // Attach the ChromeURLDataManager request ID to the history request. 124 // Attach the ChromeURLDataManager request ID to the history request.
123 cancelable_consumer_.SetClientData(favicon_service, handle, request_id); 125 cancelable_consumer_.SetClientData(favicon_service, handle, request_id);
124 } 126 }
125 127
126 std::string FaviconSource::GetMimeType(const std::string&) const { 128 std::string FaviconSource::GetMimeType(const std::string&) const {
127 // We need to explicitly return a mime type, otherwise if the user tries to 129 // We need to explicitly return a mime type, otherwise if the user tries to
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 default_favicon_ = 167 default_favicon_ =
166 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 168 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
167 IDR_DEFAULT_FAVICON, ui::SCALE_FACTOR_100P); 169 IDR_DEFAULT_FAVICON, ui::SCALE_FACTOR_100P);
168 } 170 }
169 bytes = default_favicon_; 171 bytes = default_favicon_;
170 } 172 }
171 request_size_map_.erase(request_id); 173 request_size_map_.erase(request_id);
172 174
173 SendResponse(request_id, bytes); 175 SendResponse(request_id, bytes);
174 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698