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