Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/ui/search/instant_controller.cc

Issue 12792013: Instant extended: Remove suggest commit on lost focus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 browser_->OpenURL(url, transition, disposition); 1234 browser_->OpenURL(url, transition, disposition);
1235 } 1235 }
1236 1236
1237 void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) { 1237 void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) {
1238 // If the overlay is showing custom NTP content, don't hide it, commit it 1238 // If the overlay is showing custom NTP content, don't hide it, commit it
1239 // (no matter where the user clicked) or try to recreate it. 1239 // (no matter where the user clicked) or try to recreate it.
1240 if (model_.mode().is_ntp()) 1240 if (model_.mode().is_ntp())
1241 return; 1241 return;
1242 1242
1243 if (model_.mode().is_default()) { 1243 if (model_.mode().is_default()) {
1244 // Correct search terms if the user clicked on the committed results page
1245 // while showing an autocomplete suggestion
1246 if (instant_tab_ && !last_suggestion_.text.empty() &&
1247 last_suggestion_.behavior == INSTANT_COMPLETE_NEVER &&
1248 IsViewInContents(GetViewGainingFocus(view_gaining_focus),
1249 instant_tab_->contents())) {
1250 // Commit the omnibox's suggested grey text as if the user had typed it.
1251 browser_->CommitSuggestedText(true);
1252
1253 // Update the state so that next query from hitting Enter from the
1254 // omnibox is correct.
1255 last_omnibox_text_ += last_suggestion_.text;
1256 last_suggestion_ = InstantSuggestion();
1257 }
1258 // If the overlay is not showing at all, recreate it if it's stale. 1244 // If the overlay is not showing at all, recreate it if it's stale.
1259 ReloadOverlayIfStale(); 1245 ReloadOverlayIfStale();
1260 MaybeSwitchToRemoteOverlay(); 1246 MaybeSwitchToRemoteOverlay();
1261 return; 1247 return;
1262 } 1248 }
1263 1249
1264 // The overlay is showing search suggestions. If GetOverlayContents() is NULL, 1250 // The overlay is showing search suggestions. If GetOverlayContents() is NULL,
1265 // we are in the commit path. Don't do anything. 1251 // we are in the commit path. Don't do anything.
1266 if (!GetOverlayContents()) 1252 if (!GetOverlayContents())
1267 return; 1253 return;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 // for instance, if the user types 'i' and the suggestion is 'INSTANT', 1609 // for instance, if the user types 'i' and the suggestion is 'INSTANT',
1624 // suggest 'nstant'. Otherwise, the user text really isn't a prefix, so 1610 // suggest 'nstant'. Otherwise, the user text really isn't a prefix, so
1625 // suggest nothing. 1611 // suggest nothing.
1626 // TODO(samarth|jered): revisit this logic. http://crbug.com/196572. 1612 // TODO(samarth|jered): revisit this logic. http://crbug.com/196572.
1627 return true; 1613 return true;
1628 } 1614 }
1629 } 1615 }
1630 1616
1631 return false; 1617 return false;
1632 } 1618 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698