Commit 45fce0dc authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Clean up GoogleLandingConsumer/DataSource

ContentSuggestions is enabled to 100%, those methods can be removed as
they were only used in the old NTP.

Bug: 764720
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I7606b7635862168e9e019ad8bb8175b9d11484b1
Reviewed-on: https://chromium-review.googlesource.com/778860Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517806}
parent 0855a8db
......@@ -29,11 +29,11 @@ source_set("spotlight") {
"//ios/chrome/app/strings",
"//ios/chrome/browser",
"//ios/chrome/browser/bookmarks",
"//ios/chrome/browser/content_suggestions",
"//ios/chrome/browser/favicon",
"//ios/chrome/browser/history",
"//ios/chrome/browser/suggestions",
"//ios/chrome/browser/sync",
"//ios/chrome/browser/ui/ntp:ntp_internal",
"//ios/chrome/common/app_group",
"//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/spotlight",
......
......@@ -15,12 +15,12 @@
#include "components/history/core/browser/top_sites_observer.h"
#include "components/suggestions/suggestions_service.h"
#include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
#import "ios/chrome/browser/content_suggestions/content_suggestions_mediator.h"
#include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h"
#include "ios/chrome/browser/history/top_sites_factory.h"
#include "ios/chrome/browser/suggestions/suggestions_service_factory.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/sync_observer_bridge.h"
#include "ios/chrome/browser/ui/ntp/google_landing_mediator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -239,7 +239,7 @@ initWithLargeIconService:(favicon::LargeIconService*)largeIconService
- (void)onMostVisitedURLsAvailable:
(const history::MostVisitedURLList&)top_sites {
NSUInteger sitesToIndex =
MIN(top_sites.size(), [GoogleLandingMediator maxSitesShown]);
MIN(top_sites.size(), [ContentSuggestionsMediator maxSitesShown]);
for (size_t i = 0; i < sitesToIndex; i++) {
const GURL& URL = top_sites[i].url;
......@@ -257,7 +257,8 @@ initWithLargeIconService:(favicon::LargeIconService*)largeIconService
(const suggestions::SuggestionsProfile&)suggestionsProfile {
size_t size = suggestionsProfile.suggestions_size();
if (size) {
NSUInteger sitesToIndex = MIN(size, [GoogleLandingMediator maxSitesShown]);
NSUInteger sitesToIndex =
MIN(size, [ContentSuggestionsMediator maxSitesShown]);
for (size_t i = 0; i < sitesToIndex; i++) {
const suggestions::ChromeSuggestion& suggestion =
suggestionsProfile.suggestions(i);
......
......@@ -134,6 +134,9 @@
self.contentSuggestionsMediator.commandHandler = self.NTPMediator;
self.contentSuggestionsMediator.headerProvider = self.headerController;
self.headerController.promoCanShow =
[self.contentSuggestionsMediator notificationPromo]->CanShow();
self.metricsRecorder = [[ContentSuggestionsMetricsRecorder alloc] init];
self.metricsRecorder.delegate = self.contentSuggestionsMediator;
......
......@@ -43,6 +43,9 @@ class ReadingListModel;
// Whether the Google logo or doodle is being shown.
@property(nonatomic, assign) BOOL logoIsShowing;
// |YES| if a what's new promo can be displayed.
@property(nonatomic, assign) BOOL promoCanShow;
// |YES| if its view is visible. When set to |NO| various UI updates are
// ignored.
@property(nonatomic, assign) BOOL isShowing;
......
......@@ -45,9 +45,6 @@ const CGFloat kHintLabelSidePadding = 12;
// |YES| if this consumer is has voice search enabled.
@property(nonatomic, assign) BOOL voiceSearchIsEnabled;
// |YES| if a what's new promo can be displayed.
@property(nonatomic, assign) BOOL promoCanShow;
// Exposes view and methods to drive the doodle.
@property(nonatomic, weak) id<LogoVendor> logoVendor;
......@@ -59,13 +56,6 @@ const CGFloat kHintLabelSidePadding = 12;
// pushed into the header view.
@property(nonatomic, assign) BOOL canGoBack;
// Gets the icon of a what's new promo.
// TODO(crbug.com/694750): This should not be WhatsNewIcon.
@property(nonatomic, assign) WhatsNewIcon promoIcon;
// Gets the text of a what's new promo.
@property(nonatomic, copy) NSString* promoText;
// The number of tabs to show in the google landing fake toolbar.
@property(nonatomic, assign) int tabCount;
......@@ -94,8 +84,6 @@ const CGFloat kHintLabelSidePadding = 12;
@synthesize promoCanShow = _promoCanShow;
@synthesize canGoForward = _canGoForward;
@synthesize canGoBack = _canGoBack;
@synthesize promoIcon = _promoIcon;
@synthesize promoText = _promoText;
@synthesize isShowing = _isShowing;
@synthesize omniboxFocused = _omniboxFocused;
@synthesize tabCount = _tabCount;
......@@ -394,18 +382,6 @@ const CGFloat kHintLabelSidePadding = 12;
[self updateLogoAndFakeboxDisplay];
}
- (void)setMaximumMostVisitedSitesShown:
(NSUInteger)maximumMostVisitedSitesShown {
}
- (void)mostVisitedDataUpdated {
// Do nothing as it is handled in the ContentSuggestionsMediator.
}
- (void)mostVisitedIconMadeAvailableAtIndex:(NSUInteger)index {
// Do nothing as it is handled in the ContentSuggestionsMediator.
}
- (void)setTabCount:(int)tabCount {
_tabCount = tabCount;
[self.headerView setToolbarTabCount:tabCount];
......
......@@ -73,6 +73,9 @@ initWithContentService:
// Whitelists the URL from the Most Visited sites.
- (void)whitelistMostVisitedURL:(GURL)URL;
// Get the maximum number of sites shown.
+ (NSUInteger)maxSitesShown;
@end
#endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_MEDIATOR_H_
......@@ -175,6 +175,10 @@ initWithContentService:(ntp_snippets::ContentSuggestionsService*)contentService
self.faviconMediator.dataSink = dataSink;
}
+ (NSUInteger)maxSitesShown {
return kMaxNumMostVisitedTiles;
}
#pragma mark - ContentSuggestionsDataSource
- (NSArray<ContentSuggestionsSectionInformation*>*)sectionsInfo {
......
......@@ -15,7 +15,6 @@ source_set("ntp") {
source_set("ntp_header") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"google_landing_data_source.h",
"new_tab_page_header_view.h",
"new_tab_page_header_view.mm",
"new_tab_page_toolbar_controller.h",
......
......@@ -24,20 +24,6 @@
// |YES| if this consumer is has voice search enabled.
- (void)setVoiceSearchIsEnabled:(BOOL)voiceSearchIsEnabled;
// Sets the maximum number of sites shown.
- (void)setMaximumMostVisitedSitesShown:
(NSUInteger)maximumMostVisitedSitesShown;
// Sets the text of a what's new promo.
- (void)setPromoText:(NSString*)promoText;
// Sets the icon of a what's new promo.
// TODO(crbug.com/694750): This should not be WhatsNewIcon.
- (void)setPromoIcon:(WhatsNewIcon)promoIcon;
// |YES| if a what's new promo can be displayed.
- (void)setPromoCanShow:(BOOL)promoCanShow;
// The number of tabs to show in the google landing fake toolbar.
- (void)setTabCount:(int)tabCount;
......@@ -47,14 +33,6 @@
// |YES| if the google landing toolbar can show the back arrow.
- (void)setCanGoBack:(BOOL)canGoBack;
// TODO(crbug.com/694750): This should be replaced with consumer suitable data
// type property.
// Tells the consumer to that most visited data updated.
- (void)mostVisitedDataUpdated;
// Tells the consumer a most visited icon was updated.
- (void)mostVisitedIconMadeAvailableAtIndex:(NSUInteger)index;
// TODO(crbug.com/694750): These two calls can be made with dispatcher instead.
// The location bar has lost focus.
- (void)locationBarResignsFirstResponder;
......
// Copyright 2017 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 IOS_CHROME_BROWSER_UI_NTP_GOOGLE_LANDING_DATA_SOURCE_H_
#define IOS_CHROME_BROWSER_UI_NTP_GOOGLE_LANDING_DATA_SOURCE_H_
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#include "components/ntp_tiles/ntp_tile.h"
#import "ios/chrome/browser/ui/favicon/favicon_attributes.h"
#include "url/gurl.h"
@class FaviconAttributes;
class ReadingListModel;
class LargeIconCache;
namespace favicon {
class LargeIconService;
}
// DataSource for the google landing controller.
// TODO(crbug.com/694750): Most everything here can be moved to dispatcher.
@protocol GoogleLandingDataSource
// Removes a blacklisted URL in both |_mostVisitedData|.
- (void)removeBlacklistedURL:(const GURL&)url;
// Adds URL to the blacklist in both |_mostVisitedData|.
- (void)addBlacklistedURL:(const GURL&)url;
// Logs a histogram due to a Most Visited item being opened.
- (void)logMostVisitedClick:(const NSUInteger)visitedIndex
faviconAttributes:(FaviconAttributes*)faviconAttributes;
// Called when a what's new promo is viewed.
- (void)promoViewed;
// Called when a what's new promo is tapped.
- (void)promoTapped;
// TODO(crbug.com/694750): The following two methods should be moved to the
// consumer, and converted into types more suitable for a consumer.
// Gets an a most visited NTP tile at |index|.
- (ntp_tiles::NTPTile)mostVisitedAtIndex:(NSUInteger)index;
// Gets the number of most visited entries.
- (NSUInteger)mostVisitedSize;
// TODO(crbug.com/694750): The following three properties will be removed in
// subsequent CLs, with data provided via GoogleDataConsumer into types more
// suitable for a consumer.
// Gets the reading list model.
- (ReadingListModel*)readingListModel;
// Gets the large icon cache.
- (LargeIconCache*)largeIconCache;
// Gets the large icon service.
- (favicon::LargeIconService*)largeIconService;
// Asynchronously gets the favicon for |URL| with size |size| and calls
// |imageCallback| with the |favicon| image if it's valid, or |fallbackCallback|
// if there is valid fallback data with the |textColor| and |backgroundColor|
// for the fallback icon to use. |isDefaultColor| is true if a default color
// should be used instead of |backgroundColor|.
- (void)getFaviconForPageURL:(const GURL&)URL
size:(CGFloat)size
useCache:(BOOL)useCache
callback:(void (^)(FaviconAttributes*))callback;
@end
#endif // IOS_CHROME_BROWSER_UI_NTP_GOOGLE_LANDING_DATA_SOURCE_H_
......@@ -7,8 +7,6 @@
#import <Foundation/Foundation.h>
#import "ios/chrome/browser/ui/ntp/google_landing_data_source.h"
@protocol BrowserCommands;
@protocol GoogleLandingConsumer;
@protocol OmniboxFocuser;
......@@ -20,7 +18,7 @@ class ChromeBrowserState;
}
// A mediator object that provides various data sources for google landing.
@interface GoogleLandingMediator : NSObject<GoogleLandingDataSource>
@interface GoogleLandingMediator : NSObject
- (nullable instancetype)
initWithBrowserState:(nonnull ios::ChromeBrowserState*)browserState
......@@ -40,9 +38,6 @@ initWithBrowserState:(nonnull ios::ChromeBrowserState*)browserState
// Stop listening to any observers and other cleanup functionality.
- (void)shutdown;
// Get the maximum number of sites shown.
+ (NSUInteger)maxSitesShown;
@end
#endif // IOS_CHROME_BROWSER_UI_NTP_GOOGLE_LANDING_MEDIATOR_H_
......@@ -9,7 +9,6 @@
#import "ios/chrome/browser/tabs/tab_model_observer.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.h"
#import "ios/chrome/browser/ui/image_util.h"
#import "ios/chrome/browser/ui/ntp/google_landing_data_source.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_header_constants.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_toolbar_controller.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_utils.h"
......
......@@ -11,7 +11,6 @@
#include "components/toolbar/toolbar_model.h"
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/ntp/google_landing_data_source.h"
#import "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/toolbar/omnibox_focuser.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_controller_constants.h"
......
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