| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 Value* dummy = Value::CreateNullValue(); | 652 Value* dummy = Value::CreateNullValue(); |
| 653 blacklist_->SetWithoutPathExpansion(GetURLHash(url), dummy); | 653 blacklist_->SetWithoutPathExpansion(GetURLHash(url), dummy); |
| 654 } | 654 } |
| 655 | 655 |
| 656 bool TopSites::IsBlacklisted(const GURL& url) { | 656 bool TopSites::IsBlacklisted(const GURL& url) { |
| 657 bool result = blacklist_->HasKey(GetURLHash(url)); | 657 bool result = blacklist_->HasKey(GetURLHash(url)); |
| 658 return result; | 658 return result; |
| 659 } | 659 } |
| 660 | 660 |
| 661 void TopSites::RemoveBlacklistedURL(const GURL& url) { | 661 void TopSites::RemoveBlacklistedURL(const GURL& url) { |
| 662 Value* dummy = NULL; | 662 blacklist_->RemoveWithoutPathExpansion(GetURLHash(url), NULL); |
| 663 blacklist_->RemoveWithoutPathExpansion(GetURLHash(url), &dummy); | |
| 664 } | 663 } |
| 665 | 664 |
| 666 void TopSites::ClearBlacklistedURLs() { | 665 void TopSites::ClearBlacklistedURLs() { |
| 667 blacklist_->Clear(); | 666 blacklist_->Clear(); |
| 668 } | 667 } |
| 669 | 668 |
| 670 void TopSites::AddPinnedURL(const GURL& url, size_t pinned_index) { | 669 void TopSites::AddPinnedURL(const GURL& url, size_t pinned_index) { |
| 671 GURL old; | 670 GURL old; |
| 672 if (GetPinnedURLAtIndex(pinned_index, &old)) { | 671 if (GetPinnedURLAtIndex(pinned_index, &old)) { |
| 673 RemovePinnedURL(old); | 672 RemovePinnedURL(old); |
| 674 } | 673 } |
| 675 | 674 |
| 676 if (IsURLPinned(url)) { | 675 if (IsURLPinned(url)) { |
| 677 RemovePinnedURL(url); | 676 RemovePinnedURL(url); |
| 678 } | 677 } |
| 679 | 678 |
| 680 Value* index = Value::CreateIntegerValue(pinned_index); | 679 Value* index = Value::CreateIntegerValue(pinned_index); |
| 681 pinned_urls_->SetWithoutPathExpansion(GetURLString(url), index); | 680 pinned_urls_->SetWithoutPathExpansion(GetURLString(url), index); |
| 682 } | 681 } |
| 683 | 682 |
| 684 void TopSites::RemovePinnedURL(const GURL& url) { | 683 void TopSites::RemovePinnedURL(const GURL& url) { |
| 685 Value* dummy = NULL; | 684 pinned_urls_->RemoveWithoutPathExpansion(GetURLString(url), NULL); |
| 686 pinned_urls_->RemoveWithoutPathExpansion(GetURLString(url), &dummy); | |
| 687 } | 685 } |
| 688 | 686 |
| 689 bool TopSites::GetIndexOfPinnedURL(const GURL& url, size_t* index) { | 687 bool TopSites::GetIndexOfPinnedURL(const GURL& url, size_t* index) { |
| 690 int tmp; | 688 int tmp; |
| 691 bool result = pinned_urls_->GetIntegerWithoutPathExpansion( | 689 bool result = pinned_urls_->GetIntegerWithoutPathExpansion( |
| 692 GetURLString(url), &tmp); | 690 GetURLString(url), &tmp); |
| 693 *index = static_cast<size_t>(tmp); | 691 *index = static_cast<size_t>(tmp); |
| 694 return result; | 692 return result; |
| 695 } | 693 } |
| 696 | 694 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB)); | 821 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB)); |
| 824 db_.reset(new TopSitesDatabaseImpl()); | 822 db_.reset(new TopSitesDatabaseImpl()); |
| 825 file_util::Delete(db_path_, false); | 823 file_util::Delete(db_path_, false); |
| 826 if (!db_->Init(db_path_)) { | 824 if (!db_->Init(db_path_)) { |
| 827 NOTREACHED() << "Failed to initialize database."; | 825 NOTREACHED() << "Failed to initialize database."; |
| 828 return; | 826 return; |
| 829 } | 827 } |
| 830 } | 828 } |
| 831 | 829 |
| 832 } // namespace history | 830 } // namespace history |
| OLD | NEW |