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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 } | 231 } |
232 select_all_on_mouse_release_ = false; | 232 select_all_on_mouse_release_ = false; |
233 } | 233 } |
234 | 234 |
235 bool OmniboxViewViews::OnKeyPressed(const ui::KeyEvent& event) { | 235 bool OmniboxViewViews::OnKeyPressed(const ui::KeyEvent& event) { |
236 // Skip processing of [Alt]+<num-pad digit> Unicode alt key codes. | 236 // Skip processing of [Alt]+<num-pad digit> Unicode alt key codes. |
237 // Otherwise, if num-lock is off, the events are handled as [Up], [Down], etc. | 237 // Otherwise, if num-lock is off, the events are handled as [Up], [Down], etc. |
238 if (event.IsUnicodeKeyCode()) | 238 if (event.IsUnicodeKeyCode()) |
239 return views::Textfield::OnKeyPressed(event); | 239 return views::Textfield::OnKeyPressed(event); |
240 | 240 |
| 241 const bool shift = event.IsShiftDown(); |
| 242 const bool control = event.IsControlDown(); |
| 243 const bool alt = event.IsAltDown() || event.IsAltGrDown(); |
241 switch (event.key_code()) { | 244 switch (event.key_code()) { |
242 case ui::VKEY_RETURN: | 245 case ui::VKEY_RETURN: |
243 model()->AcceptInput(event.IsAltDown() ? NEW_FOREGROUND_TAB : CURRENT_TAB, | 246 model()->AcceptInput(alt ? NEW_FOREGROUND_TAB : CURRENT_TAB, false); |
244 false); | |
245 return true; | 247 return true; |
246 case ui::VKEY_ESCAPE: | 248 case ui::VKEY_ESCAPE: |
247 return model()->OnEscapeKeyPressed(); | 249 return model()->OnEscapeKeyPressed(); |
248 case ui::VKEY_CONTROL: | 250 case ui::VKEY_CONTROL: |
249 model()->OnControlKeyChanged(true); | 251 model()->OnControlKeyChanged(true); |
250 break; | 252 break; |
251 case ui::VKEY_DELETE: | 253 case ui::VKEY_DELETE: |
252 if (event.IsShiftDown() && model()->popup_model()->IsOpen()) | 254 if (shift && model()->popup_model()->IsOpen()) |
253 model()->popup_model()->TryDeletingCurrentItem(); | 255 model()->popup_model()->TryDeletingCurrentItem(); |
254 break; | 256 break; |
255 case ui::VKEY_UP: | 257 case ui::VKEY_UP: |
256 model()->OnUpOrDownKeyPressed(-1); | 258 model()->OnUpOrDownKeyPressed(-1); |
257 return true; | 259 return true; |
258 case ui::VKEY_DOWN: | 260 case ui::VKEY_DOWN: |
259 model()->OnUpOrDownKeyPressed(1); | 261 model()->OnUpOrDownKeyPressed(1); |
260 return true; | 262 return true; |
261 case ui::VKEY_PRIOR: | 263 case ui::VKEY_PRIOR: |
262 if (event.IsControlDown() || event.IsAltDown() || | 264 if (control || alt || shift) |
263 event.IsShiftDown()) { | |
264 return false; | 265 return false; |
265 } | |
266 model()->OnUpOrDownKeyPressed(-1 * model()->result().size()); | 266 model()->OnUpOrDownKeyPressed(-1 * model()->result().size()); |
267 return true; | 267 return true; |
268 case ui::VKEY_NEXT: | 268 case ui::VKEY_NEXT: |
269 if (event.IsControlDown() || event.IsAltDown() || | 269 if (control || alt || shift) |
270 event.IsShiftDown()) { | |
271 return false; | 270 return false; |
272 } | |
273 model()->OnUpOrDownKeyPressed(model()->result().size()); | 271 model()->OnUpOrDownKeyPressed(model()->result().size()); |
274 return true; | 272 return true; |
275 case ui::VKEY_V: | 273 case ui::VKEY_V: |
276 if (event.IsControlDown() && !read_only()) { | 274 if (control && !alt && !read_only()) { |
277 OnBeforePossibleChange(); | 275 OnBeforePossibleChange(); |
278 OnPaste(); | 276 OnPaste(); |
279 OnAfterPossibleChange(); | 277 OnAfterPossibleChange(); |
280 return true; | 278 return true; |
281 } | 279 } |
282 break; | 280 break; |
283 default: | 281 default: |
284 break; | 282 break; |
285 } | 283 } |
286 | 284 |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 const string16 text(GetClipboardText()); | 918 const string16 text(GetClipboardText()); |
921 if (!text.empty()) { | 919 if (!text.empty()) { |
922 // Record this paste, so we can do different behavior. | 920 // Record this paste, so we can do different behavior. |
923 model()->on_paste(); | 921 model()->on_paste(); |
924 // Force a Paste operation to trigger the text_changed code in | 922 // Force a Paste operation to trigger the text_changed code in |
925 // OnAfterPossibleChange(), even if identical contents are pasted. | 923 // OnAfterPossibleChange(), even if identical contents are pasted. |
926 text_before_change_.clear(); | 924 text_before_change_.clear(); |
927 InsertOrReplaceText(text); | 925 InsertOrReplaceText(text); |
928 } | 926 } |
929 } | 927 } |
OLD | NEW |