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 "components/history/core/browser/top_sites_impl.h" | 5 #include "components/history/core/browser/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" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 bool TopSitesImpl::HasBlacklistedItems() const { | 312 bool TopSitesImpl::HasBlacklistedItems() const { |
313 const base::DictionaryValue* blacklist = | 313 const base::DictionaryValue* blacklist = |
314 pref_service_->GetDictionary(blacklist_pref_name_); | 314 pref_service_->GetDictionary(blacklist_pref_name_); |
315 return blacklist && !blacklist->empty(); | 315 return blacklist && !blacklist->empty(); |
316 } | 316 } |
317 | 317 |
318 void TopSitesImpl::AddBlacklistedURL(const GURL& url) { | 318 void TopSitesImpl::AddBlacklistedURL(const GURL& url) { |
319 DCHECK(thread_checker_.CalledOnValidThread()); | 319 DCHECK(thread_checker_.CalledOnValidThread()); |
320 | 320 |
321 base::Value* dummy = base::Value::CreateNullValue(); | 321 scoped_ptr<base::Value> dummy = base::Value::CreateNullValue(); |
322 { | 322 { |
323 DictionaryPrefUpdate update(pref_service_, blacklist_pref_name_); | 323 DictionaryPrefUpdate update(pref_service_, blacklist_pref_name_); |
324 base::DictionaryValue* blacklist = update.Get(); | 324 base::DictionaryValue* blacklist = update.Get(); |
325 blacklist->SetWithoutPathExpansion(GetURLHash(url), dummy); | 325 blacklist->SetWithoutPathExpansion(GetURLHash(url), dummy.Pass()); |
326 } | 326 } |
327 | 327 |
328 ResetThreadSafeCache(); | 328 ResetThreadSafeCache(); |
329 NotifyTopSitesChanged(); | 329 NotifyTopSitesChanged(); |
330 } | 330 } |
331 | 331 |
332 void TopSitesImpl::RemoveBlacklistedURL(const GURL& url) { | 332 void TopSitesImpl::RemoveBlacklistedURL(const GURL& url) { |
333 DCHECK(thread_checker_.CalledOnValidThread()); | 333 DCHECK(thread_checker_.CalledOnValidThread()); |
334 { | 334 { |
335 DictionaryPrefUpdate update(pref_service_, blacklist_pref_name_); | 335 DictionaryPrefUpdate update(pref_service_, blacklist_pref_name_); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 for (std::set<size_t>::reverse_iterator i = indices_to_delete.rbegin(); | 906 for (std::set<size_t>::reverse_iterator i = indices_to_delete.rbegin(); |
907 i != indices_to_delete.rend(); i++) { | 907 i != indices_to_delete.rend(); i++) { |
908 new_top_sites.erase(new_top_sites.begin() + *i); | 908 new_top_sites.erase(new_top_sites.begin() + *i); |
909 } | 909 } |
910 SetTopSites(new_top_sites, CALL_LOCATION_FROM_OTHER_PLACES); | 910 SetTopSites(new_top_sites, CALL_LOCATION_FROM_OTHER_PLACES); |
911 } | 911 } |
912 StartQueryForMostVisited(); | 912 StartQueryForMostVisited(); |
913 } | 913 } |
914 | 914 |
915 } // namespace history | 915 } // namespace history |
OLD | NEW |