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

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: '' 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 361 // If the omnibox is blank, send an onchange("") instead of an
362 // onsubmit(""). This is to avoid confusion with the onsubmit("") 362 // onsubmit(""). This is to avoid confusion with the onsubmit("")
363 // that we send when the user hits Enter to navigate to a URL. 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 364 // onchange("") is used for a similar situation with the overlay
365 // (when the overlay is dismissed because the user hit Escape); it 365 // (when the overlay is dismissed because the user hit Escape); it
366 // does the right thing for committed tabs as well. 366 // does the right thing for committed tabs as well.
367 if (full_text.empty()) 367 if (full_text.empty()) {
368 instant_tab_->Update(string16(), 0, 0, true); 368 if (UsingLocalPage())
samarth 2013/05/04 01:04:17 Let's send the right event for both local and remo
kmadhusu 2013/05/04 03:34:38 Done.
369 else 369 OnEscKeyPressed();
samarth 2013/05/04 01:04:17 Just call instant_tab_->OnEscKeyPressed() here. No
kmadhusu 2013/05/04 03:34:38 Done.
370 else
371 instant_tab_->Update(string16(), 0, 0, true);
372 } else {
370 instant_tab_->Submit(full_text); 373 instant_tab_->Submit(full_text);
374 }
371 } 375 }
372 } else if (!full_text.empty()) { 376 } else if (!full_text.empty()) {
373 // If |full_text| is empty, the user is on the NTP. The overlay may 377 // 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. 378 // be showing custom NTP content; hide only if that's not the case.
375 HideOverlay(); 379 HideOverlay();
376 } 380 }
377 } else if (full_text.empty()) { 381 } else if (full_text.empty()) {
378 // The user is typing, and backspaced away all omnibox text. Clear 382 // The user is typing, and backspaced away all omnibox text. Clear
379 // |last_omnibox_text_| so that we don't attempt to set suggestions. 383 // |last_omnibox_text_| so that we don't attempt to set suggestions.
380 last_omnibox_text_.clear(); 384 last_omnibox_text_.clear();
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 } 1684 }
1681 } 1685 }
1682 1686
1683 return false; 1687 return false;
1684 } 1688 }
1685 1689
1686 bool InstantController::UsingLocalPage() const { 1690 bool InstantController::UsingLocalPage() const {
1687 return (instant_tab_ && instant_tab_->IsLocal()) || 1691 return (instant_tab_ && instant_tab_->IsLocal()) ||
1688 (!instant_tab_ && overlay_ && overlay_->IsLocal()); 1692 (!instant_tab_ && overlay_ && overlay_->IsLocal());
1689 } 1693 }
1694
1695 void InstantController::OnEscKeyPressed() const {
1696 DCHECK(extended_enabled_);
1697 if (!instant_tab_ && !overlay_)
1698 return;
1699
1700 if (instant_tab_)
1701 instant_tab_->EscKeyPressed();
1702 else
1703 overlay_->EscKeyPressed();
1704 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698