| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/history/top_sites.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 357 } |
| 358 | 358 |
| 359 bool TopSites::HasBlacklistedItems() const { | 359 bool TopSites::HasBlacklistedItems() const { |
| 360 return !blacklist_->empty(); | 360 return !blacklist_->empty(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void TopSites::AddBlacklistedURL(const GURL& url) { | 363 void TopSites::AddBlacklistedURL(const GURL& url) { |
| 364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 365 | 365 |
| 366 RemovePinnedURL(url); | 366 RemovePinnedURL(url); |
| 367 Value* dummy = Value::CreateNullValue(); | 367 Value* dummy = base::NullValue(); |
| 368 { | 368 { |
| 369 DictionaryPrefUpdate update(profile_->GetPrefs(), | 369 DictionaryPrefUpdate update(profile_->GetPrefs(), |
| 370 prefs::kNTPMostVisitedURLsBlacklist); | 370 prefs::kNTPMostVisitedURLsBlacklist); |
| 371 DictionaryValue* blacklist = update.Get(); | 371 DictionaryValue* blacklist = update.Get(); |
| 372 blacklist->SetWithoutPathExpansion(GetURLHash(url), dummy); | 372 blacklist->SetWithoutPathExpansion(GetURLHash(url), dummy); |
| 373 } | 373 } |
| 374 | 374 |
| 375 ResetThreadSafeCache(); | 375 ResetThreadSafeCache(); |
| 376 NotifyTopSitesChanged(); | 376 NotifyTopSitesChanged(); |
| 377 } | 377 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 408 void TopSites::AddPinnedURL(const GURL& url, size_t pinned_index) { | 408 void TopSites::AddPinnedURL(const GURL& url, size_t pinned_index) { |
| 409 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 409 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 410 | 410 |
| 411 GURL old; | 411 GURL old; |
| 412 if (GetPinnedURLAtIndex(pinned_index, &old)) | 412 if (GetPinnedURLAtIndex(pinned_index, &old)) |
| 413 RemovePinnedURL(old); | 413 RemovePinnedURL(old); |
| 414 | 414 |
| 415 if (IsURLPinned(url)) | 415 if (IsURLPinned(url)) |
| 416 RemovePinnedURL(url); | 416 RemovePinnedURL(url); |
| 417 | 417 |
| 418 Value* index = Value::CreateIntegerValue(pinned_index); | 418 Value* index = base::NumberValue::New(static_cast<int>(pinned_index)); |
| 419 | 419 |
| 420 { | 420 { |
| 421 DictionaryPrefUpdate update(profile_->GetPrefs(), | 421 DictionaryPrefUpdate update(profile_->GetPrefs(), |
| 422 prefs::kNTPMostVisitedPinnedURLs); | 422 prefs::kNTPMostVisitedPinnedURLs); |
| 423 DictionaryValue* pinned_urls = update.Get(); | 423 DictionaryValue* pinned_urls = update.Get(); |
| 424 pinned_urls->SetWithoutPathExpansion(GetURLString(url), index); | 424 pinned_urls->SetWithoutPathExpansion(GetURLString(url), index); |
| 425 } | 425 } |
| 426 | 426 |
| 427 ResetThreadSafeCache(); | 427 ResetThreadSafeCache(); |
| 428 NotifyTopSitesChanged(); | 428 NotifyTopSitesChanged(); |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 SetTopSites(pages); | 1006 SetTopSites(pages); |
| 1007 | 1007 |
| 1008 // Used only in testing. | 1008 // Used only in testing. |
| 1009 NotificationService::current()->Notify( | 1009 NotificationService::current()->Notify( |
| 1010 chrome::NOTIFICATION_TOP_SITES_UPDATED, | 1010 chrome::NOTIFICATION_TOP_SITES_UPDATED, |
| 1011 Source<TopSites>(this), | 1011 Source<TopSites>(this), |
| 1012 Details<CancelableRequestProvider::Handle>(&handle)); | 1012 Details<CancelableRequestProvider::Handle>(&handle)); |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 } // namespace history | 1015 } // namespace history |
| OLD | NEW |