Commit 6d438a41 authored by adamta's avatar adamta Committed by Commit Bot

[iOS] 'Manage Activity' item for Discover feed header menu

Adds new item in the Discover feed header top-level menu for 'Manage
Activity', which leads to a web page. Also slightly refactors how menu
items that lead to web pages are handled. Only shows this item and
'Manage Interests' if the user is authenticated.

Bug: 1085419
Change-Id: I66be67659ccbc04121f0eb02657a7e20cfe66e3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2341805
Commit-Queue: Adam Trudeau-Arcaro <adamta@google.com>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795986}
parent 8b66b989
......@@ -719,6 +719,9 @@ Because your account is managed by <ph name="HOSTED_DOMAIN">$1<ex>google.com</ex
<message name="IDS_IOS_DISCOVER_FEED_MENU_LEARN_MORE_ITEM" desc="The 'Learn More' action for the Discover feed header menu.">
Learn More
</message>
<message name="IDS_IOS_DISCOVER_FEED_MENU_MANAGE_ACTIVITY_ITEM" desc="The 'Manage Activity' action for the Discover feed header menu.">
Manage Activity
</message>
<message name="IDS_IOS_DISCOVER_FEED_MENU_MANAGE_INTERESTS_ITEM" desc="The 'Manage Interests' action for the Discover feed header menu.">
Manage Interests
</message>
......
f2e5ed92fe61e6273b00ede67dee92c411afd017
\ No newline at end of file
......@@ -35,6 +35,8 @@
- (void)handlePromoTapped;
// Handles the actions following a tap on the "Learn more" item.
- (void)handleLearnMoreTapped;
// Handles the actions following a tap on the "Manage Activity" item.
- (void)handleManageActivityTapped;
// Handles the actions following a tap on the "Manage Interests" item.
- (void)handleManageInterestsTapped;
......
......@@ -26,6 +26,7 @@
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#import "ios/chrome/browser/signin/authentication_service.h"
#import "ios/chrome/browser/signin/authentication_service_factory.h"
#include "ios/chrome/browser/signin/identity_manager_factory.h"
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
......@@ -103,6 +104,8 @@
@property(nonatomic, weak) id<DiscoverFeedHeaderChanging>
discoverFeedHeaderDelegate;
@property(nonatomic) CGFloat discoverFeedHeight;
// Authentication Service for the user's signed-in state.
@property(nonatomic, assign) AuthenticationService* authService;
@end
......@@ -144,14 +147,16 @@
ntp_home::RecordNTPImpression(ntp_home::LOCAL_SUGGESTIONS);
}
self.authService = AuthenticationServiceFactory::GetForBrowserState(
self.browser->GetBrowserState());
self.NTPMediator = [[NTPHomeMediator alloc]
initWithWebState:self.webState
templateURLService:ios::TemplateURLServiceFactory::
GetForBrowserState(
self.browser->GetBrowserState())
URLLoader:UrlLoadingBrowserAgent::FromBrowser(self.browser)
authService:AuthenticationServiceFactory::GetForBrowserState(
self.browser->GetBrowserState())
authService:self.authService
identityManager:IdentityManagerFactory::GetForBrowserState(
self.browser->GetBrowserState())
logoVendor:ios::GetChromeBrowserProvider()->CreateLogoVendor(
......@@ -410,13 +415,23 @@
style:UIAlertActionStyleDefault];
}
[self.alertCoordinator
addItemWithTitle:l10n_util::GetNSString(
IDS_IOS_DISCOVER_FEED_MENU_MANAGE_INTERESTS_ITEM)
action:^{
[weakSelf.NTPMediator handleManageInterestsTapped];
}
style:UIAlertActionStyleDefault];
if (self.authService->IsAuthenticated()) {
[self.alertCoordinator
addItemWithTitle:l10n_util::GetNSString(
IDS_IOS_DISCOVER_FEED_MENU_MANAGE_ACTIVITY_ITEM)
action:^{
[weakSelf.NTPMediator handleManageActivityTapped];
}
style:UIAlertActionStyleDefault];
[self.alertCoordinator
addItemWithTitle:l10n_util::GetNSString(
IDS_IOS_DISCOVER_FEED_MENU_MANAGE_INTERESTS_ITEM)
action:^{
[weakSelf.NTPMediator handleManageInterestsTapped];
}
style:UIAlertActionStyleDefault];
}
[self.alertCoordinator
addItemWithTitle:l10n_util::GetNSString(
......@@ -437,6 +452,7 @@
self.discoverFeedViewController = [self discoverFeed];
self.contentSuggestionsMediator.discoverFeed =
self.discoverFeedViewController;
[self.alertCoordinator stop];
}
#pragma mark - ContentSuggestionsActionHandler
......
......@@ -65,6 +65,9 @@
#endif
namespace {
// URL for 'Manage Activity' item in the Discover feed menu.
const char kFeedManageActivityURL[] =
"https://myactivity.google.com/myactivity?product=50";
// URL for 'Manage Interests' item in the Discover feed menu.
const char kFeedManageInterestsURL[] =
"https://google.com/preferences/interests";
......@@ -390,22 +393,26 @@ const char kNTPHelpURL[] =
NOTREACHED() << "Promo type is neither URL or command.";
}
- (void)handleManageInterestsTapped {
// Opens web page for a menu item in the NTP.
- (void)openMenuItemWebPage:(GURL)URL {
NewTabPageTabHelper* NTPHelper =
NewTabPageTabHelper::FromWebState(self.webState);
if (NTPHelper && NTPHelper->IgnoreLoadRequests())
return;
_URLLoader->Load(UrlLoadParams::InCurrentTab(GURL(kFeedManageInterestsURL)));
_URLLoader->Load(UrlLoadParams::InCurrentTab(URL));
// TODO(crbug.com/1085419): Add metrics.
}
- (void)handleManageActivityTapped {
[self openMenuItemWebPage:GURL(kFeedManageActivityURL)];
}
- (void)handleManageInterestsTapped {
[self openMenuItemWebPage:GURL(kFeedManageInterestsURL)];
}
- (void)handleLearnMoreTapped {
NewTabPageTabHelper* NTPHelper =
NewTabPageTabHelper::FromWebState(self.webState);
if (NTPHelper && NTPHelper->IgnoreLoadRequests())
return;
_URLLoader->Load(UrlLoadParams::InCurrentTab(GURL(kNTPHelpURL)));
[self.NTPMetrics recordAction:new_tab_page_uma::ACTION_OPENED_LEARN_MORE];
[self openMenuItemWebPage:GURL(kNTPHelpURL)];
}
#pragma mark - ContentSuggestionsGestureCommands
......
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