[ios] Creates feedLastRefreshTime perf and FeedWasShown provider method.
- Creates a pref that tracks the last time when the DiscoverFeed was refreshed. This is now registered using the ContentSuggestions mediator. - Adds a new method to the DiscoverFeedProvider that will be called once the Feed has been shown. This is reported to the Coordinator using ContentSuggestions audience. Bug: 1156346 Change-Id: I8333d4c3dd8e372313449815b3aa336315ca5960 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2577886 Commit-Queue: Sergio Collazos <sczs@chromium.org> Reviewed-by: Gauthier Ambard <gambard@chromium.org> Cr-Commit-Position: refs/heads/master@{#835934}
This commit is contained in:
ios
chrome
browser
public
provider
chrome
browser
discover_feed
@ -80,6 +80,10 @@ const char kIosBookmarkPromoAlreadySeen[] = "ios.bookmark.promo_already_seen";
|
||||
const char kIosBookmarkSigninPromoDisplayedCount[] =
|
||||
"ios.bookmark.signin_promo_displayed_count";
|
||||
|
||||
// The time when the DiscoverFeed was last refreshed.
|
||||
const char kIosDiscoverFeedLastRefreshTime[] =
|
||||
"ios.discover_feed.last_refresh_time";
|
||||
|
||||
// Preference that hold a boolean indicating if the user has already dismissed
|
||||
// the sign-in promo in settings view.
|
||||
const char kIosSettingsPromoAlreadySeen[] = "ios.settings.promo_already_seen";
|
||||
|
@ -26,6 +26,7 @@ extern const char kIosBookmarkCachedTopMostRow[];
|
||||
extern const char kIosBookmarkFolderDefault[];
|
||||
extern const char kIosBookmarkPromoAlreadySeen[];
|
||||
extern const char kIosBookmarkSigninPromoDisplayedCount[];
|
||||
extern const char kIosDiscoverFeedLastRefreshTime[];
|
||||
extern const char kIosSettingsPromoAlreadySeen[];
|
||||
extern const char kIosSettingsSigninPromoDisplayedCount[];
|
||||
extern const char kLastSessionExitedCleanly[];
|
||||
|
@ -83,6 +83,7 @@ source_set("browser_prefs") {
|
||||
"//ios/chrome/browser/ui/authentication",
|
||||
"//ios/chrome/browser/ui/bookmarks:constants",
|
||||
"//ios/chrome/browser/ui/bookmarks:core",
|
||||
"//ios/chrome/browser/ui/content_suggestions",
|
||||
"//ios/chrome/browser/ui/first_run:field_trial",
|
||||
"//ios/chrome/browser/ui/incognito_reauth:incognito_reauth_scene_agent",
|
||||
"//ios/chrome/browser/voice:prefs",
|
||||
|
@ -66,6 +66,7 @@
|
||||
#import "ios/chrome/browser/ui/bookmarks/bookmark_mediator.h"
|
||||
#import "ios/chrome/browser/ui/bookmarks/bookmark_path_cache.h"
|
||||
#import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
|
||||
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_mediator.h"
|
||||
#import "ios/chrome/browser/ui/first_run/location_permissions_field_trial.h"
|
||||
#import "ios/chrome/browser/ui/incognito_reauth/incognito_reauth_scene_agent.h"
|
||||
#include "ios/chrome/browser/voice/voice_search_prefs_registration.h"
|
||||
@ -195,6 +196,7 @@ void RegisterBrowserStatePrefs(user_prefs::PrefRegistrySyncable* registry) {
|
||||
|
||||
[BookmarkMediator registerBrowserStatePrefs:registry];
|
||||
[BookmarkPathCache registerBrowserStatePrefs:registry];
|
||||
[ContentSuggestionsMediator registerBrowserStatePrefs:registry];
|
||||
[SigninPromoViewMediator registerBrowserStatePrefs:registry];
|
||||
[HandoffManager registerBrowserStatePrefs:registry];
|
||||
|
||||
|
@ -40,6 +40,7 @@ source_set("content_suggestions") {
|
||||
"//components/feed/core/shared_prefs:feed_shared_prefs",
|
||||
"//components/ntp_snippets",
|
||||
"//components/ntp_tiles",
|
||||
"//components/pref_registry",
|
||||
"//components/prefs",
|
||||
"//components/prefs/ios",
|
||||
"//components/reading_list/core",
|
||||
|
@ -124,6 +124,11 @@
|
||||
@property(nonatomic, assign) AuthenticationService* authService;
|
||||
// Coordinator in charge of handling sharing use cases.
|
||||
@property(nonatomic, strong) SharingCoordinator* sharingCoordinator;
|
||||
// YES if the feedShown method has already been called.
|
||||
// TODO(crbug.com/1126940): The coordinator shouldn't be keeping track of this
|
||||
// for its |self.discoverFeedViewController| remove once we have an appropriate
|
||||
// callback.
|
||||
@property(nonatomic, assign) BOOL feedShownWasCalled;
|
||||
|
||||
@end
|
||||
|
||||
@ -375,6 +380,13 @@
|
||||
_discoverFeedHeaderMenuButton = menuButton;
|
||||
}
|
||||
|
||||
- (void)discoverFeedShown {
|
||||
if (IsDiscoverFeedEnabled() && !self.feedShownWasCalled) {
|
||||
ios::GetChromeBrowserProvider()->GetDiscoverFeedProvider()->FeedWasShown();
|
||||
self.feedShownWasCalled = YES;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - OverscrollActionsControllerDelegate
|
||||
|
||||
- (void)overscrollActionsController:(OverscrollActionsController*)controller
|
||||
|
@ -27,6 +27,10 @@ namespace ntp_tiles {
|
||||
class MostVisitedSites;
|
||||
}
|
||||
|
||||
namespace user_prefs {
|
||||
class PrefRegistrySyncable;
|
||||
} // namespace user_prefs
|
||||
|
||||
@protocol ContentSuggestionsCommands;
|
||||
@protocol ContentSuggestionsConsumer;
|
||||
@protocol ContentSuggestionsGestureCommands;
|
||||
@ -61,6 +65,9 @@ class ReadingListModel;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
// Registers the feature preferences.
|
||||
+ (void)registerBrowserStatePrefs:(user_prefs::PrefRegistrySyncable*)registry;
|
||||
|
||||
// Command handler for the mediator.
|
||||
@property(nonatomic, weak)
|
||||
id<ContentSuggestionsCommands, ContentSuggestionsGestureCommands>
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "components/ntp_tiles/metrics.h"
|
||||
#include "components/ntp_tiles/most_visited_sites.h"
|
||||
#include "components/ntp_tiles/ntp_tile.h"
|
||||
#import "components/pref_registry/pref_registry_syncable.h"
|
||||
#import "components/prefs/ios/pref_observer_bridge.h"
|
||||
#include "components/prefs/pref_change_registrar.h"
|
||||
#include "components/reading_list/core/reading_list_model.h"
|
||||
@ -21,6 +22,7 @@
|
||||
#include "ios/chrome/browser/application_context.h"
|
||||
#include "ios/chrome/browser/ntp_tiles/most_visited_sites_observer_bridge.h"
|
||||
#include "ios/chrome/browser/pref_names.h"
|
||||
#import "ios/chrome/browser/pref_names.h"
|
||||
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_discover_item.h"
|
||||
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item.h"
|
||||
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_learn_more_item.h"
|
||||
@ -210,6 +212,10 @@ const NSInteger kMaxNumMostVisitedTiles = 4;
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (void)registerBrowserStatePrefs:(user_prefs::PrefRegistrySyncable*)registry {
|
||||
registry->RegisterInt64Pref(prefs::kIosDiscoverFeedLastRefreshTime, 0);
|
||||
}
|
||||
|
||||
- (void)disconnect {
|
||||
_prefChangeRegistrar.reset();
|
||||
_prefObserverBridge.reset();
|
||||
|
@ -840,6 +840,7 @@ NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix =
|
||||
// more reliably.
|
||||
if (self.feedView.contentSize.height > kDiscoverFeedLoadedHeight) {
|
||||
[self.discoverFeedMenuHandler notifyFeedLoadedForHeaderMenu];
|
||||
[self.audience discoverFeedShown];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,11 @@
|
||||
// provides a reference to the button.
|
||||
- (void)discoverHeaderMenuButtonShown:(UIView*)menuButton;
|
||||
|
||||
// Notifies the audience that the Discover Feed has been shown.
|
||||
// TODO(crbug.com/1126940): This is still a best effort approach and might be
|
||||
// called multiple times.
|
||||
- (void)discoverFeedShown;
|
||||
|
||||
@end
|
||||
|
||||
#endif // IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_VIEW_CONTROLLER_AUDIENCE_H_
|
||||
|
@ -59,6 +59,10 @@ class DiscoverFeedProvider {
|
||||
virtual void RemoveObserver(Observer* observer);
|
||||
// Loads and appends the next set of articles in the feed.
|
||||
virtual void LoadMoreFeedArticles();
|
||||
// Called by the embedder whenever the Feed has been shown.
|
||||
// TODO(crbug.com/1126940): The Feed should have a callback for this, remove
|
||||
// when its available.
|
||||
virtual void FeedWasShown();
|
||||
};
|
||||
|
||||
#endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_DISCOVER_FEED_DISCOVER_FEED_PROVIDER_H_
|
||||
|
@ -33,3 +33,4 @@ void DiscoverFeedProvider::UpdateFeedForAccountChange() {}
|
||||
void DiscoverFeedProvider::AddObserver(Observer* observer) {}
|
||||
void DiscoverFeedProvider::RemoveObserver(Observer* observer) {}
|
||||
void DiscoverFeedProvider::LoadMoreFeedArticles() {}
|
||||
void DiscoverFeedProvider::FeedWasShown() {}
|
||||
|
Reference in New Issue
Block a user