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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 !IsContentsFrom(instant_tab(), contents)) | 1111 !IsContentsFrom(instant_tab(), contents)) |
1112 return; | 1112 return; |
1113 if (IsContentsFrom(overlay(), contents) && | 1113 if (IsContentsFrom(overlay(), contents) && |
1114 !allow_overlay_to_show_search_suggestions_) | 1114 !allow_overlay_to_show_search_suggestions_) |
1115 return; | 1115 return; |
1116 | 1116 |
1117 InstantSuggestion suggestion; | 1117 InstantSuggestion suggestion; |
1118 if (!suggestions.empty()) | 1118 if (!suggestions.empty()) |
1119 suggestion = suggestions[0]; | 1119 suggestion = suggestions[0]; |
1120 | 1120 |
| 1121 // TODO(samarth): allow InstantTabs to call SetSuggestions() from the NTP once |
| 1122 // that is better supported. |
1121 bool can_use_instant_tab = UseInstantTabToShowSuggestions() && | 1123 bool can_use_instant_tab = UseInstantTabToShowSuggestions() && |
1122 !search_mode_.is_default(); | 1124 search_mode_.is_search(); |
1123 bool can_use_overlay = search_mode_.is_search_suggestions() && | 1125 bool can_use_overlay = search_mode_.is_search_suggestions() && |
1124 !last_omnibox_text_.empty(); | 1126 !last_omnibox_text_.empty(); |
1125 if (!can_use_instant_tab && !can_use_overlay) | 1127 if (!can_use_instant_tab && !can_use_overlay) |
1126 return; | 1128 return; |
1127 | 1129 |
1128 if (suggestion.behavior == INSTANT_COMPLETE_REPLACE) { | 1130 if (suggestion.behavior == INSTANT_COMPLETE_REPLACE) { |
1129 // We don't get an Update() when changing the omnibox due to a REPLACE | 1131 // We don't get an Update() when changing the omnibox due to a REPLACE |
1130 // suggestion (so that we don't inadvertently cause the overlay to change | 1132 // suggestion (so that we don't inadvertently cause the overlay to change |
1131 // what it's showing, as the user arrows up/down through the page-provided | 1133 // what it's showing, as the user arrows up/down through the page-provided |
1132 // suggestions). So, update these state variables here. | 1134 // suggestions). So, update these state variables here. |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 | 1626 |
1625 // If this is not window startup, switch. | 1627 // If this is not window startup, switch. |
1626 // TODO(shishir): This is not completely reliable. Find a better way to detect | 1628 // TODO(shishir): This is not completely reliable. Find a better way to detect |
1627 // startup time. | 1629 // startup time. |
1628 if (browser_->GetActiveWebContents()) | 1630 if (browser_->GetActiveWebContents()) |
1629 return true; | 1631 return true; |
1630 | 1632 |
1631 return chrome::IsAggressiveLocalNTPFallbackEnabled(); | 1633 return chrome::IsAggressiveLocalNTPFallbackEnabled(); |
1632 } | 1634 } |
1633 | 1635 |
OLD | NEW |