OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/input_method/input_method_engine.h" | 5 #include "chrome/browser/ui/input_method/input_method_engine.h" |
| 6 #include "base/stl_util.h" |
6 | 7 |
7 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
8 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
10 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
11 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
12 #include "content/public/browser/render_frame_host.h" | 13 #include "content/public/browser/render_frame_host.h" |
13 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
14 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 262 } |
262 return true; | 263 return true; |
263 } | 264 } |
264 | 265 |
265 bool InputMethodEngine::IsValidKeyForAllPages(ui::KeyEvent* ui_event) { | 266 bool InputMethodEngine::IsValidKeyForAllPages(ui::KeyEvent* ui_event) { |
266 // Whitelists all character keys except for Enter and Tab keys. | 267 // Whitelists all character keys except for Enter and Tab keys. |
267 std::vector<ui::KeyboardCode> invalid_character_keycodes{ui::VKEY_TAB, | 268 std::vector<ui::KeyboardCode> invalid_character_keycodes{ui::VKEY_TAB, |
268 ui::VKEY_RETURN}; | 269 ui::VKEY_RETURN}; |
269 if (ui_event->GetDomKey().IsCharacter() && !ui_event->IsControlDown() && | 270 if (ui_event->GetDomKey().IsCharacter() && !ui_event->IsControlDown() && |
270 !ui_event->IsCommandDown()) { | 271 !ui_event->IsCommandDown()) { |
271 return std::find(invalid_character_keycodes.begin(), | 272 return !base::ContainsValue(invalid_character_keycodes, |
272 invalid_character_keycodes.end(), | 273 ui_event->key_code()); |
273 ui_event->key_code()) == invalid_character_keycodes.end(); | |
274 } | 274 } |
275 | 275 |
276 // Whitelists Backspace key and arrow keys. | 276 // Whitelists Backspace key and arrow keys. |
277 std::vector<ui::KeyboardCode> whitelist_keycodes{ | 277 std::vector<ui::KeyboardCode> whitelist_keycodes{ |
278 ui::VKEY_BACK, ui::VKEY_LEFT, ui::VKEY_RIGHT, ui::VKEY_UP, ui::VKEY_DOWN}; | 278 ui::VKEY_BACK, ui::VKEY_LEFT, ui::VKEY_RIGHT, ui::VKEY_UP, ui::VKEY_DOWN}; |
279 return std::find(whitelist_keycodes.begin(), whitelist_keycodes.end(), | 279 return base::ContainsValue(whitelist_keycodes, ui_event->key_code()); |
280 ui_event->key_code()) != whitelist_keycodes.end(); | |
281 } | 280 } |
282 | 281 |
283 } // namespace input_method | 282 } // namespace input_method |
OLD | NEW |