Commit 1169f4bc authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Cleanup: Remove thumbnail retargeting code

This never launched and has long been abandoned.
This CL removes the code. Followups will remove all the wiring and
indirection in ThumbnailTabHelper and ThumbnailService.

Bug: 735905
Change-Id: Ic6d125ea5c5020dcf3f484487257f9a221e59868
Reviewed-on: https://chromium-review.googlesource.com/544960
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481834}
parent 437702b5
......@@ -1346,10 +1346,6 @@ split_static_library("browser") {
"task_profiler/task_profiler_data_serializer.h",
"themes/theme_service_win.cc",
"themes/theme_service_win.h",
"thumbnails/content_analysis.cc",
"thumbnails/content_analysis.h",
"thumbnails/content_based_thumbnailing_algorithm.cc",
"thumbnails/content_based_thumbnailing_algorithm.h",
"thumbnails/simple_thumbnail_crop.cc",
"thumbnails/simple_thumbnail_crop.h",
"thumbnails/thumbnail_list_source.cc",
......
This diff is collapsed.
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_THUMBNAILS_CONTENT_ANALYSIS_H_
#define CHROME_BROWSER_THUMBNAILS_CONTENT_ANALYSIS_H_
#include <vector>
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
class SkBitmap;
namespace thumbnailing_utils {
// Compute in-place gaussian gradient magnitude of |input_bitmap| with sigma
// |kernel_sigma|. |input_bitmap| is requried to be of SkBitmap::kA8_Config
// type. The routine computes first-order gaussian derivative on a
// gaussian-smoothed image. Beware, this is fairly slow since kernel size is
// 4 * kernel_sigma + 1.
void ApplyGaussianGradientMagnitudeFilter(SkBitmap* input_bitmap,
float kernel_sigma);
// Accumulates vertical and horizontal sum of pixel values from a subsection of
// |input_bitmap| defined by |image_area|. The image is required to be of
// SkBitmap::kA8_Config type.
// If non-empty |target_size| is given, the routine will use it to process the
// profiles with closing operator sized to eliminate gaps which would be smaller
// than 1 pixel after rescaling to |target_size|.
// If |apply_log| is true, logarithm of counts are used for morhology (and
// returned).
void ExtractImageProfileInformation(const SkBitmap& input_bitmap,
const gfx::Rect& image_area,
const gfx::Size& target_size,
bool apply_log,
std::vector<float>* rows,
std::vector<float>* columns);
// Compute a threshold value separating background (low) from signal (high)
// areas in the |input| profile.
float AutoSegmentPeaks(const std::vector<float>& input);
// Compute and return a workable (not too distorted, not bigger than the image)
// target size for retargeting in ConstrainedProfileSegmentation. |target_size|
// is the desired image size (defines aspect ratio and minimal image size) while
// |computed_size| is the size of a result of unconstrained segmentation.
// This routine makes very little sense outside ConstrainedProfileSegmentation
// and is exposed only for unit tests (it is somehow complicated).
gfx::Size AdjustClippingSizeToAspectRatio(const gfx::Size& target_size,
const gfx::Size& image_size,
const gfx::Size& computed_size);
// Compute thresholding guides |included_rows| and |included_columns| by
// segmenting 1-d profiles |row_profile| and |column_profile|. The routine will
// attempt to keep the image which would result from using these guides as close
// to the desired aspect ratio (given by |target_size|) as reasonable.
void ConstrainedProfileSegmentation(const std::vector<float>& row_profile,
const std::vector<float>& column_profile,
const gfx::Size& target_size,
std::vector<bool>* included_rows,
std::vector<bool>* included_columns);
// Shrinks the source |bitmap| by removing rows and columns where |rows| and
// |columns| are false, respectively. The function returns a new bitmap if the
// shrinking can be performed and an empty instance otherwise.
SkBitmap ComputeDecimatedImage(const SkBitmap& bitmap,
const std::vector<bool>& rows,
const std::vector<bool>& columns);
// Creates a new bitmap which contains only 'interesting' areas of
// |source_bitmap|. The |target_size| is used to estimate some computation
// parameters, but the resulting bitmap will not necessarily be of that size.
// |kernel_sigma| defines the degree of image smoothing in gradient computation.
// For a natural-sized (not shrunk) screenshot at 96 DPI and regular font size
// 5.0 was determined to be a good value.
SkBitmap CreateRetargetedThumbnailImage(const SkBitmap& source_bitmap,
const gfx::Size& target_size,
float kernel_sigma);
} // namespace thumbnailing_utils
#endif // CHROME_BROWSER_THUMBNAILS_CONTENT_ANALYSIS_H_
This diff is collapsed.
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h"
#include <stddef.h>
#include "base/metrics/histogram_macros.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/thumbnails/content_analysis.h"
#include "chrome/browser/thumbnails/simple_thumbnail_crop.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/scrollbar_size.h"
#include "ui/gfx/skbitmap_operations.h"
#include "ui/gfx/skia_util.h"
namespace {
const char kThumbnailHistogramName[] = "Thumbnail.RetargetMS";
const char kFailureHistogramName[] = "Thumbnail.FailedRetargetMS";
const float kScoreBoostFromSuccessfulRetargeting = 1.1f;
void CallbackInvocationAdapter(
const thumbnails::ThumbnailingAlgorithm::ConsumerCallback& callback,
scoped_refptr<thumbnails::ThumbnailingContext> context,
const SkBitmap& source_bitmap) {
callback.Run(*context.get(), source_bitmap);
}
} // namespace
namespace thumbnails {
using content::BrowserThread;
ContentBasedThumbnailingAlgorithm::ContentBasedThumbnailingAlgorithm(
const gfx::Size& target_size)
: target_size_(target_size) {
DCHECK(!target_size.IsEmpty());
}
ClipResult ContentBasedThumbnailingAlgorithm::GetCanvasCopyInfo(
const gfx::Size& source_size,
ui::ScaleFactor scale_factor,
gfx::Rect* clipping_rect,
gfx::Size* copy_size) const {
DCHECK(!source_size.IsEmpty());
gfx::Size copy_thumbnail_size =
SimpleThumbnailCrop::GetCopySizeForThumbnail(scale_factor, target_size_);
ClipResult clipping_method = thumbnails::CLIP_RESULT_NOT_CLIPPED;
*clipping_rect = GetClippingRect(source_size, copy_thumbnail_size, copy_size,
&clipping_method);
return clipping_method;
}
void ContentBasedThumbnailingAlgorithm::ProcessBitmap(
scoped_refptr<ThumbnailingContext> context,
const ConsumerCallback& callback,
const SkBitmap& bitmap) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(context.get());
if (bitmap.isNull() || bitmap.empty())
return;
gfx::Size target_thumbnail_size =
SimpleThumbnailCrop::ComputeTargetSizeAtMaximumScale(target_size_);
SkBitmap source_bitmap =
PrepareSourceBitmap(bitmap, target_thumbnail_size, context.get());
// If the source is same (or smaller) than the target, just return it as
// the final result. Otherwise, send the shrinking task to the blocking
// thread pool.
if (source_bitmap.width() <= target_thumbnail_size.width() ||
source_bitmap.height() <= target_thumbnail_size.height()) {
context->score.boring_score =
color_utils::CalculateBoringScore(source_bitmap);
context->score.good_clipping =
(context->clip_result == CLIP_RESULT_WIDER_THAN_TALL ||
context->clip_result == CLIP_RESULT_TALLER_THAN_WIDE ||
context->clip_result == CLIP_RESULT_NOT_CLIPPED ||
context->clip_result == CLIP_RESULT_SOURCE_SAME_AS_TARGET);
callback.Run(*context.get(), source_bitmap);
return;
}
base::PostTaskWithTraits(
FROM_HERE,
{base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
base::Bind(&CreateRetargetedThumbnail, source_bitmap,
target_thumbnail_size, context, callback));
}
// static
SkBitmap ContentBasedThumbnailingAlgorithm::PrepareSourceBitmap(
const SkBitmap& received_bitmap,
const gfx::Size& thumbnail_size,
ThumbnailingContext* context) {
gfx::Size resize_target;
SkBitmap clipped_bitmap;
if (context->clip_result == CLIP_RESULT_UNPROCESSED) {
// This case will require extracting a fragment from the retrieved bitmap.
int scrollbar_size = gfx::scrollbar_size();
gfx::Size scrollbarless(
std::max(1, received_bitmap.width() - scrollbar_size),
std::max(1, received_bitmap.height() - scrollbar_size));
gfx::Rect clipping_rect = GetClippingRect(
scrollbarless,
thumbnail_size,
&resize_target,
&context->clip_result);
received_bitmap.extractSubset(&clipped_bitmap,
gfx::RectToSkIRect(clipping_rect));
} else {
// This means that the source bitmap has been requested and at least
// clipped. Upstream code in same cases seems opportunistic and it may
// not perform actual resizing if copying with resize is not supported.
// In this case we will resize to the orignally requested copy size.
resize_target = context->requested_copy_size;
clipped_bitmap = received_bitmap;
}
SkBitmap result_bitmap = SkBitmapOperations::DownsampleByTwoUntilSize(
clipped_bitmap, resize_target.width(), resize_target.height());
return result_bitmap;
}
// static
void ContentBasedThumbnailingAlgorithm::CreateRetargetedThumbnail(
const SkBitmap& source_bitmap,
const gfx::Size& thumbnail_size,
scoped_refptr<ThumbnailingContext> context,
const ConsumerCallback& callback) {
base::TimeTicks begin_compute_thumbnail = base::TimeTicks::Now();
float kernel_sigma =
context->clip_result == CLIP_RESULT_SOURCE_SAME_AS_TARGET ? 5.0f : 2.5f;
SkBitmap thumbnail = thumbnailing_utils::CreateRetargetedThumbnailImage(
source_bitmap, thumbnail_size, kernel_sigma);
bool processing_failed = thumbnail.empty();
if (processing_failed) {
// Log and apply the method very much like in SimpleThumbnailCrop (except
// that some clipping and copying is not required).
LOG(WARNING) << "CreateRetargetedThumbnailImage failed. "
<< "The thumbnail for " << context->url
<< " will be created the old-fashioned way.";
ClipResult clip_result;
gfx::Rect clipping_rect = SimpleThumbnailCrop::GetClippingRect(
gfx::Size(source_bitmap.width(), source_bitmap.height()),
thumbnail_size,
&clip_result);
source_bitmap.extractSubset(&thumbnail, gfx::RectToSkIRect(clipping_rect));
thumbnail = SkBitmapOperations::DownsampleByTwoUntilSize(
thumbnail, thumbnail_size.width(), thumbnail_size.height());
}
if (processing_failed) {
LOCAL_HISTOGRAM_TIMES(kFailureHistogramName,
base::TimeTicks::Now() - begin_compute_thumbnail);
} else {
LOCAL_HISTOGRAM_TIMES(kThumbnailHistogramName,
base::TimeTicks::Now() - begin_compute_thumbnail);
}
context->score.boring_score =
color_utils::CalculateBoringScore(source_bitmap);
if (!processing_failed)
context->score.boring_score *= kScoreBoostFromSuccessfulRetargeting;
context->score.good_clipping =
(context->clip_result == CLIP_RESULT_WIDER_THAN_TALL ||
context->clip_result == CLIP_RESULT_TALLER_THAN_WIDE ||
context->clip_result == CLIP_RESULT_NOT_CLIPPED ||
context->clip_result == CLIP_RESULT_SOURCE_SAME_AS_TARGET);
// Post the result (the bitmap) back to the callback.
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&CallbackInvocationAdapter, callback, context, thumbnail));
}
ContentBasedThumbnailingAlgorithm::~ContentBasedThumbnailingAlgorithm() {
}
// static
gfx::Rect ContentBasedThumbnailingAlgorithm::GetClippingRect(
const gfx::Size& source_size,
const gfx::Size& thumbnail_size,
gfx::Size* target_size,
ClipResult* clip_result) {
// Compute and return the clipping rectagle of the source image and the
// size of the target bitmap which will be used for the further processing.
// This function in 'general case' is trivial (don't clip, halve the source)
// but it is needed for handling edge cases (source smaller than the target
// thumbnail size).
DCHECK(target_size);
DCHECK(clip_result);
gfx::Rect clipping_rect;
if (source_size.width() < thumbnail_size.width() ||
source_size.height() < thumbnail_size.height()) {
clipping_rect = gfx::Rect(thumbnail_size);
*target_size = thumbnail_size;
*clip_result = CLIP_RESULT_SOURCE_IS_SMALLER;
} else if (source_size.width() < thumbnail_size.width() * 4 ||
source_size.height() < thumbnail_size.height() * 4) {
clipping_rect = gfx::Rect(source_size);
*target_size = source_size;
*clip_result = CLIP_RESULT_SOURCE_SAME_AS_TARGET;
} else {
clipping_rect = gfx::Rect(source_size);
target_size->SetSize(source_size.width() / 2, source_size.height() / 2);
*clip_result = CLIP_RESULT_NOT_CLIPPED;
}
return clipping_rect;
}
} // namespace thumbnails
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_
#define CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_
#include "base/macros.h"
#include "chrome/browser/thumbnails/thumbnailing_algorithm.h"
namespace thumbnails {
// Encapsulates a method of creating a thumbnail from a captured tab shot which
// attempts to preserve only relevant fragments of the original image.
// The algorithm detects areas of high activity at low resolution and discards
// rows and columns which do not intersect with these areas.
class ContentBasedThumbnailingAlgorithm : public ThumbnailingAlgorithm {
public:
explicit ContentBasedThumbnailingAlgorithm(const gfx::Size& target_size);
ClipResult GetCanvasCopyInfo(const gfx::Size& source_size,
ui::ScaleFactor scale_factor,
gfx::Rect* clipping_rect,
gfx::Size* copy_size) const override;
void ProcessBitmap(scoped_refptr<ThumbnailingContext> context,
const ConsumerCallback& callback,
const SkBitmap& bitmap) override;
// Prepares (clips to size, copies etc.) the bitmap passed to ProcessBitmap.
// Always returns a bitmap that can be properly refcounted.
// Extracted and exposed as a test seam.
static SkBitmap PrepareSourceBitmap(const SkBitmap& received_bitmap,
const gfx::Size& thumbnail_size,
ThumbnailingContext* context);
// The function processes |source_bitmap| into a thumbnail of |thumbnail_size|
// and passes the result into |callback| (on UI thread). |context| describes
// how the thumbnail is being created.
static void CreateRetargetedThumbnail(
const SkBitmap& source_bitmap,
const gfx::Size& thumbnail_size,
scoped_refptr<ThumbnailingContext> context,
const ConsumerCallback& callback);
protected:
~ContentBasedThumbnailingAlgorithm() override;
private:
static gfx::Rect GetClippingRect(const gfx::Size& source_size,
const gfx::Size& thumbnail_size,
gfx::Size* target_size,
ClipResult* clip_result);
const gfx::Size target_size_;
DISALLOW_COPY_AND_ASSIGN(ContentBasedThumbnailingAlgorithm);
};
} // namespace thumbnails
#endif // CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "chrome/browser/thumbnails/simple_thumbnail_crop.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "skia/ext/platform_canvas.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/scrollbar_size.h"
namespace thumbnails {
typedef testing::Test ContentBasedThumbnailingAlgorithmTest;
class ConsumerCallbackCatcher {
public:
ConsumerCallbackCatcher()
: called_back_(false), clip_result_(CLIP_RESULT_UNPROCESSED) {
}
void UiThreadCallback(const ThumbnailingContext& context,
const SkBitmap& bitmap) {
called_back_ = true;
captured_bitmap_ = bitmap;
clip_result_ = context.clip_result;
score_ = context.score;
}
bool called_back() const {
return called_back_;
}
const SkBitmap& captured_bitmap() const {
return captured_bitmap_;
}
ClipResult clip_result() const {
return clip_result_;
}
const ThumbnailScore& score() const {
return score_;
}
private:
SkBitmap captured_bitmap_;
bool called_back_;
ClipResult clip_result_;
ThumbnailScore score_;
DISALLOW_COPY_AND_ASSIGN(ConsumerCallbackCatcher);
};
TEST_F(ContentBasedThumbnailingAlgorithmTest, GetCanvasCopyInfo) {
// We will want to use the entirety of the image as the source. Usually,
// an image in its original size should be requested, except for reakky large
// canvas. In that case, image will be shrunk but wit aspect ratio preserved.
const gfx::Size thumbnail_size(312, 165);
scoped_refptr<ThumbnailingAlgorithm> algorithm(
new ContentBasedThumbnailingAlgorithm(thumbnail_size));
gfx::Rect clipping_rect;
gfx::Size target_size;
gfx::Size source_size(1000, 600);
ClipResult clip_result = algorithm->GetCanvasCopyInfo(
source_size, ui::SCALE_FACTOR_100P, &clipping_rect, &target_size);
EXPECT_EQ(CLIP_RESULT_SOURCE_SAME_AS_TARGET, clip_result);
EXPECT_EQ(source_size.ToString(), clipping_rect.size().ToString());
EXPECT_EQ(gfx::Point(0, 0).ToString(), clipping_rect.origin().ToString());
EXPECT_EQ(source_size, target_size);
source_size.SetSize(6000, 3000);
clip_result = algorithm->GetCanvasCopyInfo(
source_size, ui::SCALE_FACTOR_100P, &clipping_rect, &target_size);
EXPECT_EQ(CLIP_RESULT_NOT_CLIPPED, clip_result);
EXPECT_EQ(source_size.ToString(), clipping_rect.size().ToString());
EXPECT_EQ(gfx::Point(0, 0).ToString(), clipping_rect.origin().ToString());
EXPECT_LT(target_size.width(), source_size.width());
EXPECT_LT(target_size.height(), source_size.height());
EXPECT_NEAR(static_cast<float>(target_size.width()) / target_size.height(),
static_cast<float>(source_size.width()) / source_size.height(),
0.1f);
source_size.SetSize(300, 200);
clip_result = algorithm->GetCanvasCopyInfo(
source_size, ui::SCALE_FACTOR_100P, &clipping_rect, &target_size);
EXPECT_EQ(CLIP_RESULT_SOURCE_IS_SMALLER, clip_result);
EXPECT_EQ(clipping_rect.size().ToString(),
SimpleThumbnailCrop::GetCopySizeForThumbnail(
ui::SCALE_FACTOR_100P, thumbnail_size).ToString());
EXPECT_EQ(gfx::Point(0, 0).ToString(), clipping_rect.origin().ToString());
}
TEST_F(ContentBasedThumbnailingAlgorithmTest, PrepareSourceBitmap) {
const gfx::Size thumbnail_size(312, 165);
const gfx::Size copy_size(400, 200);
scoped_refptr<ThumbnailingContext> context(
ThumbnailingContext::CreateThumbnailingContextForTest());
context->requested_copy_size = copy_size;
// This calls for exercising two distinct paths: with prior clipping and
// without.
SkBitmap source;
source.allocN32Pixels(800, 600);
source.eraseARGB(255, 50, 150, 200);
SkBitmap result = ContentBasedThumbnailingAlgorithm::PrepareSourceBitmap(
source, thumbnail_size, context.get());
EXPECT_EQ(CLIP_RESULT_SOURCE_SAME_AS_TARGET, context->clip_result);
EXPECT_GE(result.width(), copy_size.width());
EXPECT_GE(result.height(), copy_size.height());
EXPECT_LT(result.width(), source.width());
EXPECT_LT(result.height(), source.height());
// The check below is a bit of a side effect: since the image was clipped
// by scrollbar_size, it cannot be shrunk and thus what we get below is
// true.
EXPECT_NEAR(result.width(), source.width(), gfx::scrollbar_size());
EXPECT_NEAR(result.height(), source.height(), gfx::scrollbar_size());
result = ContentBasedThumbnailingAlgorithm::PrepareSourceBitmap(
source, thumbnail_size, context.get());
EXPECT_EQ(CLIP_RESULT_SOURCE_SAME_AS_TARGET, context->clip_result);
EXPECT_GE(result.width(), copy_size.width());
EXPECT_GE(result.height(), copy_size.height());
EXPECT_LT(result.width(), source.width());
EXPECT_LT(result.height(), source.height());
}
TEST_F(ContentBasedThumbnailingAlgorithmTest, CreateRetargetedThumbnail) {
// This tests the invocation of the main thumbnail-making apparatus.
// The actual content is not really of concern here, just check the plumbing.
const gfx::Size image_size(1200, 800);
gfx::Canvas canvas(image_size, 1.0f, true);
// The image consists of vertical non-overlapping stripes 150 pixels wide.
canvas.FillRect(gfx::Rect(200, 200, 800, 400), SkColorSetRGB(255, 255, 255));
SkBitmap source = canvas.GetBitmap();
ConsumerCallbackCatcher catcher;
const gfx::Size thumbnail_size(432, 284);
scoped_refptr<ThumbnailingContext> context(
ThumbnailingContext::CreateThumbnailingContextForTest());
context->requested_copy_size = image_size;
context->clip_result = CLIP_RESULT_SOURCE_SAME_AS_TARGET;
content::TestBrowserThreadBundle test_browser_thread_bundle;
ContentBasedThumbnailingAlgorithm::CreateRetargetedThumbnail(
source,
thumbnail_size,
context,
base::Bind(&ConsumerCallbackCatcher::UiThreadCallback,
base::Unretained(&catcher)));
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(catcher.called_back());
EXPECT_TRUE(catcher.score().good_clipping);
EXPECT_FALSE(catcher.captured_bitmap().empty());
EXPECT_LT(catcher.captured_bitmap().width(), source.width());
EXPECT_LT(catcher.captured_bitmap().height(), source.height());
}
} // namespace thumbnails
......@@ -36,6 +36,7 @@ class ThumbnailService : public RefcountedKeyedService {
// process of creating a thumbnail from tab contents. The lifetime of these
// instances is limited to the act of processing a single tab image. They
// are permitted to hold the state of such process.
// TODO(treib): Return a scoped_refptr rather than raw pointer.
virtual ThumbnailingAlgorithm* GetThumbnailingAlgorithm() const = 0;
// Gets a thumbnail for a given page. Returns true iff we have the thumbnail.
......
......@@ -4,16 +4,12 @@
#include "chrome/browser/thumbnails/thumbnail_service_impl.h"
#include "base/command_line.h"
#include "base/memory/ref_counted_memory.h"
#include "base/time/time.h"
#include "chrome/browser/history/history_utils.h"
#include "chrome/browser/history/top_sites_factory.h"
#include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h"
#include "chrome/browser/thumbnails/simple_thumbnail_crop.h"
#include "chrome/browser/thumbnails/thumbnailing_context.h"
#include "chrome/common/chrome_switches.h"
#include "components/search/search.h"
#include "content/public/browser/browser_thread.h"
#include "url/gurl.h"
......@@ -28,15 +24,6 @@ namespace {
const int kThumbnailWidth = 154;
const int kThumbnailHeight = 96;
// True if thumbnail retargeting feature is enabled (Finch/flags).
bool IsThumbnailRetargetingEnabled() {
if (!search::IsInstantExtendedAPIEnabled())
return false;
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableThumbnailRetargeting);
}
void AddForcedURLOnUIThread(scoped_refptr<history::TopSites> top_sites,
const GURL& url) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......@@ -50,9 +37,7 @@ void AddForcedURLOnUIThread(scoped_refptr<history::TopSites> top_sites,
namespace thumbnails {
ThumbnailServiceImpl::ThumbnailServiceImpl(Profile* profile)
: top_sites_(TopSitesFactory::GetForProfile(profile)),
use_thumbnail_retargeting_(IsThumbnailRetargetingEnabled()) {
}
: top_sites_(TopSitesFactory::GetForProfile(profile)) {}
ThumbnailServiceImpl::~ThumbnailServiceImpl() {
}
......@@ -89,10 +74,7 @@ void ThumbnailServiceImpl::AddForcedURL(const GURL& url) {
ThumbnailingAlgorithm* ThumbnailServiceImpl::GetThumbnailingAlgorithm()
const {
const gfx::Size thumbnail_size(kThumbnailWidth, kThumbnailHeight);
if (use_thumbnail_retargeting_)
return new ContentBasedThumbnailingAlgorithm(thumbnail_size);
return new SimpleThumbnailCrop(thumbnail_size);
return new SimpleThumbnailCrop(gfx::Size(kThumbnailWidth, kThumbnailHeight));
}
bool ThumbnailServiceImpl::ShouldAcquirePageThumbnail(const GURL& url) {
......
......@@ -40,7 +40,6 @@ class ThumbnailServiceImpl : public ThumbnailService {
~ThumbnailServiceImpl() override;
scoped_refptr<history::TopSites> top_sites_;
bool use_thumbnail_retargeting_;
DISALLOW_COPY_AND_ASSIGN(ThumbnailServiceImpl);
};
......
......@@ -424,10 +424,6 @@ const char kEnableSupervisedUserManagedBookmarksFolder[] =
// Enables user control over muting tab audio from the tab strip.
const char kEnableTabAudioMuting[] = "enable-tab-audio-muting";
// Enables fanciful thumbnail processing. Used with NTP for
// instant-extended-api, where thumbnails are generally smaller.
const char kEnableThumbnailRetargeting[] = "enable-thumbnail-retargeting";
// Enables Web Notification custom layouts.
const char kEnableWebNotificationCustomLayouts[] =
"enable-web-notification-custom-layouts";
......
......@@ -132,7 +132,6 @@ extern const char kEnableSiteEngagementEvictionPolicy[];
extern const char kEnableSiteSettings[];
extern const char kEnableSupervisedUserManagedBookmarksFolder[];
extern const char kEnableTabAudioMuting[];
extern const char kEnableThumbnailRetargeting[];
extern const char kEnableWebNotificationCustomLayouts[];
extern const char kEnableWebRtcEventLoggingFromExtension[];
extern const char kExtensionContentVerification[];
......
......@@ -3283,8 +3283,6 @@ test("unit_tests") {
"../browser/sync/sessions/sync_sessions_web_contents_router_unittest.cc",
"../browser/sync/sync_startup_tracker_unittest.cc",
"../browser/task_profiler/task_profiler_data_serializer_unittest.cc",
"../browser/thumbnails/content_analysis_unittest.cc",
"../browser/thumbnails/content_based_thumbnailing_algorithm_unittest.cc",
"../browser/thumbnails/simple_thumbnail_crop_unittest.cc",
"../browser/thumbnails/thumbnail_service_unittest.cc",
"../browser/translate/chrome_translate_client_unittest.cc",
......
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