OLD | NEW |
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/history/top_sites.h" | 9 #include "chrome/browser/history/top_sites.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 bool FaviconSource::ShouldReplaceExistingSource() const { | 125 bool FaviconSource::ShouldReplaceExistingSource() const { |
126 // Leave the existing DataSource in place, otherwise we'll drop any pending | 126 // Leave the existing DataSource in place, otherwise we'll drop any pending |
127 // requests on the floor. | 127 // requests on the floor. |
128 return false; | 128 return false; |
129 } | 129 } |
130 | 130 |
131 void FaviconSource::OnFaviconDataAvailable( | 131 void FaviconSource::OnFaviconDataAvailable( |
132 FaviconService::Handle request_handle, | 132 FaviconService::Handle request_handle, |
133 history::FaviconData favicon) { | 133 history::FaviconData favicon_data, |
| 134 std::vector<GURL> icon_urls_in_db) { |
134 FaviconService* favicon_service = | 135 FaviconService* favicon_service = |
135 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 136 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
136 int request_id = cancelable_consumer_.GetClientData(favicon_service, | 137 int request_id = cancelable_consumer_.GetClientData(favicon_service, |
137 request_handle); | 138 request_handle); |
138 | 139 |
139 if (favicon.is_valid()) { | 140 if (favicon_data.has_valid_bitmaps()) { |
140 // Forward the data along to the networking system. | 141 // Forward the data along to the networking system. |
141 SendResponse(request_id, favicon.image_data); | 142 SendResponse(request_id, favicon_data.first_bitmap()); |
142 } else { | 143 } else { |
143 SendDefaultResponse(request_id); | 144 SendDefaultResponse(request_id); |
144 } | 145 } |
145 } | 146 } |
146 | 147 |
147 void FaviconSource::SendDefaultResponse(int request_id) { | 148 void FaviconSource::SendDefaultResponse(int request_id) { |
148 base::RefCountedMemory* bytes = NULL; | 149 base::RefCountedMemory* bytes = NULL; |
149 if (request_size_map_[request_id] == 32) { | 150 if (request_size_map_[request_id] == 32) { |
150 if (!default_favicon_large_.get()) { | 151 if (!default_favicon_large_.get()) { |
151 default_favicon_large_ = | 152 default_favicon_large_ = |
152 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 153 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
153 IDR_DEFAULT_LARGE_FAVICON, ui::SCALE_FACTOR_100P); | 154 IDR_DEFAULT_LARGE_FAVICON, ui::SCALE_FACTOR_100P); |
154 } | 155 } |
155 bytes = default_favicon_large_; | 156 bytes = default_favicon_large_; |
156 } else { | 157 } else { |
157 if (!default_favicon_.get()) { | 158 if (!default_favicon_.get()) { |
158 default_favicon_ = | 159 default_favicon_ = |
159 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 160 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
160 IDR_DEFAULT_FAVICON, ui::SCALE_FACTOR_100P); | 161 IDR_DEFAULT_FAVICON, ui::SCALE_FACTOR_100P); |
161 } | 162 } |
162 bytes = default_favicon_; | 163 bytes = default_favicon_; |
163 } | 164 } |
164 request_size_map_.erase(request_id); | 165 request_size_map_.erase(request_id); |
165 | 166 |
166 SendResponse(request_id, bytes); | 167 SendResponse(request_id, bytes); |
167 } | 168 } |
OLD | NEW |