Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/content_suggestions/content_suggestions_coordinator. h" | 5 #import "ios/chrome/browser/content_suggestions/content_suggestions_coordinator. h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/metrics/user_metrics.h" | 8 #include "base/metrics/user_metrics.h" |
| 9 #include "base/metrics/user_metrics_action.h" | 9 #include "base/metrics/user_metrics_action.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "components/ntp_snippets/content_suggestions_service.h" | 11 #include "components/ntp_snippets/content_suggestions_service.h" |
| 12 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" | 12 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" |
| 13 #include "components/reading_list/core/reading_list_model.h" | 13 #include "components/reading_list/core/reading_list_model.h" |
| 14 #import "ios/chrome/browser/content_suggestions/content_suggestions_mediator.h" | 14 #import "ios/chrome/browser/content_suggestions/content_suggestions_mediator.h" |
| 15 #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" | 15 #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" |
| 16 #include "ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service _factory.h" | 16 #include "ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service _factory.h" |
| 17 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" | 17 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" |
| 18 #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" | 18 #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" |
| 19 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | |
| 20 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | |
| 21 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | |
| 19 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_art icle_item.h" | 22 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_art icle_item.h" |
| 20 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands. h" | 23 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands. h" |
| 21 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_cont roller.h" | 24 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_cont roller.h" |
| 22 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion _identifier.h" | 25 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion _identifier.h" |
| 23 #import "ios/chrome/browser/ui/url_loader.h" | 26 #import "ios/chrome/browser/ui/url_loader.h" |
| 24 #include "ios/chrome/grit/ios_strings.h" | 27 #include "ios/chrome/grit/ios_strings.h" |
| 25 #include "ios/web/public/referrer.h" | 28 #include "ios/web/public/referrer.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/strings/grit/ui_strings.h" | 30 #include "ui/strings/grit/ui_strings.h" |
| 28 | 31 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 | 72 |
| 70 ntp_snippets::ContentSuggestionsService* contentSuggestionsService = | 73 ntp_snippets::ContentSuggestionsService* contentSuggestionsService = |
| 71 IOSChromeContentSuggestionsServiceFactory::GetForBrowserState( | 74 IOSChromeContentSuggestionsServiceFactory::GetForBrowserState( |
| 72 self.browserState); | 75 self.browserState); |
| 73 contentSuggestionsService->remote_suggestions_scheduler()->OnNTPOpened(); | 76 contentSuggestionsService->remote_suggestions_scheduler()->OnNTPOpened(); |
| 74 | 77 |
| 75 self.contentSuggestionsMediator = [[ContentSuggestionsMediator alloc] | 78 self.contentSuggestionsMediator = [[ContentSuggestionsMediator alloc] |
| 76 initWithContentService:contentSuggestionsService | 79 initWithContentService:contentSuggestionsService |
| 77 largeIconService:IOSChromeLargeIconServiceFactory:: | 80 largeIconService:IOSChromeLargeIconServiceFactory:: |
| 78 GetForBrowserState(self.browserState)]; | 81 GetForBrowserState(self.browserState)]; |
| 82 self.contentSuggestionsMediator.commandHandler = self; | |
| 79 | 83 |
| 80 self.suggestionsViewController = [[ContentSuggestionsViewController alloc] | 84 self.suggestionsViewController = [[ContentSuggestionsViewController alloc] |
| 81 initWithStyle:CollectionViewControllerStyleDefault | 85 initWithStyle:CollectionViewControllerStyleDefault |
| 82 dataSource:self.contentSuggestionsMediator]; | 86 dataSource:self.contentSuggestionsMediator]; |
| 83 | 87 |
| 84 self.suggestionsViewController.suggestionCommandHandler = self; | 88 self.suggestionsViewController.suggestionCommandHandler = self; |
| 85 _navigationController = [[UINavigationController alloc] | 89 _navigationController = [[UINavigationController alloc] |
| 86 initWithRootViewController:self.suggestionsViewController]; | 90 initWithRootViewController:self.suggestionsViewController]; |
| 87 | 91 |
| 88 self.suggestionsViewController.navigationItem.leftBarButtonItem = | 92 self.suggestionsViewController.navigationItem.leftBarButtonItem = |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 103 completion:nil]; | 107 completion:nil]; |
| 104 self.navigationController = nil; | 108 self.navigationController = nil; |
| 105 self.contentSuggestionsMediator = nil; | 109 self.contentSuggestionsMediator = nil; |
| 106 self.alertCoordinator = nil; | 110 self.alertCoordinator = nil; |
| 107 _visible = NO; | 111 _visible = NO; |
| 108 } | 112 } |
| 109 | 113 |
| 110 #pragma mark - ContentSuggestionsCommands | 114 #pragma mark - ContentSuggestionsCommands |
| 111 | 115 |
| 112 - (void)openReadingList { | 116 - (void)openReadingList { |
| 117 [self.baseViewController | |
| 118 chromeExecuteCommand:[GenericChromeCommand | |
| 119 commandWithTag:IDC_SHOW_READING_LIST]]; | |
|
stkhapugin
2017/04/05 13:06:02
This is ugly. Isn't it supposed to be done through
gambard
2017/04/05 15:30:17
Yes in bling*... For now this is the way (from mar
| |
| 113 } | 120 } |
| 114 | 121 |
| 115 - (void)openFirstPageOfReadingList { | 122 - (void)openFirstPageOfReadingList { |
| 116 } | 123 } |
| 117 | 124 |
| 118 - (void)openFaviconAtIndex:(NSInteger)index { | 125 - (void)openFaviconAtIndex:(NSInteger)index { |
| 119 } | 126 } |
| 120 | 127 |
| 121 - (void)openURL:(const GURL&)URL { | 128 - (void)openURL:(const GURL&)URL { |
| 122 // TODO(crbug.com/691979): Add metrics. | 129 // TODO(crbug.com/691979): Add metrics. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 if (!article) | 237 if (!article) |
| 231 return; | 238 return; |
| 232 | 239 |
| 233 // TODO(crbug.com/691979): Add metrics. | 240 // TODO(crbug.com/691979): Add metrics. |
| 234 [self.contentSuggestionsMediator | 241 [self.contentSuggestionsMediator |
| 235 dismissSuggestion:article.suggestionIdentifier]; | 242 dismissSuggestion:article.suggestionIdentifier]; |
| 236 [self.suggestionsViewController dismissEntryAtIndexPath:indexPath]; | 243 [self.suggestionsViewController dismissEntryAtIndexPath:indexPath]; |
| 237 } | 244 } |
| 238 | 245 |
| 239 @end | 246 @end |
| OLD | NEW |