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

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

Issue 2798563002: Add MostVistedSites to ContentSuggestionsMediator (Closed)
Patch Set: Rebase (different HEAD) Created 3 years, 8 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
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/mediator_util.h" 5 #import "ios/chrome/browser/content_suggestions/mediator_util.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "components/ntp_snippets/category.h" 8 #include "components/ntp_snippets/category.h"
9 #include "components/ntp_tiles/metrics.h"
10 #include "components/rappor/rappor_service_impl.h"
11 #include "ios/chrome/browser/application_context.h"
9 #import "ios/chrome/browser/content_suggestions/content_suggestions_category_wra pper.h" 12 #import "ios/chrome/browser/content_suggestions/content_suggestions_category_wra pper.h"
10 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion _identifier.h" 13 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion _identifier.h"
11 #include "ios/chrome/grit/ios_strings.h" 14 #include "ios/chrome/grit/ios_strings.h"
12 #include "ui/base/l10n/l10n_util_mac.h" 15 #include "ui/base/l10n/l10n_util_mac.h"
13 16
14 #if !defined(__has_feature) || !__has_feature(objc_arc) 17 #if !defined(__has_feature) || !__has_feature(objc_arc)
15 #error "This file requires ARC support." 18 #error "This file requires ARC support."
16 #endif 19 #endif
17 20
18 void BindWrapper( 21 void BindWrapper(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 sectionInfo.title = base::SysUTF16ToNSString(categoryInfo->title()); 92 sectionInfo.title = base::SysUTF16ToNSString(categoryInfo->title());
90 } 93 }
91 return sectionInfo; 94 return sectionInfo;
92 } 95 }
93 96
94 ntp_snippets::ContentSuggestion::ID SuggestionIDForSectionID( 97 ntp_snippets::ContentSuggestion::ID SuggestionIDForSectionID(
95 ContentSuggestionsCategoryWrapper* category, 98 ContentSuggestionsCategoryWrapper* category,
96 const std::string& id_in_category) { 99 const std::string& id_in_category) {
97 return ntp_snippets::ContentSuggestion::ID(category.category, id_in_category); 100 return ntp_snippets::ContentSuggestion::ID(category.category, id_in_category);
98 } 101 }
102
103 ContentSuggestion* EmptySuggestion() {
104 ContentSuggestion* suggestion = [[ContentSuggestion alloc] init];
105 suggestion.type = ContentSuggestionTypeEmpty;
106 suggestion.suggestionIdentifier = [[ContentSuggestionIdentifier alloc] init];
107
108 return suggestion;
109 }
110
111 ContentSuggestionsSectionInformation* MostVisitedSectionInformation() {
112 ContentSuggestionsSectionInformation* sectionInfo =
113 [[ContentSuggestionsSectionInformation alloc]
114 initWithSectionID:ContentSuggestionsSectionMostVisited];
115 sectionInfo.title = nil;
116 sectionInfo.footerTitle = nil;
117 sectionInfo.showIfEmpty = NO;
118 sectionInfo.layout = ContentSuggestionsSectionLayoutCustom;
119
120 return sectionInfo;
121 }
122
123 void RecordPageImpression(const ntp_tiles::NTPTilesVector& mostVisited) {
124 std::vector<ntp_tiles::metrics::TileImpression> tiles;
125 for (const ntp_tiles::NTPTile& ntpTile : mostVisited) {
126 tiles.emplace_back(ntpTile.source, ntp_tiles::UNKNOWN_TILE_TYPE,
127 ntpTile.url);
128 }
129 ntp_tiles::metrics::RecordPageImpression(
130 tiles, GetApplicationContext()->GetRapporServiceImpl());
131 }
132
133 ContentSuggestion* ConvertNTPTile(const ntp_tiles::NTPTile& tile) {
134 ContentSuggestion* suggestion = [[ContentSuggestion alloc] init];
135
136 suggestion.title = base::SysUTF16ToNSString(tile.title);
137 suggestion.url = tile.url;
138 suggestion.type = ContentSuggestionTypeMostVisited;
139
140 suggestion.suggestionIdentifier = [[ContentSuggestionIdentifier alloc] init];
141 suggestion.suggestionIdentifier.IDInSection = tile.url.spec();
142
143 return suggestion;
144 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/content_suggestions/mediator_util.h ('k') | ios/chrome/browser/ui/content_suggestions/content_suggestion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698