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

Side by Side Diff: ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm

Issue 2745593002: Remove categories notified as invalid (Closed)
Patch Set: Add comment 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 unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698