Index: chrome/browser/ui/search/instant_controller.cc |
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc |
index f4ba1a4f35081ff5ea043d8caccae9fe3e56a8f6..88ab61ba6fe50c5203b423f1a7894e3a5caafe2c 100644 |
--- a/chrome/browser/ui/search/instant_controller.cc |
+++ b/chrome/browser/ui/search/instant_controller.cc |
@@ -16,6 +16,7 @@ |
#include "chrome/browser/history/history_service.h" |
#include "chrome/browser/history/history_service_factory.h" |
#include "chrome/browser/history/history_tab_helper.h" |
+#include "chrome/browser/history/top_sites.h" |
#include "chrome/browser/platform_util.h" |
#include "chrome/browser/search/instant_service.h" |
#include "chrome/browser/search/instant_service_factory.h" |
@@ -28,6 +29,7 @@ |
#include "chrome/browser/ui/search/instant_overlay.h" |
#include "chrome/browser/ui/search/instant_tab.h" |
#include "chrome/browser/ui/search/search_tab_helper.h" |
+#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/url_constants.h" |
@@ -245,6 +247,17 @@ void DeletePageSoon(scoped_ptr<T> page) { |
base::MessageLoop::current()->DeleteSoon(FROM_HERE, page.release()); |
} |
+// Creates a set containing the canonical URLs of the currently open tabs. |
+void GetOpenUrls(const TabStripModel& tabs, |
+ const history::TopSites& ts, |
+ std::set<std::string>* urls) { |
+ for (int i = 0; i < tabs.count(); ++i) { |
+ content::WebContents* web_contents = tabs.GetWebContentsAt(i); |
+ if (web_contents) |
+ urls->insert(ts.GetCanonicalURLString(web_contents->GetURL())); |
+ } |
+} |
+ |
} // namespace |
InstantController::InstantController(BrowserInstantController* browser, |
@@ -1145,6 +1158,8 @@ void InstantController::UpdateMostVisitedItems() { |
std::vector<InstantMostVisitedItem> items; |
instant_service->GetCurrentMostVisitedItems(&items); |
+ MaybeRemoveMostVisitedItems(&items); |
+ |
if (overlay_ && GetOverlayContents() && |
SearchTabHelper::FromWebContents(overlay_->contents())-> |
UpdateLastKnownMostVisitedItems(items)) { |
@@ -1866,3 +1881,22 @@ void InstantController::PopulateInstantAutocompleteResultFromMatch( |
<< result->description << "' '" << result->search_query << "' " |
<< result->transition << " " << result->autocomplete_match_index; |
} |
+ |
+void InstantController::MaybeRemoveMostVisitedItems( |
+ std::vector<InstantMostVisitedItem>* items) { |
+#if !defined(OS_ANDROID) |
+ if (!history::TopSites::IsClientInTabsGroup()) |
+ return; |
+ |
+ TabStripModel* tab_strip_model = browser_->tab_strip_model(); |
+ history::TopSites* top_sites = browser_->profile()->GetTopSites(); |
+ if (!tab_strip_model || !top_sites) { |
+ NOTREACHED(); |
+ return; |
+ } |
+ |
+ std::set<std::string> open_urls; |
+ GetOpenUrls(*tab_strip_model, *top_sites, &open_urls); |
+ history::TopSites::RemoveItemsMatchingOpenTabs(open_urls, items); |
+#endif |
+} |