OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "ui/base/ime/chromeos/input_method_descriptor.h" | 5 #include "ui/base/ime/chromeos/input_method_descriptor.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 : id_(id), | 27 : id_(id), |
28 name_(name), | 28 name_(name), |
29 keyboard_layouts_(keyboard_layouts), | 29 keyboard_layouts_(keyboard_layouts), |
30 language_codes_(language_codes), | 30 language_codes_(language_codes), |
31 indicator_(indicator), | 31 indicator_(indicator), |
32 is_login_keyboard_(is_login_keyboard), | 32 is_login_keyboard_(is_login_keyboard), |
33 options_page_url_(options_page_url), | 33 options_page_url_(options_page_url), |
34 input_view_url_(input_view_url) { | 34 input_view_url_(input_view_url) { |
35 } | 35 } |
36 | 36 |
| 37 InputMethodDescriptor::InputMethodDescriptor( |
| 38 const InputMethodDescriptor& other) = default; |
| 39 |
37 std::string InputMethodDescriptor::GetPreferredKeyboardLayout() const { | 40 std::string InputMethodDescriptor::GetPreferredKeyboardLayout() const { |
38 // TODO(nona): Investigate better way to guess the preferred layout | 41 // TODO(nona): Investigate better way to guess the preferred layout |
39 // http://crbug.com/170601. | 42 // http://crbug.com/170601. |
40 return keyboard_layouts_.empty() ? "us" : keyboard_layouts_[0]; | 43 return keyboard_layouts_.empty() ? "us" : keyboard_layouts_[0]; |
41 } | 44 } |
42 | 45 |
43 std::string InputMethodDescriptor::GetIndicator() const { | 46 std::string InputMethodDescriptor::GetIndicator() const { |
44 // If indicator is empty, use the first two character in its preferred | 47 // If indicator is empty, use the first two character in its preferred |
45 // keyboard layout or language code. | 48 // keyboard layout or language code. |
46 if (indicator_.empty()) { | 49 if (indicator_.empty()) { |
47 if (extension_ime_util::IsKeyboardLayoutExtension(id_)) { | 50 if (extension_ime_util::IsKeyboardLayoutExtension(id_)) { |
48 return base::ToUpperASCII(GetPreferredKeyboardLayout().substr(0, 2)); | 51 return base::ToUpperASCII(GetPreferredKeyboardLayout().substr(0, 2)); |
49 } | 52 } |
50 DCHECK(language_codes_.size() > 0); | 53 DCHECK(language_codes_.size() > 0); |
51 return base::ToUpperASCII(language_codes_[0].substr(0, 2)); | 54 return base::ToUpperASCII(language_codes_[0].substr(0, 2)); |
52 } | 55 } |
53 return indicator_; | 56 return indicator_; |
54 } | 57 } |
55 | 58 |
56 InputMethodDescriptor::InputMethodDescriptor() { | 59 InputMethodDescriptor::InputMethodDescriptor() { |
57 } | 60 } |
58 | 61 |
59 InputMethodDescriptor::~InputMethodDescriptor() { | 62 InputMethodDescriptor::~InputMethodDescriptor() { |
60 } | 63 } |
61 | 64 |
62 } // namespace input_method | 65 } // namespace input_method |
63 } // namespace chromeos | 66 } // namespace chromeos |
OLD | NEW |