Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm

Issue 2766713002: Add "Read Later" action to ContentSuggestions' context menu (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/content_suggestions/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm b/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm
index c350a4f1a3d9f964235c72fb9fa62e3d997d5fe8..23797d2e748b8a0be242cfdfee5836de1ecaa7a2 100644
--- a/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm
+++ b/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm
@@ -5,11 +5,15 @@
#import "ios/chrome/browser/content_suggestions/content_suggestions_coordinator.h"
#include "base/mac/scoped_nsobject.h"
+#include "base/metrics/user_metrics.h"
+#include "base/metrics/user_metrics_action.h"
#include "base/strings/sys_string_conversions.h"
#include "components/ntp_snippets/content_suggestions_service.h"
#include "components/ntp_snippets/remote/remote_suggestions_scheduler.h"
+#include "components/reading_list/ios/reading_list_model.h"
#import "ios/chrome/browser/content_suggestions/content_suggestions_mediator.h"
#include "ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.h"
+#include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_article_item.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.h"
@@ -136,6 +140,7 @@
__weak ContentSuggestionsCoordinator* weakSelf = self;
GURL articleURL = articleItem.articleURL;
+ NSString* articleTitle = articleItem.title;
__weak ContentSuggestionsArticleItem* weakArticle = articleItem;
NSString* openInNewTabTitle =
@@ -158,6 +163,28 @@
}
style:UIAlertActionStyleDefault];
+ NSString* readLaterTitle =
Olivier 2017/03/22 08:28:43 if (reading_list::switches::IsReadingListEnabled()
gambard 2017/03/22 08:37:54 Done.
+ l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST);
+ [self.alertCoordinator
+ addItemWithTitle:readLaterTitle
+ action:^{
+ ContentSuggestionsCoordinator* strongSelf = weakSelf;
+ if (!strongSelf)
+ return;
+
+ base::RecordAction(
+ base::UserMetricsAction("MobileReadingListAdd"));
+ // TODO(crbug.com/691979): Add metrics.
+
+ ReadingListModel* readingModel =
+ ReadingListModelFactory::GetForBrowserState(
+ strongSelf.browserState);
+ readingModel->AddEntry(articleURL,
+ base::SysNSStringToUTF8(articleTitle),
+ reading_list::ADDED_VIA_CURRENT_APP);
+ }
+ style:UIAlertActionStyleDefault];
+
NSString* deleteTitle =
l10n_util::GetNSString(IDS_IOS_CONTENT_SUGGESTIONS_DELETE);
[self.alertCoordinator addItemWithTitle:deleteTitle
« no previous file with comments | « ios/chrome/browser/content_suggestions/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698