| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_LL_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_LL_H_ | |
| 7 | |
| 8 // "Latin Layout" checker: checks if given keyboard layout is "Full Latin Input" | |
| 9 | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/strings/string_util.h" | |
| 14 | |
| 15 namespace chromeos { | |
| 16 namespace input_method { | |
| 17 | |
| 18 class TwoLetterLanguageCode { | |
| 19 public: | |
| 20 TwoLetterLanguageCode() : val(0) {} | |
| 21 explicit TwoLetterLanguageCode(const char* lang) | |
| 22 : val(base::ToLowerASCII(lang[0]) * 256 + base::ToLowerASCII(lang[1])) {} | |
| 23 | |
| 24 bool operator<(const TwoLetterLanguageCode& r) const { return val < r.val; } | |
| 25 bool operator!=(const TwoLetterLanguageCode& r) const { return val != r.val; } | |
| 26 | |
| 27 private: | |
| 28 uint16_t val; | |
| 29 }; | |
| 30 | |
| 31 // To keep index small, sizeof(TwoLetterLanguageCode2KBDList) = 4. | |
| 32 class TwoLetterLanguageCode2KBDList { | |
| 33 public: | |
| 34 TwoLetterLanguageCode2KBDList() : index(0) {} | |
| 35 TwoLetterLanguageCode2KBDList(const char* l, const uint16_t i) | |
| 36 : lang(l), index(i) {} | |
| 37 | |
| 38 bool operator<(const TwoLetterLanguageCode2KBDList& r) const { | |
| 39 return lang < r.lang; | |
| 40 } | |
| 41 bool operator<(const TwoLetterLanguageCode& r) const { return lang < r; } | |
| 42 | |
| 43 TwoLetterLanguageCode lang; | |
| 44 | |
| 45 // index in kHasLatinKeyboardLanguageList[] | |
| 46 uint16_t index; | |
| 47 }; | |
| 48 | |
| 49 // For fast lookup "whether this language and layout are among listed in | |
| 50 // kHasLatinKeyboardLanguageList[] or not". | |
| 51 class FullLatinKeyboardLayoutChecker { | |
| 52 public: | |
| 53 FullLatinKeyboardLayoutChecker(); | |
| 54 ~FullLatinKeyboardLayoutChecker(); | |
| 55 | |
| 56 bool IsFullLatinKeyboard(const std::string& layout, | |
| 57 const std::string& lang) const; | |
| 58 | |
| 59 private: | |
| 60 // Sorted vector for fast lookup. | |
| 61 std::vector<TwoLetterLanguageCode2KBDList> full_latin_keyboard_languages_; | |
| 62 }; | |
| 63 | |
| 64 } // namespace input_method | |
| 65 } // namespace chromeos | |
| 66 | |
| 67 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_LL_H_ | |
| OLD | NEW |