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

Side by Side Diff: chrome/renderer/searchbox/searchbox.cc

Issue 11889003: Fixing ESC in instant-extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reworked to send ESC down to JS, added test. Created 7 years, 10 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 "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/renderer/searchbox/searchbox_extension.h" 8 #include "chrome/renderer/searchbox/searchbox_extension.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit) 115 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit)
116 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel) 116 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel)
117 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxPopupResize, OnPopupResize) 117 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxPopupResize, OnPopupResize)
118 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMarginChange, OnMarginChange) 118 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMarginChange, OnMarginChange)
119 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant, 119 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant,
120 OnDetermineIfPageSupportsInstant) 120 OnDetermineIfPageSupportsInstant)
121 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults, 121 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults,
122 OnAutocompleteResults) 122 OnAutocompleteResults)
123 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed, 123 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed,
124 OnUpOrDownKeyPressed) 124 OnUpOrDownKeyPressed)
125 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxEscKeyPressed,
126 OnEscKeyPressed)
125 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxModeChanged, 127 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxModeChanged,
126 OnModeChanged) 128 OnModeChanged)
127 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, 129 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults,
128 OnSetDisplayInstantResults) 130 OnSetDisplayInstantResults)
129 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxKeyCaptureChanged, 131 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxKeyCaptureChanged,
130 OnKeyCaptureChange) 132 OnKeyCaptureChange)
131 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged, 133 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged,
132 OnThemeChanged) 134 OnThemeChanged)
133 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeAreaHeightChanged, 135 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeAreaHeightChanged,
134 OnThemeAreaHeightChanged) 136 OnThemeAreaHeightChanged)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 224 }
223 225
224 void SearchBox::OnUpOrDownKeyPressed(int count) { 226 void SearchBox::OnUpOrDownKeyPressed(int count) {
225 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 227 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
226 DVLOG(1) << render_view() << " OnKeyPress: " << count; 228 DVLOG(1) << render_view() << " OnKeyPress: " << count;
227 extensions_v8::SearchBoxExtension::DispatchUpOrDownKeyPress( 229 extensions_v8::SearchBoxExtension::DispatchUpOrDownKeyPress(
228 render_view()->GetWebView()->mainFrame(), count); 230 render_view()->GetWebView()->mainFrame(), count);
229 } 231 }
230 } 232 }
231 233
234 void SearchBox::OnEscKeyPressed() {
235 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
236 DVLOG(1) << render_view() << " OnKeyPress ESC";
237 extensions_v8::SearchBoxExtension::DispatchEscKeyPress(
238 render_view()->GetWebView()->mainFrame());
239 }
240 }
241
232 void SearchBox::OnKeyCaptureChange(bool is_key_capture_enabled) { 242 void SearchBox::OnKeyCaptureChange(bool is_key_capture_enabled) {
233 if (is_key_capture_enabled != is_key_capture_enabled_ && 243 if (is_key_capture_enabled != is_key_capture_enabled_ &&
234 render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 244 render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
235 is_key_capture_enabled_ = is_key_capture_enabled; 245 is_key_capture_enabled_ = is_key_capture_enabled;
236 DVLOG(1) << render_view() << " OnKeyCaptureChange"; 246 DVLOG(1) << render_view() << " OnKeyCaptureChange";
237 extensions_v8::SearchBoxExtension::DispatchKeyCaptureChange( 247 extensions_v8::SearchBoxExtension::DispatchKeyCaptureChange(
238 render_view()->GetWebView()->mainFrame()); 248 render_view()->GetWebView()->mainFrame());
239 } 249 }
240 } 250 }
241 251
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 is_key_capture_enabled_ = false; 307 is_key_capture_enabled_ = false;
298 mode_ = chrome::search::Mode(); 308 mode_ = chrome::search::Mode();
299 theme_info_ = ThemeBackgroundInfo(); 309 theme_info_ = ThemeBackgroundInfo();
300 theme_area_height_ = 0; 310 theme_area_height_ = 0;
301 // Don't reset display_instant_results_ to prevent clearing it on committed 311 // Don't reset display_instant_results_ to prevent clearing it on committed
302 // results pages in extended mode. Otherwise resetting it is a no-op because 312 // results pages in extended mode. Otherwise resetting it is a no-op because
303 // a new loader is created when it changes; see crbug.com/164662. 313 // a new loader is created when it changes; see crbug.com/164662.
304 // Also don't reset omnibox_font_ or omnibox_font_size_ since it never 314 // Also don't reset omnibox_font_ or omnibox_font_size_ since it never
305 // changes. 315 // changes.
306 } 316 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698