Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_descriptor.cc

Issue 10388181: Remove virtual keyboard support from input_method_descriptor.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/chromeos/input_method/input_method_descriptor.h" 5 #include "chrome/browser/chromeos/input_method/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/string_split.h" 10 #include "base/string_split.h"
11 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h"
12
13 // TODO(yusukes): Remove virtual keyboard support.
14 11
15 namespace chromeos { 12 namespace chromeos {
16 namespace input_method { 13 namespace input_method {
17 14
18 namespace { 15 namespace {
19 const char kFallbackLayout[] = "us"; 16 const char kFallbackLayout[] = "us";
20 } // namespace 17 } // namespace
21 18
22 InputMethodDescriptor::InputMethodDescriptor( 19 InputMethodDescriptor::InputMethodDescriptor(const std::string& id,
23 const InputMethodWhitelist& whitelist, 20 const std::string& name,
24 const std::string& id, 21 const std::string& keyboard_layout,
25 const std::string& name, 22 const std::string& language_code)
26 const std::string& raw_layout,
27 const std::string& language_code)
28 : id_(id), 23 : id_(id),
29 name_(name), 24 name_(name),
25 keyboard_layout_(keyboard_layout),
30 language_code_(language_code) { 26 language_code_(language_code) {
31 keyboard_layout_ = kFallbackLayout;
32 base::SplitString(raw_layout, ',', &virtual_keyboard_layouts_);
33
34 // Find a valid XKB layout name from the comma-separated list, |raw_layout|.
35 // Only the first acceptable XKB layout name in the list is used as the
36 // |keyboard_layout| value of the InputMethodDescriptor object to be created
37 for (size_t i = 0; i < virtual_keyboard_layouts_.size(); ++i) {
38 if (whitelist.XkbLayoutIsSupported(virtual_keyboard_layouts_[i])) {
39 keyboard_layout_ = virtual_keyboard_layouts_[i];
40 DCHECK(keyboard_layout_.find(",") == std::string::npos);
41 break;
42 }
43 }
44 } 27 }
45 28
46 InputMethodDescriptor::InputMethodDescriptor() { 29 InputMethodDescriptor::InputMethodDescriptor() {
47 } 30 }
48 31
49 InputMethodDescriptor::~InputMethodDescriptor() { 32 InputMethodDescriptor::~InputMethodDescriptor() {
50 } 33 }
51 34
52 InputMethodDescriptor::InputMethodDescriptor(
53 const std::string& in_id,
54 const std::string& in_name,
55 const std::string& in_keyboard_layout,
56 const std::string& in_virtual_keyboard_layouts,
57 const std::string& in_language_code)
58 : id_(in_id),
59 name_(in_name),
60 keyboard_layout_(in_keyboard_layout),
61 language_code_(in_language_code) {
62 DCHECK(keyboard_layout_.find(",") == std::string::npos);
63 base::SplitString(
64 in_virtual_keyboard_layouts, ',', &virtual_keyboard_layouts_);
65 }
66
67 bool InputMethodDescriptor::operator==( 35 bool InputMethodDescriptor::operator==(
68 const InputMethodDescriptor& other) const { 36 const InputMethodDescriptor& other) const {
69 return id() == other.id(); 37 return id() == other.id();
70 } 38 }
71 39
72 bool InputMethodDescriptor::operator!=( 40 bool InputMethodDescriptor::operator!=(
73 const InputMethodDescriptor& other) const { 41 const InputMethodDescriptor& other) const {
74 return !(*this == other); 42 return !(*this == other);
75 } 43 }
76 44
77 // static 45 // static
78 InputMethodDescriptor 46 InputMethodDescriptor
79 InputMethodDescriptor::GetFallbackInputMethodDescriptor() { 47 InputMethodDescriptor::GetFallbackInputMethodDescriptor() {
80 return InputMethodDescriptor("xkb:us::eng", 48 return InputMethodDescriptor("xkb:us::eng",
81 "", 49 "",
82 kFallbackLayout, 50 kFallbackLayout,
83 kFallbackLayout,
84 "en-US"); 51 "en-US");
85 } 52 }
86 53
87 std::string InputMethodDescriptor::ToString() const { 54 std::string InputMethodDescriptor::ToString() const {
88 std::stringstream stream; 55 std::stringstream stream;
89 stream << "id=" << id() 56 stream << "id=" << id()
90 << ", name=" << name() 57 << ", name=" << name()
91 << ", keyboard_layout=" << keyboard_layout() 58 << ", keyboard_layout=" << keyboard_layout()
92 << ", virtual_keyboard_layouts=" << virtual_keyboard_layouts_.size()
93 << ", language_code=" << language_code(); 59 << ", language_code=" << language_code();
94 return stream.str(); 60 return stream.str();
95 } 61 }
96 62
97 } // namespace input_method 63 } // namespace input_method
98 } // namespace chromeos 64 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698