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

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

Issue 14562006: Handle Esc key press event in Local NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 7 years, 7 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // The user is on a search results page. It may be showing results for 351 // The user is on a search results page. It may be showing results for
352 // a partial query the user typed before they hit Escape. Send the 352 // a partial query the user typed before they hit Escape. Send the
353 // omnibox text to the page to restore the original results. 353 // omnibox text to the page to restore the original results.
354 // 354 //
355 // In a tab switch, |instant_tab_| won't have updated yet, so it may 355 // In a tab switch, |instant_tab_| won't have updated yet, so it may
356 // be pointing to the previous tab (which was a search results page). 356 // be pointing to the previous tab (which was a search results page).
357 // Ensure we don't send the omnibox text to a random webpage (the new 357 // Ensure we don't send the omnibox text to a random webpage (the new
358 // tab), by comparing the old and new WebContents. 358 // tab), by comparing the old and new WebContents.
359 if (escape_pressed && 359 if (escape_pressed &&
360 instant_tab_->contents() == browser_->GetActiveWebContents()) { 360 instant_tab_->contents() == browser_->GetActiveWebContents()) {
361 // If the omnibox is blank, send an onchange("") instead of an
362 // onsubmit(""). This is to avoid confusion with the onsubmit("")
363 // that we send when the user hits Enter to navigate to a URL.
364 // onchange("") is used for a similar situation with the overlay
365 // (when the overlay is dismissed because the user hit Escape); it
366 // does the right thing for committed tabs as well.
367 if (full_text.empty()) 361 if (full_text.empty())
samarth 2013/05/04 16:37:35 Add a TODO here for sending an escape key press in
kmadhusu 2013/05/05 22:44:54 Done.
368 instant_tab_->Update(string16(), 0, 0, true); 362 instant_tab_->EscKeyPressed();
369 else 363 else
370 instant_tab_->Submit(full_text); 364 instant_tab_->Submit(full_text);
371 } 365 }
372 } else if (!full_text.empty()) { 366 } else if (!full_text.empty()) {
373 // If |full_text| is empty, the user is on the NTP. The overlay may 367 // If |full_text| is empty, the user is on the NTP. The overlay may
374 // be showing custom NTP content; hide only if that's not the case. 368 // be showing custom NTP content; hide only if that's not the case.
375 HideOverlay(); 369 HideOverlay();
376 } 370 }
377 } else if (full_text.empty()) { 371 } else if (full_text.empty()) {
378 // The user is typing, and backspaced away all omnibox text. Clear 372 // The user is typing, and backspaced away all omnibox text. Clear
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 } 1674 }
1681 } 1675 }
1682 1676
1683 return false; 1677 return false;
1684 } 1678 }
1685 1679
1686 bool InstantController::UsingLocalPage() const { 1680 bool InstantController::UsingLocalPage() const {
1687 return (instant_tab_ && instant_tab_->IsLocal()) || 1681 return (instant_tab_ && instant_tab_->IsLocal()) ||
1688 (!instant_tab_ && overlay_ && overlay_->IsLocal()); 1682 (!instant_tab_ && overlay_ && overlay_->IsLocal());
1689 } 1683 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/local_ntp.js ('k') | chrome/browser/ui/search/instant_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698