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 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 | 1155 |
1156 void InstantController::UpdateMostVisitedItems() { | 1156 void InstantController::UpdateMostVisitedItems() { |
1157 InstantService* instant_service = | 1157 InstantService* instant_service = |
1158 InstantServiceFactory::GetForProfile(profile()); | 1158 InstantServiceFactory::GetForProfile(profile()); |
1159 if (!instant_service) | 1159 if (!instant_service) |
1160 return; | 1160 return; |
1161 | 1161 |
1162 std::vector<InstantMostVisitedItem> items; | 1162 std::vector<InstantMostVisitedItem> items; |
1163 instant_service->GetCurrentMostVisitedItems(&items); | 1163 instant_service->GetCurrentMostVisitedItems(&items); |
1164 | 1164 |
1165 if (overlay_ && GetOverlayContents() && | 1165 if (overlay_) |
1166 SearchTabHelper::FromWebContents(overlay_->contents())-> | |
1167 UpdateLastKnownMostVisitedItems(items)) { | |
1168 overlay_->SendMostVisitedItems(items); | 1166 overlay_->SendMostVisitedItems(items); |
1169 } | |
1170 | 1167 |
1171 if (ntp_ && ntp_->contents() && | 1168 if (ntp_) |
1172 SearchTabHelper::FromWebContents(ntp_->contents())-> | |
1173 UpdateLastKnownMostVisitedItems(items)) { | |
1174 ntp_->SendMostVisitedItems(items); | 1169 ntp_->SendMostVisitedItems(items); |
1175 } | |
1176 | 1170 |
1177 if (instant_tab_ && instant_tab_->contents() && | 1171 if (instant_tab_) |
1178 SearchTabHelper::FromWebContents(instant_tab_->contents())-> | |
1179 UpdateLastKnownMostVisitedItems(items)) { | |
1180 instant_tab_->SendMostVisitedItems(items); | 1172 instant_tab_->SendMostVisitedItems(items); |
1181 } | |
1182 | 1173 |
1183 content::NotificationService::current()->Notify( | 1174 content::NotificationService::current()->Notify( |
1184 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, | 1175 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, |
1185 content::Source<InstantController>(this), | 1176 content::Source<InstantController>(this), |
1186 content::NotificationService::NoDetails()); | 1177 content::NotificationService::NoDetails()); |
1187 } | 1178 } |
1188 | 1179 |
1189 void InstantController::DeleteMostVisitedItem(const GURL& url) { | 1180 void InstantController::DeleteMostVisitedItem(const GURL& url) { |
1190 DCHECK(!url.is_empty()); | 1181 DCHECK(!url.is_empty()); |
1191 InstantService* instant_service = | 1182 InstantService* instant_service = |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 bool js_webkit_enabled = profile()->GetPrefs()->GetBoolean( | 1905 bool js_webkit_enabled = profile()->GetPrefs()->GetBoolean( |
1915 prefs::kWebKitJavascriptEnabled); | 1906 prefs::kWebKitJavascriptEnabled); |
1916 return js_content_enabled && js_webkit_enabled; | 1907 return js_content_enabled && js_webkit_enabled; |
1917 } | 1908 } |
1918 | 1909 |
1919 bool InstantController::InStartup() const { | 1910 bool InstantController::InStartup() const { |
1920 // TODO(shishir): This is not completely reliable. Find a better way to detect | 1911 // TODO(shishir): This is not completely reliable. Find a better way to detect |
1921 // startup time. | 1912 // startup time. |
1922 return !browser_->GetActiveWebContents(); | 1913 return !browser_->GetActiveWebContents(); |
1923 } | 1914 } |
OLD | NEW |