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

Unified Diff: chrome/browser/ui/webui/fallback_icon_source.cc

Issue 996253002: [Fallback Icons] Refactor FallbackIconService to be a BrowserContext-level singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Making FallbackIconSource take FallbackIconService directly. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/fallback_icon_source.cc
diff --git a/chrome/browser/ui/webui/fallback_icon_source.cc b/chrome/browser/ui/webui/fallback_icon_source.cc
index 78eae81ba79ec1e8721db6c977891c3795402c98..7fa185f5b1abae47353af71fd3fdc5a0d0b6cb45 100644
--- a/chrome/browser/ui/webui/fallback_icon_source.cc
+++ b/chrome/browser/ui/webui/fallback_icon_source.cc
@@ -8,25 +8,19 @@
#include <vector>
#include "base/memory/ref_counted_memory.h"
+#include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h"
#include "chrome/browser/search/instant_io_context.h"
#include "chrome/common/favicon/fallback_icon_url_parser.h"
#include "chrome/common/url_constants.h"
-#include "grit/platform_locale_settings.h"
+#include "components/favicon_base/fallback_icon_service.h"
+#include "components/keyed_service/core/service_access_type.h"
#include "net/url_request/url_request.h"
-#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/favicon_size.h"
-FallbackIconSource::FallbackIconSource() {
- std::vector<std::string> font_list;
-#if defined(OS_CHROMEOS)
- font_list.push_back("Noto Sans");
-#elif defined(OS_IOS)
- font_list.push_back("Helvetica Neue");
-#else
- font_list.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY));
-#endif
- fallback_icon_service_.reset(
- new favicon_base::FallbackIconService(font_list));
+FallbackIconSource::FallbackIconSource(
+ favicon_base::FallbackIconService* fallback_icon_service)
+ : fallback_icon_service_(fallback_icon_service) {
+ DCHECK(fallback_icon_service_);
}
FallbackIconSource::~FallbackIconSource() {
@@ -48,11 +42,8 @@ void FallbackIconSource::StartDataRequest(
return;
}
- GURL url(parsed.url());
- std::vector<unsigned char> bitmap_data =
- fallback_icon_service_->RenderFallbackIconBitmap(
- url, parsed.size_in_pixels(), parsed.style());
- callback.Run(base::RefCountedBytes::TakeVector(&bitmap_data));
+ SendFallbackIconHelper(
+ parsed.url(), parsed.size_in_pixels(), parsed.style(), callback);
}
std::string FallbackIconSource::GetMimeType(const std::string&) const {
@@ -74,10 +65,19 @@ bool FallbackIconSource::ShouldServiceRequest(
return URLDataSource::ShouldServiceRequest(request);
}
-void FallbackIconSource::SendDefaultResponse(
+void FallbackIconSource::SendFallbackIconHelper(
+ const GURL& url,
+ int size_in_pixels,
+ const favicon_base::FallbackIconStyle& style,
const content::URLDataSource::GotDataCallback& callback) {
std::vector<unsigned char> bitmap_data =
fallback_icon_service_->RenderFallbackIconBitmap(
- GURL(), gfx::kFaviconSize, favicon_base::FallbackIconStyle());
+ url, size_in_pixels, style);
callback.Run(base::RefCountedBytes::TakeVector(&bitmap_data));
}
+
+void FallbackIconSource::SendDefaultResponse(
+ const content::URLDataSource::GotDataCallback& callback) {
+ favicon_base::FallbackIconStyle default_style;
+ SendFallbackIconHelper(GURL(), gfx::kFaviconSize, default_style, callback);
+}

Powered by Google App Engine
This is Rietveld 408576698