Chromium Code Reviews| Index: chrome/browser/instant/instant_controller.cc |
| diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc |
| index 0d736b6b744e4588bbb825593f7664fe11947c76..ea2f98d542681b1b33fbf48e65017947edf103b7 100644 |
| --- a/chrome/browser/instant/instant_controller.cc |
| +++ b/chrome/browser/instant/instant_controller.cc |
| @@ -197,23 +197,20 @@ void EnsureSearchTermsAreSet(content::WebContents* contents, |
| NavigationEntryUpdated(); |
| } |
| -bool GetURLForMostVisitedItemId(Profile* profile, |
| - uint64 most_visited_item_id, |
| +bool GetURLForMostVisitedItemID(Profile* profile, |
| + InstantRestrictedID restricted_id, |
|
dhollowa
2013/03/14 00:02:43
Keep |most_visited_item_id|.
Shishir
2013/03/14 19:53:03
Done.
|
| GURL* url) { |
| InstantService* instant_service = |
| InstantServiceFactory::GetForProfile(profile); |
| if (!instant_service) |
| return false; |
| - return instant_service->GetURLForMostVisitedItemId(most_visited_item_id, url); |
| -} |
| -// Creates a new restriced id if one is not found. |
| -size_t GetMostVisitedItemIDForURL(Profile* profile, const GURL& url) { |
| - InstantService* instant_service = |
| - InstantServiceFactory::GetForProfile(profile); |
| - if (!instant_service) |
| - return 0; |
| - return instant_service->AddURL(url); |
| + InstantMostVisitedItem item; |
| + if (!instant_service->GetMostVisitedItemForID(restricted_id, &item)) |
| + return false; |
| + |
| + *url = item.url; |
| + return true; |
| } |
| } // namespace |
| @@ -889,25 +886,25 @@ void InstantController::ClearDebugEvents() { |
| debug_events_.clear(); |
| } |
| -void InstantController::DeleteMostVisitedItem(uint64 most_visited_item_id) { |
| +void InstantController::DeleteMostVisitedItem( |
| + InstantRestrictedID restricted_id) { |
|
dhollowa
2013/03/14 00:02:43
Keep |most_visited_item_id|. (Throughout).
Shishir
2013/03/14 19:53:03
Done.
|
| history::TopSites* top_sites = browser_->profile()->GetTopSites(); |
| if (!top_sites) |
| return; |
| GURL url; |
| - if (GetURLForMostVisitedItemId(browser_->profile(), |
| - most_visited_item_id, &url)) |
| + if (GetURLForMostVisitedItemID(browser_->profile(), restricted_id, &url)) |
| top_sites->AddBlacklistedURL(url); |
| } |
| -void InstantController::UndoMostVisitedDeletion(uint64 most_visited_item_id) { |
| +void InstantController::UndoMostVisitedDeletion( |
| + InstantRestrictedID restricted_id) { |
| history::TopSites* top_sites = browser_->profile()->GetTopSites(); |
| if (!top_sites) |
| return; |
| GURL url; |
| - if (GetURLForMostVisitedItemId(browser_->profile(), |
| - most_visited_item_id, &url)) |
| + if (GetURLForMostVisitedItemID(browser_->profile(), restricted_id, &url)) |
| top_sites->RemoveBlacklistedURL(url); |
| } |
| @@ -1495,23 +1492,29 @@ void InstantController::RequestMostVisitedItems() { |
| void InstantController::OnMostVisitedItemsReceived( |
| const history::MostVisitedURLList& data) { |
| + InstantService* instant_service = |
| + InstantServiceFactory::GetForProfile(browser_->profile()); |
| + if (!instant_service) |
| + return; |
| + |
| std::vector<InstantMostVisitedItem> most_visited_items; |
| for (size_t i = 0; i < data.size(); i++) { |
| const history::MostVisitedURL& url = data[i]; |
| - |
| InstantMostVisitedItem item; |
| - item.most_visited_item_id = GetMostVisitedItemIDForURL(browser_->profile(), |
| - url.url); |
| item.url = url.url; |
| item.title = url.title; |
| - |
| most_visited_items.push_back(item); |
| } |
| - SendMostVisitedItems(most_visited_items); |
| + |
| + instant_service->AddMostVisitedItems(most_visited_items); |
| + |
| + std::vector<InstantMostVisitedItemIDPair> items_with_ids; |
| + instant_service->GetCurrentMostVisitedItems(&items_with_ids); |
| + SendMostVisitedItems(items_with_ids); |
| } |
| void InstantController::SendMostVisitedItems( |
| - const std::vector<InstantMostVisitedItem>& items) { |
| + const std::vector<InstantMostVisitedItemIDPair>& items) { |
| if (overlay_) |
| overlay_->SendMostVisitedItems(items); |
| if (ntp_) |