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 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 browser_->OpenURL(url, transition, disposition); | 1210 browser_->OpenURL(url, transition, disposition); |
1211 } | 1211 } |
1212 | 1212 |
1213 void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) { | 1213 void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) { |
1214 // If the overlay is showing custom NTP content, don't hide it, commit it | 1214 // If the overlay is showing custom NTP content, don't hide it, commit it |
1215 // (no matter where the user clicked) or try to recreate it. | 1215 // (no matter where the user clicked) or try to recreate it. |
1216 if (model_.mode().is_ntp()) | 1216 if (model_.mode().is_ntp()) |
1217 return; | 1217 return; |
1218 | 1218 |
1219 if (model_.mode().is_default()) { | 1219 if (model_.mode().is_default()) { |
1220 // Correct search terms if the user clicked on the committed results page | |
1221 // while showing an autocomplete suggestion | |
1222 if (UseInstantTabToShowSuggestions() && !last_suggestion_.text.empty() && | |
1223 last_suggestion_.behavior == INSTANT_COMPLETE_NEVER && | |
1224 IsViewInContents(GetViewGainingFocus(view_gaining_focus), | |
1225 instant_tab_->contents())) { | |
1226 // Commit the omnibox's suggested grey text as if the user had typed it. | |
1227 browser_->CommitSuggestedText(true); | |
1228 | |
1229 // Update the state so that next query from hitting Enter from the | |
1230 // omnibox is correct. | |
1231 last_omnibox_text_ += last_suggestion_.text; | |
1232 last_suggestion_ = InstantSuggestion(); | |
1233 } | |
1234 // If the overlay is not showing at all, recreate it if it's stale. | 1220 // If the overlay is not showing at all, recreate it if it's stale. |
1235 ReloadOverlayIfStale(); | 1221 ReloadOverlayIfStale(); |
1236 MaybeSwitchToRemoteOverlay(); | 1222 MaybeSwitchToRemoteOverlay(); |
1237 return; | 1223 return; |
1238 } | 1224 } |
1239 | 1225 |
1240 // The overlay is showing search suggestions. If GetOverlayContents() is NULL, | 1226 // The overlay is showing search suggestions. If GetOverlayContents() is NULL, |
1241 // we are in the commit path. Don't do anything. | 1227 // we are in the commit path. Don't do anything. |
1242 if (!GetOverlayContents()) | 1228 if (!GetOverlayContents()) |
1243 return; | 1229 return; |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 | 1608 |
1623 // If this is not window startup, switch. | 1609 // If this is not window startup, switch. |
1624 // TODO(shishir): This is not completely reliable. Find a better way to detect | 1610 // TODO(shishir): This is not completely reliable. Find a better way to detect |
1625 // startup time. | 1611 // startup time. |
1626 if (browser_->GetActiveWebContents()) | 1612 if (browser_->GetActiveWebContents()) |
1627 return true; | 1613 return true; |
1628 | 1614 |
1629 return chrome::IsAggressiveLocalNTPFallbackEnabled(); | 1615 return chrome::IsAggressiveLocalNTPFallbackEnabled(); |
1630 } | 1616 } |
1631 | 1617 |
OLD | NEW |