| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "components/ntp_tiles/most_visited_sites.h" | 5 #include "components/ntp_tiles/most_visited_sites.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 // The whole grid is already filled with personal tiles, no point in bothering | 117 // The whole grid is already filled with personal tiles, no point in bothering |
| 118 // with popular ones. | 118 // with popular ones. |
| 119 return false; | 119 return false; |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool AreURLsEquivalent(const GURL& url1, const GURL& url2) { | 122 bool AreURLsEquivalent(const GURL& url1, const GURL& url2) { |
| 123 return url1.host() == url2.host() && url1.path() == url2.path(); | 123 return url1.host() == url2.host() && url1.path() == url2.path(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 std::string GetSourceHistogramName(int source) { | 126 std::string GetSourceHistogramName(NTPTileSource source) { |
| 127 switch (source) { | 127 switch (source) { |
| 128 case static_cast<int>(NTPTileSource::TOP_SITES): | 128 case NTPTileSource::TOP_SITES: |
| 129 return kHistogramClientName; | 129 return kHistogramClientName; |
| 130 case static_cast<int>(NTPTileSource::POPULAR): | 130 case NTPTileSource::POPULAR: |
| 131 return kHistogramPopularName; | 131 return kHistogramPopularName; |
| 132 case static_cast<int>(NTPTileSource::WHITELIST): | 132 case NTPTileSource::WHITELIST: |
| 133 return kHistogramWhitelistName; | 133 return kHistogramWhitelistName; |
| 134 case static_cast<int>(NTPTileSource::SUGGESTIONS_SERVICE): | 134 case NTPTileSource::SUGGESTIONS_SERVICE: |
| 135 return kHistogramServerName; | 135 return kHistogramServerName; |
| 136 } | 136 } |
| 137 NOTREACHED(); | 137 NOTREACHED(); |
| 138 return std::string(); | 138 return std::string(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace | 141 } // namespace |
| 142 | 142 |
| 143 MostVisitedSites::MostVisitedSites(PrefService* prefs, | 143 MostVisitedSites::MostVisitedSites(PrefService* prefs, |
| 144 scoped_refptr<history::TopSites> top_sites, | 144 scoped_refptr<history::TopSites> top_sites, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 if (mv_source_ == NTPTileSource::SUGGESTIONS_SERVICE) { | 220 if (mv_source_ == NTPTileSource::SUGGESTIONS_SERVICE) { |
| 221 if (add_url) | 221 if (add_url) |
| 222 suggestions_service_->BlacklistURL(url); | 222 suggestions_service_->BlacklistURL(url); |
| 223 else | 223 else |
| 224 suggestions_service_->UndoBlacklistURL(url); | 224 suggestions_service_->UndoBlacklistURL(url); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 void MostVisitedSites::RecordTileTypeMetrics( | 228 void MostVisitedSites::RecordTileTypeMetrics( |
| 229 const std::vector<int>& tile_types, | 229 const std::vector<int>& tile_types, |
| 230 const std::vector<int>& sources) { | 230 const std::vector<NTPTileSource>& sources) { |
| 231 int counts_per_type[NUM_TILE_TYPES] = {0}; | 231 int counts_per_type[NUM_TILE_TYPES] = {0}; |
| 232 for (size_t i = 0; i < tile_types.size(); ++i) { | 232 for (size_t i = 0; i < tile_types.size(); ++i) { |
| 233 int tile_type = tile_types[i]; | 233 int tile_type = tile_types[i]; |
| 234 ++counts_per_type[tile_type]; | 234 ++counts_per_type[tile_type]; |
| 235 | 235 |
| 236 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileType", tile_type, NUM_TILE_TYPES); | 236 UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileType", tile_type, NUM_TILE_TYPES); |
| 237 | 237 |
| 238 std::string histogram = base::StringPrintf( | 238 std::string histogram = base::StringPrintf( |
| 239 "NewTabPage.TileType.%s", | 239 "NewTabPage.TileType.%s", |
| 240 GetSourceHistogramName(sources[i]).c_str()); | 240 GetSourceHistogramName(sources[i]).c_str()); |
| 241 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); | 241 LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); |
| 242 } | 242 } |
| 243 | 243 |
| 244 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal", | 244 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsReal", |
| 245 counts_per_type[ICON_REAL]); | 245 counts_per_type[ICON_REAL]); |
| 246 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor", | 246 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsColor", |
| 247 counts_per_type[ICON_COLOR]); | 247 counts_per_type[ICON_COLOR]); |
| 248 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray", | 248 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.IconsGray", |
| 249 counts_per_type[ICON_DEFAULT]); | 249 counts_per_type[ICON_DEFAULT]); |
| 250 } | 250 } |
| 251 | 251 |
| 252 void MostVisitedSites::RecordOpenedMostVisitedItem(int index, | 252 void MostVisitedSites::RecordOpenedMostVisitedItem(int index, |
| 253 int tile_type, | 253 int tile_type, |
| 254 int source) { | 254 NTPTileSource source) { |
| 255 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, num_sites_); | 255 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisited", index, num_sites_); |
| 256 | 256 |
| 257 std::string histogram = base::StringPrintf( | 257 std::string histogram = base::StringPrintf( |
| 258 "NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str()); | 258 "NewTabPage.MostVisited.%s", GetSourceHistogramName(source).c_str()); |
| 259 LogHistogramEvent(histogram, index, num_sites_); | 259 LogHistogramEvent(histogram, index, num_sites_); |
| 260 | 260 |
| 261 UMA_HISTOGRAM_ENUMERATION( | 261 UMA_HISTOGRAM_ENUMERATION( |
| 262 "NewTabPage.TileTypeClicked", tile_type, NUM_TILE_TYPES); | 262 "NewTabPage.TileTypeClicked", tile_type, NUM_TILE_TYPES); |
| 263 | 263 |
| 264 histogram = base::StringPrintf("NewTabPage.TileTypeClicked.%s", | 264 histogram = base::StringPrintf("NewTabPage.TileTypeClicked.%s", |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 void MostVisitedSites::RecordImpressionUMAMetrics() { | 527 void MostVisitedSites::RecordImpressionUMAMetrics() { |
| 528 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", | 528 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", |
| 529 current_tiles_.size()); | 529 current_tiles_.size()); |
| 530 | 530 |
| 531 for (size_t i = 0; i < current_tiles_.size(); i++) { | 531 for (size_t i = 0; i < current_tiles_.size(); i++) { |
| 532 UMA_HISTOGRAM_ENUMERATION( | 532 UMA_HISTOGRAM_ENUMERATION( |
| 533 "NewTabPage.SuggestionsImpression", static_cast<int>(i), num_sites_); | 533 "NewTabPage.SuggestionsImpression", static_cast<int>(i), num_sites_); |
| 534 | 534 |
| 535 std::string histogram = base::StringPrintf( | 535 std::string histogram = base::StringPrintf( |
| 536 "NewTabPage.SuggestionsImpression.%s", | 536 "NewTabPage.SuggestionsImpression.%s", |
| 537 GetSourceHistogramName(static_cast<int>(current_tiles_[i].source)) | 537 GetSourceHistogramName(current_tiles_[i].source).c_str()); |
| 538 .c_str()); | |
| 539 LogHistogramEvent(histogram, static_cast<int>(i), num_sites_); | 538 LogHistogramEvent(histogram, static_cast<int>(i), num_sites_); |
| 540 } | 539 } |
| 541 } | 540 } |
| 542 | 541 |
| 543 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {} | 542 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {} |
| 544 | 543 |
| 545 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, | 544 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, |
| 546 ChangeReason change_reason) { | 545 ChangeReason change_reason) { |
| 547 if (mv_source_ == NTPTileSource::TOP_SITES) { | 546 if (mv_source_ == NTPTileSource::TOP_SITES) { |
| 548 // The displayed tiles are invalidated. | 547 // The displayed tiles are invalidated. |
| 549 InitiateTopSitesQuery(); | 548 InitiateTopSitesQuery(); |
| 550 } | 549 } |
| 551 } | 550 } |
| 552 | 551 |
| 553 } // namespace ntp_tiles | 552 } // namespace ntp_tiles |
| OLD | NEW |