Commit c7fbec49 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Remove AtrributesProvider logic from ReadingListMediator

AtrributesProvider was used in legacy reading list logic. FaviconLoader is now the preferred method.

Bug: 878796
Change-Id: I009c762dfe7053e149c6b94b2145c4f68008a304
Reviewed-on: https://chromium-review.googlesource.com/1252523
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595458}
parent 659eb2cb
......@@ -9,10 +9,6 @@
#import "ios/chrome/browser/ui/reading_list/reading_list_data_source.h"
namespace favicon {
class LargeIconService;
}
class FaviconLoader;
class GURL;
class ReadingListEntry;
......@@ -24,16 +20,11 @@ class ReadingListModel;
- (nullable instancetype)init NS_UNAVAILABLE;
// TODO(crbug.com/878796): Deprecated. Remove this as part of UIRefresh cleanup.
- (nullable instancetype)
initWithModel:(nonnull ReadingListModel*)model
largeIconService:(nonnull favicon::LargeIconService*)largeIconService
listItemFactory:(nonnull ReadingListListItemFactory*)itemFactory;
- (nullable instancetype)initWithModel:(nonnull ReadingListModel*)model
faviconLoader:(nonnull FaviconLoader*)faviconLoader
listItemFactory:
(nonnull ReadingListListItemFactory*)itemFactory;
(nonnull ReadingListListItemFactory*)itemFactory
NS_DESIGNATED_INITIALIZER;
// Returns the entry corresponding to the |item|. The item should be of type
// ReadingListCollectionViewItem. Returns nullptr if there is no corresponding
......
......@@ -9,13 +9,11 @@
#import "base/mac/foundation_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/sys_string_conversions.h"
#include "components/favicon/core/large_icon_service.h"
#include "components/reading_list/core/reading_list_model.h"
#import "components/reading_list/ios/reading_list_model_bridge_observer.h"
#include "components/url_formatter/url_formatter.h"
#import "ios/chrome/browser/favicon/favicon_loader.h"
#include "ios/chrome/browser/favicon/ios_chrome_favicon_loader_factory.h"
#import "ios/chrome/browser/ui/favicon/favicon_attributes_provider.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_data_sink.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_list_item.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_list_item_factory.h"
......@@ -55,13 +53,6 @@ const CGFloat kFaviconMinWidthHeight = 16;
// The ListItem factory passed on initialization.
@property(nonatomic, strong) ReadingListListItemFactory* itemFactory;
// Lazily instantiated.
@property(nonatomic, strong, readonly)
FaviconAttributesProvider* attributesProvider;
@property(nonatomic, assign, readonly)
favicon::LargeIconService* largeIconService;
// Favicon Service used for UIRefresh Collections.
@property(nonatomic, assign, readonly) FaviconLoader* faviconLoader;
......@@ -73,28 +64,10 @@ const CGFloat kFaviconMinWidthHeight = 16;
@synthesize model = _model;
@synthesize shouldMonitorModel = _shouldMonitorModel;
@synthesize itemFactory = _itemFactory;
@synthesize attributesProvider = _attributesProvider;
@synthesize largeIconService = _largeIconService;
@synthesize faviconLoader = _faviconLoader;
#pragma mark - Public
- (instancetype)initWithModel:(ReadingListModel*)model
largeIconService:(favicon::LargeIconService*)largeIconService
listItemFactory:(ReadingListListItemFactory*)itemFactory {
self = [super init];
if (self) {
_model = model;
_largeIconService = largeIconService;
_itemFactory = itemFactory;
_shouldMonitorModel = YES;
// This triggers the callback method. Should be created last.
_modelBridge.reset(new ReadingListModelBridge(self, model));
}
return self;
}
- (instancetype)initWithModel:(ReadingListModel*)model
faviconLoader:(nonnull FaviconLoader*)faviconLoader
listItemFactory:(ReadingListListItemFactory*)itemFactory {
......@@ -195,17 +168,11 @@ const CGFloat kFaviconMinWidthHeight = 16;
[strongSelf.dataSink itemHasChangedAfterDelay:strongItem];
};
if (self.faviconLoader) {
FaviconAttributes* cachedAttributes = self.faviconLoader->FaviconForUrl(
item.faviconPageURL, kFaviconMinWidthHeight, kFaviconWidthHeight,
/*fallback_to_google_server=*/false, completionBlock);
DCHECK(cachedAttributes);
return completionBlock(cachedAttributes);
} else {
DCHECK(self.attributesProvider);
[self.attributesProvider fetchFaviconAttributesForURL:item.faviconPageURL
completion:completionBlock];
}
}
- (void)beginBatchUpdates {
......@@ -220,21 +187,6 @@ const CGFloat kFaviconMinWidthHeight = 16;
#pragma mark - Properties
- (FaviconAttributesProvider*)attributesProvider {
if (_attributesProvider) {
return _attributesProvider;
}
DCHECK(self.largeIconService);
// Accept any favicon even the smallest ones (16x16) as it is better than the
// fallback icon.
// Pass 1 as minimum size to avoid empty favicons.
_attributesProvider = [[FaviconAttributesProvider alloc]
initWithFaviconSize:kFaviconPreferredSize
minFaviconSize:1
largeIconService:self.largeIconService];
return _attributesProvider;
}
- (void)setDataSink:(id<ReadingListDataSink>)dataSink {
_dataSink = dataSink;
if (self.model->loaded()) {
......
......@@ -70,18 +70,11 @@ class ReadingListMediatorTest
large_icon_service_.reset(new favicon::LargeIconService(
&mock_favicon_service_, /*image_fetcher=*/nullptr));
if (GetParam() == FaviconServiceType::FAVICON_LOADER) {
favicon_loader.reset(new FaviconLoader(large_icon_service_.get()));
mediator_ = [[ReadingListMediator alloc]
initWithModel:model_.get()
faviconLoader:favicon_loader.get()
listItemFactory:[[ReadingListListItemFactory alloc] init]];
} else {
mediator_ = [[ReadingListMediator alloc]
initWithModel:model_.get()
largeIconService:large_icon_service_.get()
listItemFactory:[[ReadingListListItemFactory alloc] init]];
}
}
protected:
......
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