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 "chromeos/ime/input_method_descriptor.h" | 5 #include "chromeos/ime/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" |
11 #include "base/strings/string_util.h" | |
12 #include "chromeos/ime/extension_ime_util.h" | |
11 #include "url/gurl.h" | 13 #include "url/gurl.h" |
12 | 14 |
13 namespace chromeos { | 15 namespace chromeos { |
14 namespace input_method { | 16 namespace input_method { |
15 | 17 |
16 InputMethodDescriptor::InputMethodDescriptor( | 18 InputMethodDescriptor::InputMethodDescriptor( |
17 const std::string& id, | 19 const std::string& id, |
18 const std::string& name, | 20 const std::string& name, |
19 const std::string& indicator, | 21 const std::string& indicator, |
20 const std::vector<std::string>& keyboard_layouts, | 22 const std::vector<std::string>& keyboard_layouts, |
(...skipping 10 matching lines...) Expand all Loading... | |
31 options_page_url_(options_page_url), | 33 options_page_url_(options_page_url), |
32 input_view_url_(input_view_url) { | 34 input_view_url_(input_view_url) { |
33 } | 35 } |
34 | 36 |
35 std::string InputMethodDescriptor::GetPreferredKeyboardLayout() const { | 37 std::string InputMethodDescriptor::GetPreferredKeyboardLayout() const { |
36 // TODO(nona): Investigate better way to guess the preferred layout | 38 // TODO(nona): Investigate better way to guess the preferred layout |
37 // http://crbug.com/170601. | 39 // http://crbug.com/170601. |
38 return keyboard_layouts_.empty() ? "us" : keyboard_layouts_[0]; | 40 return keyboard_layouts_.empty() ? "us" : keyboard_layouts_[0]; |
39 } | 41 } |
40 | 42 |
43 std::string InputMethodDescriptor::GetIndicator() const { | |
44 // If indicator is empty, use the first two character in its preferred | |
45 // keyboard layout or language code. | |
46 if (indicator_.empty()) { | |
47 if (extension_ime_util::IsKeyboardLayoutExtension(id_)) | |
48 return StringToUpperASCII(GetPreferredKeyboardLayout().substr(0, 2)); | |
49 DCHECK(language_codes_.size() > 0); | |
50 return StringToUpperASCII(language_codes_[0].substr(0, 2)); | |
51 } | |
52 return indicator_; | |
Seigo Nonaka
2014/09/30 02:49:01
This |indicator_| can be set by third party, right
Shu Chen
2014/09/30 02:52:56
This cl only enables the indicator for component I
| |
53 } | |
54 | |
41 InputMethodDescriptor::InputMethodDescriptor() { | 55 InputMethodDescriptor::InputMethodDescriptor() { |
42 } | 56 } |
43 | 57 |
44 InputMethodDescriptor::~InputMethodDescriptor() { | 58 InputMethodDescriptor::~InputMethodDescriptor() { |
45 } | 59 } |
46 | 60 |
47 } // namespace input_method | 61 } // namespace input_method |
48 } // namespace chromeos | 62 } // namespace chromeos |
OLD | NEW |