OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/history/top_sites_impl.h" | 5 #include "chrome/browser/history/top_sites_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/metrics/histogram.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/md5.h" | 14 #include "base/md5.h" |
14 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
15 #include "base/message_loop/message_loop_proxy.h" | 16 #include "base/message_loop/message_loop_proxy.h" |
16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "base/task_runner.h" | 20 #include "base/task_runner.h" |
20 #include "base/values.h" | 21 #include "base/values.h" |
21 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 IndexOf(*urls, prepopulate_urls[i].url) == -1) { | 685 IndexOf(*urls, prepopulate_urls[i].url) == -1) { |
685 urls->push_back(prepopulate_urls[i]); | 686 urls->push_back(prepopulate_urls[i]); |
686 added = true; | 687 added = true; |
687 } | 688 } |
688 } | 689 } |
689 return added; | 690 return added; |
690 } | 691 } |
691 | 692 |
692 void TopSitesImpl::ApplyBlacklist(const MostVisitedURLList& urls, | 693 void TopSitesImpl::ApplyBlacklist(const MostVisitedURLList& urls, |
693 MostVisitedURLList* out) { | 694 MostVisitedURLList* out) { |
| 695 // Log the number of times ApplyBlacklist is called so we can compute the |
| 696 // average number of blacklisted items per user. |
| 697 const DictionaryValue* blacklist = |
| 698 profile_->GetPrefs()->GetDictionary(prefs::kNtpMostVisitedURLsBlacklist); |
| 699 UMA_HISTOGRAM_BOOLEAN("TopSites.NumberOfApplyBlacklist", true); |
| 700 UMA_HISTOGRAM_COUNTS_100("TopSites.NumberOfBlacklistedItems", |
| 701 (blacklist ? blacklist->size() : 0)); |
694 for (size_t i = 0; i < urls.size() && i < kTopSitesNumber; ++i) { | 702 for (size_t i = 0; i < urls.size() && i < kTopSitesNumber; ++i) { |
695 if (!IsBlacklisted(urls[i].url)) | 703 if (!IsBlacklisted(urls[i].url)) |
696 out->push_back(urls[i]); | 704 out->push_back(urls[i]); |
697 } | 705 } |
698 } | 706 } |
699 | 707 |
700 std::string TopSitesImpl::GetURLHash(const GURL& url) { | 708 std::string TopSitesImpl::GetURLHash(const GURL& url) { |
701 // We don't use canonical URLs here to be able to blacklist only one of | 709 // We don't use canonical URLs here to be able to blacklist only one of |
702 // the two 'duplicate' sites, e.g. 'gmail.com' and 'mail.google.com'. | 710 // the two 'duplicate' sites, e.g. 'gmail.com' and 'mail.google.com'. |
703 return base::MD5String(url.spec()); | 711 return base::MD5String(url.spec()); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 SetTopSites(pages); | 944 SetTopSites(pages); |
937 | 945 |
938 // Used only in testing. | 946 // Used only in testing. |
939 content::NotificationService::current()->Notify( | 947 content::NotificationService::current()->Notify( |
940 chrome::NOTIFICATION_TOP_SITES_UPDATED, | 948 chrome::NOTIFICATION_TOP_SITES_UPDATED, |
941 content::Source<TopSitesImpl>(this), | 949 content::Source<TopSitesImpl>(this), |
942 content::Details<CancelableRequestProvider::Handle>(&handle)); | 950 content::Details<CancelableRequestProvider::Handle>(&handle)); |
943 } | 951 } |
944 | 952 |
945 } // namespace history | 953 } // namespace history |
OLD | NEW |