| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/webui/browsing_history_handler.h" | 5 #include "chrome/browser/ui/webui/browsing_history_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 // through some sort of delegate. | 612 // through some sort of delegate. |
| 613 Browser* browser = chrome::FindBrowserWithWebContents( | 613 Browser* browser = chrome::FindBrowserWithWebContents( |
| 614 web_ui()->GetWebContents()); | 614 web_ui()->GetWebContents()); |
| 615 chrome::ShowClearBrowsingDataDialog(browser); | 615 chrome::ShowClearBrowsingDataDialog(browser); |
| 616 #endif | 616 #endif |
| 617 } | 617 } |
| 618 | 618 |
| 619 void BrowsingHistoryHandler::HandleRemoveBookmark(const base::ListValue* args) { | 619 void BrowsingHistoryHandler::HandleRemoveBookmark(const base::ListValue* args) { |
| 620 base::string16 url = ExtractStringValue(args); | 620 base::string16 url = ExtractStringValue(args); |
| 621 Profile* profile = Profile::FromWebUI(web_ui()); | 621 Profile* profile = Profile::FromWebUI(web_ui()); |
| 622 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); | 622 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); |
| 623 bookmarks::RemoveAllBookmarks(model, GURL(url)); | 623 bookmarks::RemoveAllBookmarks(model, GURL(url)); |
| 624 } | 624 } |
| 625 | 625 |
| 626 // static | 626 // static |
| 627 void BrowsingHistoryHandler::MergeDuplicateResults( | 627 void BrowsingHistoryHandler::MergeDuplicateResults( |
| 628 std::vector<BrowsingHistoryHandler::HistoryEntry>* results) { | 628 std::vector<BrowsingHistoryHandler::HistoryEntry>* results) { |
| 629 std::vector<BrowsingHistoryHandler::HistoryEntry> new_results; | 629 std::vector<BrowsingHistoryHandler::HistoryEntry> new_results; |
| 630 // Pre-reserve the size of the new vector. Since we're working with pointers | 630 // Pre-reserve the size of the new vector. Since we're working with pointers |
| 631 // later on not doing this could lead to the vector being resized and to | 631 // later on not doing this could lead to the vector being resized and to |
| 632 // pointers to invalid locations. | 632 // pointers to invalid locations. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 entry->entry_type = | 664 entry->entry_type = |
| 665 BrowsingHistoryHandler::HistoryEntry::COMBINED_ENTRY; | 665 BrowsingHistoryHandler::HistoryEntry::COMBINED_ENTRY; |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 } | 668 } |
| 669 results->swap(new_results); | 669 results->swap(new_results); |
| 670 } | 670 } |
| 671 | 671 |
| 672 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { | 672 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { |
| 673 Profile* profile = Profile::FromWebUI(web_ui()); | 673 Profile* profile = Profile::FromWebUI(web_ui()); |
| 674 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile); | 674 BookmarkModel* bookmark_model = |
| 675 BookmarkModelFactory::GetForBrowserContext(profile); |
| 675 SupervisedUserService* supervised_user_service = NULL; | 676 SupervisedUserService* supervised_user_service = NULL; |
| 676 #if defined(ENABLE_SUPERVISED_USERS) | 677 #if defined(ENABLE_SUPERVISED_USERS) |
| 677 if (profile->IsSupervised()) | 678 if (profile->IsSupervised()) |
| 678 supervised_user_service = | 679 supervised_user_service = |
| 679 SupervisedUserServiceFactory::GetForProfile(profile); | 680 SupervisedUserServiceFactory::GetForProfile(profile); |
| 680 #endif | 681 #endif |
| 681 ProfileSyncService* sync_service = | 682 ProfileSyncService* sync_service = |
| 682 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 683 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
| 683 | 684 |
| 684 // Combine the local and remote results into |query_results_|, and remove | 685 // Combine the local and remote results into |query_results_|, and remove |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 | 953 |
| 953 void BrowsingHistoryHandler::OnURLsDeleted( | 954 void BrowsingHistoryHandler::OnURLsDeleted( |
| 954 history::HistoryService* history_service, | 955 history::HistoryService* history_service, |
| 955 bool all_history, | 956 bool all_history, |
| 956 bool expired, | 957 bool expired, |
| 957 const history::URLRows& deleted_rows, | 958 const history::URLRows& deleted_rows, |
| 958 const std::set<GURL>& favicon_urls) { | 959 const std::set<GURL>& favicon_urls) { |
| 959 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) | 960 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) |
| 960 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); | 961 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); |
| 961 } | 962 } |
| OLD | NEW |