OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 250 } |
251 select_all_on_mouse_release_ = false; | 251 select_all_on_mouse_release_ = false; |
252 } | 252 } |
253 | 253 |
254 bool OmniboxViewViews::OnKeyPressed(const ui::KeyEvent& event) { | 254 bool OmniboxViewViews::OnKeyPressed(const ui::KeyEvent& event) { |
255 // Skip processing of [Alt]+<num-pad digit> Unicode alt key codes. | 255 // Skip processing of [Alt]+<num-pad digit> Unicode alt key codes. |
256 // Otherwise, if num-lock is off, the events are handled as [Up], [Down], etc. | 256 // Otherwise, if num-lock is off, the events are handled as [Up], [Down], etc. |
257 if (event.IsUnicodeKeyCode()) | 257 if (event.IsUnicodeKeyCode()) |
258 return views::Textfield::OnKeyPressed(event); | 258 return views::Textfield::OnKeyPressed(event); |
259 | 259 |
| 260 const bool shift = event.IsShiftDown(); |
| 261 const bool control = event.IsControlDown(); |
| 262 const bool alt = event.IsAltDown() || event.IsAltGrDown(); |
260 switch (event.key_code()) { | 263 switch (event.key_code()) { |
261 case ui::VKEY_RETURN: | 264 case ui::VKEY_RETURN: |
262 model()->AcceptInput(event.IsAltDown() ? NEW_FOREGROUND_TAB : CURRENT_TAB, | 265 model()->AcceptInput(alt ? NEW_FOREGROUND_TAB : CURRENT_TAB, false); |
263 false); | |
264 return true; | 266 return true; |
265 case ui::VKEY_ESCAPE: | 267 case ui::VKEY_ESCAPE: |
266 return model()->OnEscapeKeyPressed(); | 268 return model()->OnEscapeKeyPressed(); |
267 case ui::VKEY_CONTROL: | 269 case ui::VKEY_CONTROL: |
268 model()->OnControlKeyChanged(true); | 270 model()->OnControlKeyChanged(true); |
269 break; | 271 break; |
270 case ui::VKEY_DELETE: | 272 case ui::VKEY_DELETE: |
271 if (event.IsShiftDown() && model()->popup_model()->IsOpen()) | 273 if (shift && model()->popup_model()->IsOpen()) |
272 model()->popup_model()->TryDeletingCurrentItem(); | 274 model()->popup_model()->TryDeletingCurrentItem(); |
273 break; | 275 break; |
274 case ui::VKEY_UP: | 276 case ui::VKEY_UP: |
275 model()->OnUpOrDownKeyPressed(-1); | 277 model()->OnUpOrDownKeyPressed(-1); |
276 return true; | 278 return true; |
277 case ui::VKEY_DOWN: | 279 case ui::VKEY_DOWN: |
278 model()->OnUpOrDownKeyPressed(1); | 280 model()->OnUpOrDownKeyPressed(1); |
279 return true; | 281 return true; |
280 case ui::VKEY_PRIOR: | 282 case ui::VKEY_PRIOR: |
281 if (event.IsControlDown() || event.IsAltDown() || | 283 if (control || alt || shift) |
282 event.IsShiftDown()) { | |
283 return false; | 284 return false; |
284 } | |
285 model()->OnUpOrDownKeyPressed(-1 * model()->result().size()); | 285 model()->OnUpOrDownKeyPressed(-1 * model()->result().size()); |
286 return true; | 286 return true; |
287 case ui::VKEY_NEXT: | 287 case ui::VKEY_NEXT: |
288 if (event.IsControlDown() || event.IsAltDown() || | 288 if (control || alt || shift) |
289 event.IsShiftDown()) { | |
290 return false; | 289 return false; |
291 } | |
292 model()->OnUpOrDownKeyPressed(model()->result().size()); | 290 model()->OnUpOrDownKeyPressed(model()->result().size()); |
293 return true; | 291 return true; |
294 case ui::VKEY_V: | 292 case ui::VKEY_V: |
295 if (event.IsControlDown() && !read_only()) { | 293 if (control && !alt && !read_only()) { |
296 OnBeforePossibleChange(); | 294 OnBeforePossibleChange(); |
297 OnPaste(); | 295 OnPaste(); |
298 OnAfterPossibleChange(); | 296 OnAfterPossibleChange(); |
299 return true; | 297 return true; |
300 } | 298 } |
301 break; | 299 break; |
302 default: | 300 default: |
303 break; | 301 break; |
304 } | 302 } |
305 | 303 |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 const string16 text(GetClipboardText()); | 954 const string16 text(GetClipboardText()); |
957 if (!text.empty()) { | 955 if (!text.empty()) { |
958 // Record this paste, so we can do different behavior. | 956 // Record this paste, so we can do different behavior. |
959 model()->on_paste(); | 957 model()->on_paste(); |
960 // Force a Paste operation to trigger the text_changed code in | 958 // Force a Paste operation to trigger the text_changed code in |
961 // OnAfterPossibleChange(), even if identical contents are pasted. | 959 // OnAfterPossibleChange(), even if identical contents are pasted. |
962 text_before_change_.clear(); | 960 text_before_change_.clear(); |
963 InsertOrReplaceText(text); | 961 InsertOrReplaceText(text); |
964 } | 962 } |
965 } | 963 } |
OLD | NEW |