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/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "components/ntp_snippets/content_suggestions_service.h" | 9 #include "components/ntp_snippets/content_suggestions_service.h" |
10 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" | 10 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 animated:YES | 89 animated:YES |
90 completion:nil]; | 90 completion:nil]; |
91 } | 91 } |
92 | 92 |
93 - (void)stop { | 93 - (void)stop { |
94 [[self.navigationController presentingViewController] | 94 [[self.navigationController presentingViewController] |
95 dismissViewControllerAnimated:YES | 95 dismissViewControllerAnimated:YES |
96 completion:nil]; | 96 completion:nil]; |
97 self.navigationController = nil; | 97 self.navigationController = nil; |
98 self.contentSuggestionsMediator = nil; | 98 self.contentSuggestionsMediator = nil; |
| 99 self.alertCoordinator = nil; |
99 _visible = NO; | 100 _visible = NO; |
100 } | 101 } |
101 | 102 |
102 #pragma mark - ContentSuggestionsCommands | 103 #pragma mark - ContentSuggestionsCommands |
103 | 104 |
104 - (void)openReadingList { | 105 - (void)openReadingList { |
105 } | 106 } |
106 | 107 |
107 - (void)openFirstPageOfReadingList { | 108 - (void)openFirstPageOfReadingList { |
108 } | 109 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 170 |
170 [self.alertCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_APP_CANCEL) | 171 [self.alertCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_APP_CANCEL) |
171 action:^{ | 172 action:^{ |
172 // TODO(crbug.com/691979): Add metrics. | 173 // TODO(crbug.com/691979): Add metrics. |
173 } | 174 } |
174 style:UIAlertActionStyleCancel]; | 175 style:UIAlertActionStyleCancel]; |
175 | 176 |
176 [self.alertCoordinator start]; | 177 [self.alertCoordinator start]; |
177 } | 178 } |
178 | 179 |
| 180 - (void)dismissContextMenu { |
| 181 [self.alertCoordinator stop]; |
| 182 self.alertCoordinator = nil; |
| 183 } |
| 184 |
179 #pragma mark - Private | 185 #pragma mark - Private |
180 | 186 |
181 - (void)openNewTabWithURL:(const GURL&)URL incognito:(BOOL)incognito { | 187 - (void)openNewTabWithURL:(const GURL&)URL incognito:(BOOL)incognito { |
182 // TODO(crbug.com/691979): Add metrics. | 188 // TODO(crbug.com/691979): Add metrics. |
183 | 189 |
184 [self.URLLoader webPageOrderedOpen:URL | 190 [self.URLLoader webPageOrderedOpen:URL |
185 referrer:web::Referrer() | 191 referrer:web::Referrer() |
186 inIncognito:incognito | 192 inIncognito:incognito |
187 inBackground:NO | 193 inBackground:NO |
188 appendTo:kLastTab]; | 194 appendTo:kLastTab]; |
189 | 195 |
190 [self stop]; | 196 [self stop]; |
191 } | 197 } |
192 | 198 |
193 - (void)dismissArticle:(ContentSuggestionsArticleItem*)article | 199 - (void)dismissArticle:(ContentSuggestionsArticleItem*)article |
194 atIndexPath:(NSIndexPath*)indexPath { | 200 atIndexPath:(NSIndexPath*)indexPath { |
195 if (!article) | 201 if (!article) |
196 return; | 202 return; |
197 | 203 |
198 // TODO(crbug.com/691979): Add metrics. | 204 // TODO(crbug.com/691979): Add metrics. |
199 [self.contentSuggestionsMediator | 205 [self.contentSuggestionsMediator |
200 dismissSuggestion:article.suggestionIdentifier]; | 206 dismissSuggestion:article.suggestionIdentifier]; |
201 [self.suggestionsViewController dismissEntryAtIndexPath:indexPath]; | 207 [self.suggestionsViewController dismissEntryAtIndexPath:indexPath]; |
202 } | 208 } |
203 | 209 |
204 @end | 210 @end |
OLD | NEW |