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_mediator.h" | 5 #import "ios/chrome/browser/content_suggestions/content_suggestions_mediator.h" |
6 | 6 |
7 #include "base/mac/bind_objc_block.h" | 7 #include "base/mac/bind_objc_block.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/optional.h" | 9 #include "base/optional.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 - (void)contentSuggestionsService: | 186 - (void)contentSuggestionsService: |
187 (ntp_snippets::ContentSuggestionsService*)suggestionsService | 187 (ntp_snippets::ContentSuggestionsService*)suggestionsService |
188 newSuggestionsInCategory:(ntp_snippets::Category)category { | 188 newSuggestionsInCategory:(ntp_snippets::Category)category { |
189 [self.dataSink dataAvailable]; | 189 [self.dataSink dataAvailable]; |
190 } | 190 } |
191 | 191 |
192 - (void)contentSuggestionsService: | 192 - (void)contentSuggestionsService: |
193 (ntp_snippets::ContentSuggestionsService*)suggestionsService | 193 (ntp_snippets::ContentSuggestionsService*)suggestionsService |
194 category:(ntp_snippets::Category)category | 194 category:(ntp_snippets::Category)category |
195 statusChangedTo:(ntp_snippets::CategoryStatus)status { | 195 statusChangedTo:(ntp_snippets::CategoryStatus)status { |
196 // Update dataSink. | 196 if (!ntp_snippets::IsCategoryStatusInitOrAvailable(status)) { |
| 197 // Remove the category from the UI if it is not available. |
| 198 ContentSuggestionsCategoryWrapper* wrapper = |
| 199 [[ContentSuggestionsCategoryWrapper alloc] initWithCategory:category]; |
| 200 ContentSuggestionsSectionInformation* sectionInfo = |
| 201 self.sectionInformationByCategory[wrapper]; |
| 202 |
| 203 [self.dataSink clearSection:sectionInfo]; |
| 204 [self.sectionInformationByCategory removeObjectForKey:wrapper]; |
| 205 } |
197 } | 206 } |
198 | 207 |
199 - (void)contentSuggestionsService: | 208 - (void)contentSuggestionsService: |
200 (ntp_snippets::ContentSuggestionsService*)suggestionsService | 209 (ntp_snippets::ContentSuggestionsService*)suggestionsService |
201 suggestionInvalidated: | 210 suggestionInvalidated: |
202 (const ntp_snippets::ContentSuggestion::ID&)suggestion_id { | 211 (const ntp_snippets::ContentSuggestion::ID&)suggestion_id { |
203 ContentSuggestionsCategoryWrapper* wrapper = | 212 ContentSuggestionsCategoryWrapper* wrapper = |
204 [[ContentSuggestionsCategoryWrapper alloc] | 213 [[ContentSuggestionsCategoryWrapper alloc] |
205 initWithCategory:suggestion_id.category()]; | 214 initWithCategory:suggestion_id.category()]; |
206 ContentSuggestionIdentifier* suggestionIdentifier = | 215 ContentSuggestionIdentifier* suggestionIdentifier = |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 wrapperWithCategory:category]] = sectionInfo; | 271 wrapperWithCategory:category]] = sectionInfo; |
263 } | 272 } |
264 | 273 |
265 - (ContentSuggestionsCategoryWrapper*)categoryWrapperForSectionInfo: | 274 - (ContentSuggestionsCategoryWrapper*)categoryWrapperForSectionInfo: |
266 (ContentSuggestionsSectionInformation*)sectionInfo { | 275 (ContentSuggestionsSectionInformation*)sectionInfo { |
267 return [[self.sectionInformationByCategory allKeysForObject:sectionInfo] | 276 return [[self.sectionInformationByCategory allKeysForObject:sectionInfo] |
268 firstObject]; | 277 firstObject]; |
269 } | 278 } |
270 | 279 |
271 @end | 280 @end |
OLD | NEW |