| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/search/instant_controller.h" | 5 #include "chrome/browser/ui/search/instant_controller.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 void InstantController::UpdateMostVisitedItems() { | 1164 void InstantController::UpdateMostVisitedItems() { |
| 1165 InstantService* instant_service = GetInstantService(); | 1165 InstantService* instant_service = GetInstantService(); |
| 1166 if (!instant_service) | 1166 if (!instant_service) |
| 1167 return; | 1167 return; |
| 1168 | 1168 |
| 1169 std::vector<InstantMostVisitedItem> items; | 1169 std::vector<InstantMostVisitedItem> items; |
| 1170 instant_service->GetCurrentMostVisitedItems(&items); | 1170 instant_service->GetCurrentMostVisitedItems(&items); |
| 1171 | 1171 |
| 1172 if (overlay_ && GetOverlayContents() && | 1172 if (overlay_) |
| 1173 SearchTabHelper::FromWebContents(overlay_->contents())-> | |
| 1174 UpdateLastKnownMostVisitedItems(items)) { | |
| 1175 overlay_->sender()->SendMostVisitedItems(items); | 1173 overlay_->sender()->SendMostVisitedItems(items); |
| 1176 } | |
| 1177 | 1174 |
| 1178 if (ntp_ && ntp_->contents() && | 1175 if (ntp_) |
| 1179 SearchTabHelper::FromWebContents(ntp_->contents())-> | |
| 1180 UpdateLastKnownMostVisitedItems(items)) { | |
| 1181 ntp_->sender()->SendMostVisitedItems(items); | 1176 ntp_->sender()->SendMostVisitedItems(items); |
| 1182 } | |
| 1183 | 1177 |
| 1184 if (instant_tab_ && instant_tab_->contents() && | 1178 if (instant_tab_) |
| 1185 SearchTabHelper::FromWebContents(instant_tab_->contents())-> | |
| 1186 UpdateLastKnownMostVisitedItems(items)) { | |
| 1187 instant_tab_->sender()->SendMostVisitedItems(items); | 1179 instant_tab_->sender()->SendMostVisitedItems(items); |
| 1188 } | |
| 1189 | 1180 |
| 1190 content::NotificationService::current()->Notify( | 1181 content::NotificationService::current()->Notify( |
| 1191 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, | 1182 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, |
| 1192 content::Source<InstantController>(this), | 1183 content::Source<InstantController>(this), |
| 1193 content::NotificationService::NoDetails()); | 1184 content::NotificationService::NoDetails()); |
| 1194 } | 1185 } |
| 1195 | 1186 |
| 1196 void InstantController::DeleteMostVisitedItem(const GURL& url) { | 1187 void InstantController::DeleteMostVisitedItem(const GURL& url) { |
| 1197 DCHECK(!url.is_empty()); | 1188 DCHECK(!url.is_empty()); |
| 1198 InstantService* instant_service = GetInstantService(); | 1189 InstantService* instant_service = GetInstantService(); |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 | 1920 |
| 1930 bool InstantController::InStartup() const { | 1921 bool InstantController::InStartup() const { |
| 1931 // TODO(shishir): This is not completely reliable. Find a better way to detect | 1922 // TODO(shishir): This is not completely reliable. Find a better way to detect |
| 1932 // startup time. | 1923 // startup time. |
| 1933 return !browser_->GetActiveWebContents(); | 1924 return !browser_->GetActiveWebContents(); |
| 1934 } | 1925 } |
| 1935 | 1926 |
| 1936 InstantService* InstantController::GetInstantService() const { | 1927 InstantService* InstantController::GetInstantService() const { |
| 1937 return InstantServiceFactory::GetForProfile(profile()); | 1928 return InstantServiceFactory::GetForProfile(profile()); |
| 1938 } | 1929 } |
| OLD | NEW |