Commit ced2f174 authored by huangs's avatar huangs Committed by Commit bot

[Icons NTP] Refactoring: Moving FallbackIconService to components\favicon\core

The class used to be in components\favicon_base. The DEP changes arise
due to movement of fallback icon drawing code.

BUG=467712

Review URL: https://codereview.chromium.org/1032683002

Cr-Commit-Position: refs/heads/master@{#322157}
parent 28307d55
...@@ -26,8 +26,7 @@ FallbackIconSource::FallbackIconSource() { ...@@ -26,8 +26,7 @@ FallbackIconSource::FallbackIconSource() {
#else #else
font_list.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY)); font_list.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY));
#endif #endif
fallback_icon_service_.reset( fallback_icon_service_.reset(new FallbackIconService(font_list));
new favicon_base::FallbackIconService(font_list));
} }
FallbackIconSource::~FallbackIconSource() { FallbackIconSource::~FallbackIconSource() {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_ #define CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "components/favicon_base/fallback_icon_service.h" #include "components/favicon/core/fallback_icon_service.h"
#include "content/public/browser/url_data_source.h" #include "content/public/browser/url_data_source.h"
// FallbackIconSource services explicit chrome:// requests for fallback icons. // FallbackIconSource services explicit chrome:// requests for fallback icons.
...@@ -61,7 +61,7 @@ class FallbackIconSource : public content::URLDataSource { ...@@ -61,7 +61,7 @@ class FallbackIconSource : public content::URLDataSource {
void SendDefaultResponse( void SendDefaultResponse(
const content::URLDataSource::GotDataCallback& callback); const content::URLDataSource::GotDataCallback& callback);
scoped_ptr<favicon_base::FallbackIconService> fallback_icon_service_; scoped_ptr<FallbackIconService> fallback_icon_service_;
DISALLOW_COPY_AND_ASSIGN(FallbackIconSource); DISALLOW_COPY_AND_ASSIGN(FallbackIconSource);
}; };
......
...@@ -51,8 +51,7 @@ LargeIconSource::LargeIconSource(Profile* profile) : profile_(profile) { ...@@ -51,8 +51,7 @@ LargeIconSource::LargeIconSource(Profile* profile) : profile_(profile) {
#else #else
font_list.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY)); font_list.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY));
#endif #endif
fallback_icon_service_.reset( fallback_icon_service_.reset(new FallbackIconService(font_list));
new favicon_base::FallbackIconService(font_list));
} }
LargeIconSource::~LargeIconSource() { LargeIconSource::~LargeIconSource() {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/task/cancelable_task_tracker.h" #include "base/task/cancelable_task_tracker.h"
#include "components/favicon_base/fallback_icon_service.h" #include "components/favicon/core/fallback_icon_service.h"
#include "components/favicon_base/favicon_types.h" #include "components/favicon_base/favicon_types.h"
#include "content/public/browser/url_data_source.h" #include "content/public/browser/url_data_source.h"
...@@ -73,7 +73,7 @@ class LargeIconSource : public content::URLDataSource { ...@@ -73,7 +73,7 @@ class LargeIconSource : public content::URLDataSource {
base::CancelableTaskTracker cancelable_task_tracker_; base::CancelableTaskTracker cancelable_task_tracker_;
scoped_ptr<favicon_base::FallbackIconService> fallback_icon_service_; scoped_ptr<FallbackIconService> fallback_icon_service_;
DISALLOW_COPY_AND_ASSIGN(LargeIconSource); DISALLOW_COPY_AND_ASSIGN(LargeIconSource);
}; };
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
], ],
'sources': [ 'sources': [
# Note: sources list duplicated in GN build. # Note: sources list duplicated in GN build.
'favicon/core/fallback_icon_service.cc',
'favicon/core/fallback_icon_service.h',
'favicon/core/favicon_client.h', 'favicon/core/favicon_client.h',
'favicon/core/favicon_driver.h', 'favicon/core/favicon_driver.h',
'favicon/core/favicon_handler.cc', 'favicon/core/favicon_handler.cc',
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
static_library("core") { static_library("core") {
sources = [ sources = [
"fallback_icon_service.cc",
"fallback_icon_service.h",
"favicon_client.h", "favicon_client.h",
"favicon_driver.h", "favicon_driver.h",
"favicon_handler.cc", "favicon_handler.cc",
......
...@@ -2,6 +2,9 @@ include_rules = [ ...@@ -2,6 +2,9 @@ include_rules = [
"+components/bookmarks/browser", "+components/bookmarks/browser",
"+components/history/core/browser", "+components/history/core/browser",
"+components/keyed_service/core", "+components/keyed_service/core",
"+net/base/registry_controlled_domains/registry_controlled_domain.h",
"+skia", "+skia",
"+third_party/skia", "+third_party/skia",
"+third_party/skia/include",
"+ui/gfx",
] ]
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/favicon_base/fallback_icon_service.h" #include "components/favicon/core/fallback_icon_service.h"
#include <algorithm> #include <algorithm>
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace favicon_base {
namespace { namespace {
// Arbitrary maximum icon size, can be reasonably increased if needed. // Arbitrary maximum icon size, can be reasonably increased if needed.
...@@ -48,7 +46,7 @@ FallbackIconService::~FallbackIconService() { ...@@ -48,7 +46,7 @@ FallbackIconService::~FallbackIconService() {
std::vector<unsigned char> FallbackIconService::RenderFallbackIconBitmap( std::vector<unsigned char> FallbackIconService::RenderFallbackIconBitmap(
const GURL& icon_url, const GURL& icon_url,
int size, int size,
const FallbackIconStyle& style) { const favicon_base::FallbackIconStyle& style) {
int size_to_use = std::min(kMaxFallbackFaviconSize, size); int size_to_use = std::min(kMaxFallbackFaviconSize, size);
gfx::Canvas canvas(gfx::Size(size_to_use, size_to_use), 1.0f, false); gfx::Canvas canvas(gfx::Size(size_to_use, size_to_use), 1.0f, false);
DrawFallbackIcon(icon_url, size_to_use, style, &canvas); DrawFallbackIcon(icon_url, size_to_use, style, &canvas);
...@@ -61,10 +59,11 @@ std::vector<unsigned char> FallbackIconService::RenderFallbackIconBitmap( ...@@ -61,10 +59,11 @@ std::vector<unsigned char> FallbackIconService::RenderFallbackIconBitmap(
return bitmap_data; return bitmap_data;
} }
void FallbackIconService::DrawFallbackIcon(const GURL& icon_url, void FallbackIconService::DrawFallbackIcon(
int size, const GURL& icon_url,
const FallbackIconStyle& style, int size,
gfx::Canvas* canvas) { const favicon_base::FallbackIconStyle& style,
gfx::Canvas* canvas) {
const int kOffsetX = 0; const int kOffsetX = 0;
const int kOffsetY = 0; const int kOffsetY = 0;
SkPaint paint; SkPaint paint;
...@@ -93,5 +92,3 @@ void FallbackIconService::DrawFallbackIcon(const GURL& icon_url, ...@@ -93,5 +92,3 @@ void FallbackIconService::DrawFallbackIcon(const GURL& icon_url,
gfx::Rect(kOffsetX, kOffsetY, size, size), gfx::Rect(kOffsetX, kOffsetY, size, size),
gfx::Canvas::TEXT_ALIGN_CENTER); gfx::Canvas::TEXT_ALIGN_CENTER);
} }
} // namespace favicon_base
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_FAVICON_BASE_FALLBACK_ICON_SERVICE_H_ #ifndef COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_
#define COMPONENTS_FAVICON_BASE_FALLBACK_ICON_SERVICE_H_ #define COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -17,8 +17,8 @@ class Canvas; ...@@ -17,8 +17,8 @@ class Canvas;
} }
namespace favicon_base { namespace favicon_base {
struct FallbackIconStyle; struct FallbackIconStyle;
}
// A service to provide methods to render fallback favicons. // A service to provide methods to render fallback favicons.
class FallbackIconService { class FallbackIconService {
...@@ -31,14 +31,14 @@ class FallbackIconService { ...@@ -31,14 +31,14 @@ class FallbackIconService {
std::vector<unsigned char> RenderFallbackIconBitmap( std::vector<unsigned char> RenderFallbackIconBitmap(
const GURL& icon_url, const GURL& icon_url,
int size, int size,
const FallbackIconStyle& style); const favicon_base::FallbackIconStyle& style);
private: private:
// Renders a fallback icon on |canvas| at position (|x|, |y|). |size| is icon // Renders a fallback icon on |canvas| at position (|x|, |y|). |size| is icon
// width and height in pixels. // width and height in pixels.
void DrawFallbackIcon(const GURL& icon_url, void DrawFallbackIcon(const GURL& icon_url,
int size, int size,
const FallbackIconStyle& style, const favicon_base::FallbackIconStyle& style,
gfx::Canvas* canvas); gfx::Canvas* canvas);
std::vector<std::string> font_list_; std::vector<std::string> font_list_;
...@@ -46,6 +46,4 @@ class FallbackIconService { ...@@ -46,6 +46,4 @@ class FallbackIconService {
DISALLOW_COPY_AND_ASSIGN(FallbackIconService); DISALLOW_COPY_AND_ASSIGN(FallbackIconService);
}; };
} // namespace favicon_base #endif // COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_
#endif // COMPONENTS_FAVICON_BASE_FALLBACK_ICON_SERVICE_H_
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
'../url/url.gyp:url_lib', '../url/url.gyp:url_lib',
], ],
'sources': [ 'sources': [
'favicon_base/fallback_icon_service.cc',
'favicon_base/fallback_icon_service.h',
'favicon_base/fallback_icon_style.cc', 'favicon_base/fallback_icon_style.cc',
'favicon_base/fallback_icon_style.h', 'favicon_base/fallback_icon_style.h',
'favicon_base/favicon_callback.h', 'favicon_base/favicon_callback.h',
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
source_set("favicon_base") { source_set("favicon_base") {
sources = [ sources = [
"fallback_icon_service.cc",
"fallback_icon_service.h",
"fallback_icon_style.cc", "fallback_icon_style.cc",
"fallback_icon_style.h", "fallback_icon_style.h",
"favicon_callback.h", "favicon_callback.h",
......
include_rules = [ include_rules = [
"+net/base/registry_controlled_domains/registry_controlled_domain.h",
"+skia/ext", "+skia/ext",
"+third_party/skia/include", "+third_party/skia/include",
"+ui/base", "+ui/base",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment