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

Side by Side Diff: chrome/renderer/searchbox/searchbox.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/renderer/searchbox/searchbox.h" 5 #include "chrome/renderer/searchbox/searchbox.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/omnibox_focus_state.h" 10 #include "chrome/common/omnibox_focus_state.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel) 159 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel)
160 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxPopupResize, OnPopupResize) 160 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxPopupResize, OnPopupResize)
161 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMarginChange, OnMarginChange) 161 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMarginChange, OnMarginChange)
162 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxBarsHidden, OnBarsHidden) 162 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxBarsHidden, OnBarsHidden)
163 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant, 163 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant,
164 OnDetermineIfPageSupportsInstant) 164 OnDetermineIfPageSupportsInstant)
165 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults, 165 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults,
166 OnAutocompleteResults) 166 OnAutocompleteResults)
167 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed, 167 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed,
168 OnUpOrDownKeyPressed) 168 OnUpOrDownKeyPressed)
169 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxEscKeyPressed, OnEscKeyPressed)
169 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancelSelection, 170 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancelSelection,
170 OnCancelSelection) 171 OnCancelSelection)
171 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, 172 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults,
172 OnSetDisplayInstantResults) 173 OnSetDisplayInstantResults)
173 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxKeyCaptureChanged, 174 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxKeyCaptureChanged,
174 OnKeyCaptureChange) 175 OnKeyCaptureChange)
175 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged, 176 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged,
176 OnThemeChanged) 177 OnThemeChanged)
177 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFontInformation, 178 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFontInformation,
178 OnFontInformationReceived) 179 OnFontInformationReceived)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 294 }
294 295
295 void SearchBox::OnUpOrDownKeyPressed(int count) { 296 void SearchBox::OnUpOrDownKeyPressed(int count) {
296 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 297 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
297 DVLOG(1) << render_view() << " OnKeyPress: " << count; 298 DVLOG(1) << render_view() << " OnKeyPress: " << count;
298 extensions_v8::SearchBoxExtension::DispatchUpOrDownKeyPress( 299 extensions_v8::SearchBoxExtension::DispatchUpOrDownKeyPress(
299 render_view()->GetWebView()->mainFrame(), count); 300 render_view()->GetWebView()->mainFrame(), count);
300 } 301 }
301 } 302 }
302 303
304 void SearchBox::OnEscKeyPressed() {
305 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
306 DVLOG(1) << render_view() << " OnEscKeyPressed ";
307 extensions_v8::SearchBoxExtension::DispatchEscKeyPress(
308 render_view()->GetWebView()->mainFrame());
309 }
310 }
311
303 void SearchBox::OnCancelSelection(const string16& query, 312 void SearchBox::OnCancelSelection(const string16& query,
304 bool verbatim, 313 bool verbatim,
305 size_t selection_start, 314 size_t selection_start,
306 size_t selection_end) { 315 size_t selection_end) {
307 SetQuery(query, verbatim); 316 SetQuery(query, verbatim);
308 selection_start_ = selection_start; 317 selection_start_ = selection_start;
309 selection_end_ = selection_end; 318 selection_end_ = selection_end;
310 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 319 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
311 DVLOG(1) << render_view() << " OnKeyPress ESC"; 320 DVLOG(1) << render_view() << " OnKeyPress ESC";
312 extensions_v8::SearchBoxExtension::DispatchEscKeyPress( 321 extensions_v8::SearchBoxExtension::DispatchEscKeyPress(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 std::vector<InstantMostVisitedItemIDPair>* items) const { 398 std::vector<InstantMostVisitedItemIDPair>* items) const {
390 return most_visited_items_cache_.GetCurrentItems(items); 399 return most_visited_items_cache_.GetCurrentItems(items);
391 } 400 }
392 401
393 bool SearchBox::GetMostVisitedItemWithID( 402 bool SearchBox::GetMostVisitedItemWithID(
394 InstantRestrictedID most_visited_item_id, 403 InstantRestrictedID most_visited_item_id,
395 InstantMostVisitedItem* item) const { 404 InstantMostVisitedItem* item) const {
396 return most_visited_items_cache_.GetItemWithRestrictedID(most_visited_item_id, 405 return most_visited_items_cache_.GetItemWithRestrictedID(most_visited_item_id,
397 item); 406 item);
398 } 407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698