| Index: chrome/browser/ui/webui/favicon_source.cc
|
| ===================================================================
|
| --- chrome/browser/ui/webui/favicon_source.cc (revision 176942)
|
| +++ chrome/browser/ui/webui/favicon_source.cc (working copy)
|
| @@ -9,7 +9,6 @@
|
| #include "chrome/browser/favicon/favicon_service_factory.h"
|
| #include "chrome/browser/history/top_sites.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| -#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
|
| #include "chrome/browser/ui/webui/web_ui_util.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "grit/locale_settings.h"
|
| @@ -18,6 +17,25 @@
|
| #include "ui/base/layout.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
|
|
| +FaviconSource::IconRequest::IconRequest()
|
| + : size_in_dip(gfx::kFaviconSize),
|
| + scale_factor(ui::SCALE_FACTOR_NONE) {
|
| +}
|
| +
|
| +FaviconSource::IconRequest::IconRequest(
|
| + const content::URLDataSource::GotDataCallback& cb,
|
| + const std::string& path,
|
| + int size,
|
| + ui::ScaleFactor scale)
|
| + : callback(cb),
|
| + request_path(path),
|
| + size_in_dip(size),
|
| + scale_factor(scale) {
|
| +}
|
| +
|
| +FaviconSource::IconRequest::~IconRequest() {
|
| +}
|
| +
|
| FaviconSource::FaviconSource(Profile* profile, IconType type)
|
| : profile_(profile->GetOriginalProfile()),
|
| icon_types_(type == FAVICON ? history::FAVICON :
|
| @@ -33,13 +51,14 @@
|
| chrome::kChromeUIFaviconHost : chrome::kChromeUITouchIconHost;
|
| }
|
|
|
| -void FaviconSource::StartDataRequest(const std::string& path,
|
| - bool is_incognito,
|
| - int request_id) {
|
| +void FaviconSource::StartDataRequest(
|
| + const std::string& path,
|
| + bool is_incognito,
|
| + const content::URLDataSource::GotDataCallback& callback) {
|
| FaviconService* favicon_service =
|
| FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
|
| if (!favicon_service || path.empty()) {
|
| - SendDefaultResponse(IconRequest(request_id,
|
| + SendDefaultResponse(IconRequest(callback,
|
| "",
|
| 16,
|
| ui::SCALE_FACTOR_100P));
|
| @@ -68,7 +87,7 @@
|
| scale_factor,
|
| base::Bind(&FaviconSource::OnFaviconDataAvailable,
|
| base::Unretained(this),
|
| - IconRequest(request_id,
|
| + IconRequest(callback,
|
| path.substr(prefix_length),
|
| size_in_dip,
|
| scale_factor)),
|
| @@ -115,7 +134,7 @@
|
| for (size_t i = 0; i < arraysize(history::kPrepopulatedPages); i++) {
|
| if (url.spec() ==
|
| l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) {
|
| - url_data_source()->SendResponse(request_id,
|
| + callback.Run(
|
| ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
|
| history::kPrepopulatedPages[i].favicon_id,
|
| scale_factor));
|
| @@ -129,7 +148,7 @@
|
| scale_factor,
|
| base::Bind(&FaviconSource::OnFaviconDataAvailable,
|
| base::Unretained(this),
|
| - IconRequest(request_id,
|
| + IconRequest(callback,
|
| url.spec(),
|
| size_in_dip,
|
| scale_factor)),
|
| @@ -160,8 +179,7 @@
|
| const history::FaviconBitmapResult& bitmap_result) {
|
| if (bitmap_result.is_valid()) {
|
| // Forward the data along to the networking system.
|
| - url_data_source()->SendResponse(
|
| - request.request_id, bitmap_result.bitmap_data);
|
| + request.callback.Run(bitmap_result.bitmap_data);
|
| } else if (!HandleMissingResource(request)) {
|
| SendDefaultResponse(request);
|
| }
|
| @@ -193,5 +211,5 @@
|
| default_favicons_[favicon_index] = default_favicon;
|
| }
|
|
|
| - url_data_source()->SendResponse(icon_request.request_id, default_favicon);
|
| + icon_request.callback.Run(default_favicon);
|
| }
|
|
|