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