1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/cros/input_method_library.h"
#include "base/basictypes.h"
#include "base/message_loop.h"
#include "base/string_util.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/keyboard_library.h"
#include "chrome/browser/chromeos/language_preferences.h"
#include "third_party/icu/public/common/unicode/uloc.h"
#include <glib.h>
#include <signal.h>
namespace {
// Finds a property which has |new_prop.key| from |prop_list|, and replaces the
// property with |new_prop|. Returns true if such a property is found.
bool FindAndUpdateProperty(const chromeos::ImeProperty& new_prop,
chromeos::ImePropertyList* prop_list) {
for (size_t i = 0; i < prop_list->size(); ++i) {
chromeos::ImeProperty& prop = prop_list->at(i);
if (prop.key == new_prop.key) {
const int saved_id = prop.selection_item_id;
// Update the list except the radio id. As written in
// chromeos_input_method.h, |prop.selection_item_id| is dummy.
prop = new_prop;
prop.selection_item_id = saved_id;
return true;
}
}
return false;
}
// The default keyboard layout.
const char kDefaultKeyboardLayout[] = "us";
} // namespace
namespace chromeos {
// This class handles the interaction with the ChromeOS language library APIs.
// Classes can add themselves as observers. Users can get an instance of this
// library class like this: InputMethodLibrary::Get()
class InputMethodLibraryImpl : public InputMethodLibrary {
public:
InputMethodLibraryImpl()
: input_method_status_connection_(NULL),
previous_input_method_("", "", "", ""),
current_input_method_("", "", "", ""),
ime_running_(false),
ime_connected_(false),
defer_ime_startup_(false),
active_input_method_(kHardwareKeyboardLayout),
need_input_method_set_(false),
ime_handle_(0),
candidate_window_handle_(0) {
scoped_ptr<InputMethodDescriptors> input_method_descriptors(
CreateFallbackInputMethodDescriptors());
current_input_method_ = input_method_descriptors->at(0);
}
~InputMethodLibraryImpl() {
StopInputMethodProcesses();
}
void AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
InputMethodDescriptors* GetActiveInputMethods() {
chromeos::InputMethodDescriptors* result = NULL;
// The connection does not need to be alive, but it does need to be created.
if (EnsureLoadedAndStarted()) {
result = chromeos::GetActiveInputMethods(input_method_status_connection_);
}
if (!result || result->empty()) {
result = CreateFallbackInputMethodDescriptors();
}
return result;
}
size_t GetNumActiveInputMethods() {
scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods());
return input_methods->size();
}
InputMethodDescriptors* GetSupportedInputMethods() {
InputMethodDescriptors* result = NULL;
// The connection does not need to be alive, but it does need to be created.
if (EnsureLoadedAndStarted()) {
result = chromeos::GetSupportedInputMethods(
input_method_status_connection_);
}
if (!result || result->empty()) {
result = CreateFallbackInputMethodDescriptors();
}
return result;
}
void ChangeInputMethod(const std::string& input_method_id) {
active_input_method_ = input_method_id;
if (EnsureLoadedAndStarted()) {
if (input_method_id != kHardwareKeyboardLayout) {
StartInputMethodProcesses();
}
chromeos::ChangeInputMethod(
input_method_status_connection_, input_method_id.c_str());
}
}
void SetImePropertyActivated(const std::string& key, bool activated) {
DCHECK(!key.empty());
if (EnsureLoadedAndStarted()) {
chromeos::SetImePropertyActivated(
input_method_status_connection_, key.c_str(), activated);
}
}
bool InputMethodIsActivated(const std::string& input_method_id) {
scoped_ptr<InputMethodDescriptors> active_input_method_descriptors(
CrosLibrary::Get()->GetInputMethodLibrary()->GetActiveInputMethods());
for (size_t i = 0; i < active_input_method_descriptors->size(); ++i) {
if (active_input_method_descriptors->at(i).id == input_method_id) {
return true;
}
}
return false;
}
bool GetImeConfig(const char* section, const char* config_name,
ImeConfigValue* out_value) {
bool success = false;
if (EnsureLoadedAndStarted()) {
success = chromeos::GetImeConfig(input_method_status_connection_,
section, config_name, out_value);
}
return success;
}
bool SetImeConfig(const char* section, const char* config_name,
const ImeConfigValue& value) {
MaybeUpdateImeState(section, config_name, value);
const ConfigKeyType key = std::make_pair(section, config_name);
current_config_values_[key] = value;
if (ime_connected_) {
pending_config_requests_[key] = value;
FlushImeConfig();
}
return pending_config_requests_.empty();
}
virtual const InputMethodDescriptor& previous_input_method() const {
return previous_input_method_;
}
virtual const InputMethodDescriptor& current_input_method() const {
return current_input_method_;
}
virtual const ImePropertyList& current_ime_properties() const {
return current_ime_properties_;
}
private:
void MaybeUpdateImeState(
const char* section,
const char* config_name,
const ImeConfigValue& value) {
if (!strcmp(kGeneralSectionName, section) &&
!strcmp(kPreloadEnginesConfigName, config_name)) {
if (EnsureLoadedAndStarted()) {
if (value.type == ImeConfigValue::kValueTypeStringList &&
value.string_list_value.size() == 1 &&
value.string_list_value[0] == kHardwareKeyboardLayout) {
StopInputMethodProcesses();
} else if (!defer_ime_startup_) {
StartInputMethodProcesses();
}
chromeos::SetActiveInputMethods(input_method_status_connection_, value);
}
}
}
void FlushImeConfig() {
bool active_input_methods_are_changed = false;
bool completed = false;
if (EnsureLoadedAndStarted()) {
InputMethodConfigRequests::iterator iter =
pending_config_requests_.begin();
while (iter != pending_config_requests_.end()) {
const std::string& section = iter->first.first;
const std::string& config_name = iter->first.second;
const ImeConfigValue& value = iter->second;
if (chromeos::SetImeConfig(input_method_status_connection_,
section.c_str(),
config_name.c_str(),
value)) {
// Check if it's a change in active input methods.
if (config_name == kPreloadEnginesConfigName) {
active_input_methods_are_changed = true;
}
// Successfully sent. Remove the command and proceed to the next one.
pending_config_requests_.erase(iter++);
} else {
// If SetImeConfig() fails, subsequent calls will likely fail.
break;
}
}
if (pending_config_requests_.empty()) {
// Calls to ChangeInputMethod() will fail if the input method has not
// yet been added to preload_engines. As such, the call is deferred
// until after all config values have been sent to the IME process.
if (need_input_method_set_) {
if (chromeos::ChangeInputMethod(input_method_status_connection_,
active_input_method_.c_str())) {
need_input_method_set_ = false;
completed = true;
active_input_methods_are_changed = true;
}
} else {
completed = true;
}
}
}
if (completed) {
timer_.Stop(); // no-op if it's not running.
} else {
if (!timer_.IsRunning()) {
static const int64 kTimerIntervalInMsec = 100;
timer_.Start(base::TimeDelta::FromMilliseconds(kTimerIntervalInMsec),
this, &InputMethodLibraryImpl::FlushImeConfig);
}
}
if (active_input_methods_are_changed) {
FOR_EACH_OBSERVER(Observer, observers_, ActiveInputMethodsChanged(this));
}
}
static void InputMethodChangedHandler(
void* object,
const chromeos::InputMethodDescriptor& current_input_method) {
InputMethodLibraryImpl* input_method_library =
static_cast<InputMethodLibraryImpl*>(object);
input_method_library->UpdateCurrentInputMethod(current_input_method);
}
static void RegisterPropertiesHandler(
void* object, const ImePropertyList& prop_list) {
InputMethodLibraryImpl* input_method_library =
static_cast<InputMethodLibraryImpl*>(object);
input_method_library->RegisterProperties(prop_list);
}
static void UpdatePropertyHandler(
void* object, const ImePropertyList& prop_list) {
InputMethodLibraryImpl* input_method_library =
static_cast<InputMethodLibraryImpl*>(object);
input_method_library->UpdateProperty(prop_list);
}
static void ConnectionChangeHandler(void* object, bool connected) {
InputMethodLibraryImpl* input_method_library =
static_cast<InputMethodLibraryImpl*>(object);
input_method_library->ime_connected_ = connected;
if (connected) {
input_method_library->pending_config_requests_.clear();
input_method_library->pending_config_requests_.insert(
input_method_library->current_config_values_.begin(),
input_method_library->current_config_values_.end());
input_method_library->need_input_method_set_ = true;
input_method_library->FlushImeConfig();
} else {
// Stop attempting to resend config data, since it will continue to fail.
input_method_library->timer_.Stop(); // no-op if it's not running.
}
}
bool EnsureStarted() {
if (!input_method_status_connection_) {
input_method_status_connection_ = chromeos::MonitorInputMethodStatus(
this,
&InputMethodChangedHandler,
&RegisterPropertiesHandler,
&UpdatePropertyHandler,
&ConnectionChangeHandler);
}
return true;
}
bool EnsureLoadedAndStarted() {
return CrosLibrary::Get()->EnsureLoaded() &&
EnsureStarted();
}
void UpdateCurrentInputMethod(const InputMethodDescriptor& new_input_method) {
// Make sure we run on UI thread.
if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
DLOG(INFO) << "UpdateCurrentInputMethod (Background thread)";
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
// NewRunnableMethod() copies |new_input_method| by value.
NewRunnableMethod(
this, &InputMethodLibraryImpl::UpdateCurrentInputMethod,
new_input_method));
return;
}
DLOG(INFO) << "UpdateCurrentInputMethod (UI thread)";
// Change the keyboard layout to a preferred layout for the input method.
CrosLibrary::Get()->GetKeyboardLibrary()->SetCurrentKeyboardLayoutByName(
new_input_method.keyboard_layout);
if (current_input_method_.id != new_input_method.id) {
previous_input_method_ = current_input_method_;
current_input_method_ = new_input_method;
}
FOR_EACH_OBSERVER(Observer, observers_, InputMethodChanged(this));
}
void RegisterProperties(const ImePropertyList& prop_list) {
if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
NewRunnableMethod(
this, &InputMethodLibraryImpl::RegisterProperties, prop_list));
return;
}
// |prop_list| might be empty. This means "clear all properties."
current_ime_properties_ = prop_list;
FOR_EACH_OBSERVER(Observer, observers_, ImePropertiesChanged(this));
}
void StartInputMethodProcesses() {
ime_running_ = true;
MaybeLaunchIme();
}
void UpdateProperty(const ImePropertyList& prop_list) {
if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
NewRunnableMethod(
this, &InputMethodLibraryImpl::UpdateProperty, prop_list));
return;
}
for (size_t i = 0; i < prop_list.size(); ++i) {
FindAndUpdateProperty(prop_list[i], ¤t_ime_properties_);
}
FOR_EACH_OBSERVER(Observer, observers_, ImePropertiesChanged(this));
}
void MaybeLaunchIme() {
if (!ime_running_) {
return;
}
// TODO(zork): export "LD_PRELOAD=/usr/lib/libcrash.so"
GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD;
if (ime_handle_ == 0) {
GError *error = NULL;
gchar **argv;
gint argc;
if (!g_shell_parse_argv(
"/usr/bin/ibus-daemon --panel=disable --cache=none --restart",
&argc, &argv, &error)) {
LOG(ERROR) << "Could not parse command: " << error->message;
g_error_free(error);
return;
}
error = NULL;
int handle;
// TODO(zork): Send output to /var/log/ibus.log
gboolean result = g_spawn_async(NULL, argv, NULL,
flags, NULL, NULL,
&handle, &error);
g_strfreev(argv);
if (!result) {
LOG(ERROR) << "Could not launch ime: " << error->message;
g_error_free(error);
return;
}
ime_handle_ = handle;
g_child_watch_add(ime_handle_, (GChildWatchFunc)OnImeShutdown, this);
}
if (candidate_window_handle_ == 0) {
GError *error = NULL;
gchar **argv;
gint argc;
if (!g_shell_parse_argv("/opt/google/chrome/candidate_window",
&argc, &argv, &error)) {
LOG(ERROR) << "Could not parse command: " << error->message;
g_error_free(error);
return;
}
error = NULL;
int handle;
gboolean result = g_spawn_async(NULL, argv, NULL,
flags, NULL, NULL,
&handle, &error);
g_strfreev(argv);
if (!result) {
LOG(ERROR) << "Could not launch ime candidate window" << error->message;
g_error_free(error);
return;
}
candidate_window_handle_ = handle;
g_child_watch_add(candidate_window_handle_,
(GChildWatchFunc)OnImeShutdown, this);
}
}
static void OnImeShutdown(int pid,
int status,
InputMethodLibraryImpl* library) {
g_spawn_close_pid(pid);
if (library->ime_handle_ == pid) {
library->ime_handle_ = 0;
} else if (library->candidate_window_handle_ == pid) {
library->candidate_window_handle_ = 0;
}
library->MaybeLaunchIme();
}
void StopInputMethodProcesses() {
ime_running_ = false;
if (ime_handle_) {
kill(ime_handle_, SIGTERM);
ime_handle_ = 0;
}
if (candidate_window_handle_) {
kill(candidate_window_handle_, SIGTERM);
candidate_window_handle_ = 0;
}
}
void SetDeferImeStartup(bool defer) {
defer_ime_startup_ = defer;
}
// A reference to the language api, to allow callbacks when the input method
// status changes.
InputMethodStatusConnection* input_method_status_connection_;
ObserverList<Observer> observers_;
// The input method which was/is selected.
InputMethodDescriptor previous_input_method_;
InputMethodDescriptor current_input_method_;
// The input method properties which the current input method uses. The list
// might be empty when no input method is used.
ImePropertyList current_ime_properties_;
typedef std::pair<std::string, std::string> ConfigKeyType;
typedef std::map<ConfigKeyType, ImeConfigValue> InputMethodConfigRequests;
// SetImeConfig requests that are not yet completed.
// Use a map to queue config requests, so we only send the last request for
// the same config key (i.e. we'll discard ealier requests for the same
// config key). As we discard old requests for the same config key, the order
// of requests doesn't matter, so it's safe to use a map.
InputMethodConfigRequests pending_config_requests_;
// Values that have been set via SetImeConfig(). We keep a copy available to
// resend if the ime restarts and loses its state.
InputMethodConfigRequests current_config_values_;
// A timer for retrying to send |pendning_config_commands_| to the input
// method config daemon.
base::OneShotTimer<InputMethodLibraryImpl> timer_;
bool ime_running_;
bool ime_connected_;
bool defer_ime_startup_;
std::string active_input_method_;
bool need_input_method_set_;
int ime_handle_;
int candidate_window_handle_;
DISALLOW_COPY_AND_ASSIGN(InputMethodLibraryImpl);
};
InputMethodLibraryImpl::Observer::~Observer() {}
class InputMethodLibraryStubImpl : public InputMethodLibrary {
public:
InputMethodLibraryStubImpl()
: previous_input_method_("", "", "", ""),
current_input_method_("", "", "", "") {
}
~InputMethodLibraryStubImpl() {}
void AddObserver(Observer* observer) {}
void RemoveObserver(Observer* observer) {}
InputMethodDescriptors* GetActiveInputMethods() {
return CreateRealisticInputMethodDescriptors();
}
size_t GetNumActiveInputMethods() {
scoped_ptr<InputMethodDescriptors> descriptors(
CreateRealisticInputMethodDescriptors());
return descriptors->size();
}
InputMethodDescriptors* GetSupportedInputMethods() {
return CreateRealisticInputMethodDescriptors();
}
void ChangeInputMethod(const std::string& input_method_id) {}
void SetImePropertyActivated(const std::string& key, bool activated) {}
bool InputMethodIsActivated(const std::string& input_method_id) {
return true;
}
bool GetImeConfig(const char* section,
const char* config_name,
ImeConfigValue* out_value) {
return false;
}
bool SetImeConfig(const char* section,
const char* config_name,
const ImeConfigValue& value) {
return false;
}
virtual const InputMethodDescriptor& previous_input_method() const {
return previous_input_method_;
}
virtual const InputMethodDescriptor& current_input_method() const {
return current_input_method_;
}
virtual const ImePropertyList& current_ime_properties() const {
return current_ime_properties_;
}
virtual void StartInputMethodProcesses() {}
virtual void StopInputMethodProcesses() {}
virtual void SetDeferImeStartup(bool defer) {}
private:
// Creates realistic input method descriptors that can be used for
// testing Chrome OS version of chrome on regular Linux desktops.
InputMethodDescriptors* CreateRealisticInputMethodDescriptors() {
InputMethodDescriptors* descriptions = new InputMethodDescriptors;
// The list is created from output of gen_engines.py in libcros.
descriptions->push_back(InputMethodDescriptor(
"chewing", "Chewing", "us", "zh_TW"));
descriptions->push_back(InputMethodDescriptor(
"hangul", "Korean", "us", "ko"));
descriptions->push_back(InputMethodDescriptor(
"m17n:fa:isiri", "isiri (m17n)", "us", "fa"));
descriptions->push_back(InputMethodDescriptor(
"m17n:he:kbd", "kbd (m17n)", "us", "he"));
descriptions->push_back(InputMethodDescriptor(
"m17n:ar:kbd", "kbd (m17n)", "us", "ar"));
descriptions->push_back(InputMethodDescriptor(
"m17n:hi:itrans", "itrans (m17n)", "us", "hi"));
descriptions->push_back(InputMethodDescriptor(
"m17n:vi:vni", "vni (m17n)", "us", "vi"));
descriptions->push_back(InputMethodDescriptor(
"m17n:vi:viqr", "viqr (m17n)", "us", "vi"));
descriptions->push_back(InputMethodDescriptor(
"m17n:vi:tcvn", "tcvn (m17n)", "us", "vi"));
descriptions->push_back(InputMethodDescriptor(
"m17n:vi:telex", "telex (m17n)", "us", "vi"));
descriptions->push_back(InputMethodDescriptor(
"m17n:zh:cangjie", "cangjie (m17n)", "us", "zh"));
descriptions->push_back(InputMethodDescriptor(
"m17n:zh:quick", "quick (m17n)", "us", "zh"));
descriptions->push_back(InputMethodDescriptor(
"m17n:th:tis820", "tis820 (m17n)", "us", "th"));
descriptions->push_back(InputMethodDescriptor(
"m17n:th:kesmanee", "kesmanee (m17n)", "us", "th"));
descriptions->push_back(InputMethodDescriptor(
"m17n:th:pattachote", "pattachote (m17n)", "us", "th"));
descriptions->push_back(InputMethodDescriptor(
"mozc-jp", "Mozc (Japanese keyboard layout)", "jp", "ja"));
descriptions->push_back(InputMethodDescriptor(
"mozc", "Mozc (US keyboard layout)", "us", "ja"));
descriptions->push_back(InputMethodDescriptor(
"mozc-dv", "Mozc (US Dvorak keyboard layout)", "us(dvorak)", "ja"));
descriptions->push_back(InputMethodDescriptor(
"pinyin", "Pinyin", "us", "zh"));
descriptions->push_back(InputMethodDescriptor(
"bopomofo", "Bopomofo", "us", "zh"));
descriptions->push_back(InputMethodDescriptor(
"xkb:us::eng", "USA", "us", "eng"));
descriptions->push_back(InputMethodDescriptor(
"xkb:us:dvorak:eng", "USA - Dvorak", "us(dvorak)", "eng"));
descriptions->push_back(InputMethodDescriptor(
"xkb:be::ger", "Belgium", "be", "ger"));
descriptions->push_back(InputMethodDescriptor(
"xkb:be::nld", "Belgium", "be", "nld"));
descriptions->push_back(InputMethodDescriptor(
"xkb:be::fra", "Belgium", "be", "fra"));
descriptions->push_back(InputMethodDescriptor(
"xkb:br::por", "Brazil", "br", "por"));
descriptions->push_back(InputMethodDescriptor(
"xkb:bg::bul", "Bulgaria", "bg", "bul"));
descriptions->push_back(InputMethodDescriptor(
"xkb:ca::fra", "Canada", "ca", "fra"));
descriptions->push_back(InputMethodDescriptor(
"xkb:ca:eng:eng", "Canada - English", "ca(eng)", "eng"));
descriptions->push_back(InputMethodDescriptor(
"xkb:hr::scr", "Croatia", "hr", "scr"));
descriptions->push_back(InputMethodDescriptor(
"xkb:cz::cze", "Czechia", "cz", "cze"));
descriptions->push_back(InputMethodDescriptor(
"xkb:dk::dan", "Denmark", "dk", "dan"));
descriptions->push_back(InputMethodDescriptor(
"xkb:nl::nld", "Netherlands", "nl", "nld"));
descriptions->push_back(InputMethodDescriptor(
"xkb:ee::est", "Estonia", "ee", "est"));
descriptions->push_back(InputMethodDescriptor(
"xkb:fi::fin", "Finland", "fi", "fin"));
descriptions->push_back(InputMethodDescriptor(
"xkb:fr::fra", "France", "fr", "fra"));
descriptions->push_back(InputMethodDescriptor(
"xkb:de::ger", "Germany", "de", "ger"));
descriptions->push_back(InputMethodDescriptor(
"xkb:gr::gre", "Greece", "gr", "gre"));
descriptions->push_back(InputMethodDescriptor(
"xkb:hu::hun", "Hungary", "hu", "hun"));
descriptions->push_back(InputMethodDescriptor(
"xkb:it::ita", "Italy", "it", "ita"));
descriptions->push_back(InputMethodDescriptor(
"xkb:jp::jpn", "Japan", "jp", "jpn"));
descriptions->push_back(InputMethodDescriptor(
"xkb:lt::lit", "Lithuania", "lt", "lit"));
descriptions->push_back(InputMethodDescriptor(
"xkb:lv::lav", "Latvia", "lv", "lav"));
descriptions->push_back(InputMethodDescriptor(
"xkb:no::nor", "Norway", "no", "nor"));
descriptions->push_back(InputMethodDescriptor(
"xkb:pl::pol", "Poland", "pl", "pol"));
descriptions->push_back(InputMethodDescriptor(
"xkb:pt::por", "Portugal", "pt", "por"));
descriptions->push_back(InputMethodDescriptor(
"xkb:ro::rum", "Romania", "ro", "rum"));
descriptions->push_back(InputMethodDescriptor(
"xkb:ru::rus", "Russia", "ru", "rus"));
descriptions->push_back(InputMethodDescriptor(
"xkb:rs::srp", "Serbia", "rs", "srp"));
descriptions->push_back(InputMethodDescriptor(
"xkb:si::slv", "Slovenia", "si", "slv"));
descriptions->push_back(InputMethodDescriptor(
"xkb:sk::slo", "Slovakia", "sk", "slo"));
descriptions->push_back(InputMethodDescriptor(
"xkb:es::spa", "Spain", "es", "spa"));
descriptions->push_back(InputMethodDescriptor(
"xkb:es:cat:cat",
"Spain - Catalan variant with middle-dot L", "es(cat)", "cat"));
descriptions->push_back(InputMethodDescriptor(
"xkb:se::swe", "Sweden", "se", "swe"));
descriptions->push_back(InputMethodDescriptor(
"xkb:ch::ger", "Switzerland", "ch", "ger"));
descriptions->push_back(InputMethodDescriptor(
"xkb:ch:fr:fra", "Switzerland - French", "ch(fr)", "fra"));
descriptions->push_back(InputMethodDescriptor(
"xkb:tr::tur", "Turkey", "tr", "tur"));
descriptions->push_back(InputMethodDescriptor(
"xkb:ua::ukr", "Ukraine", "ua", "ukr"));
descriptions->push_back(InputMethodDescriptor(
"xkb:gb:extd:eng", "United Kingdom - Extended - Winkeys", "gb(extd)",
"eng"));
return descriptions;
}
InputMethodDescriptor previous_input_method_;
InputMethodDescriptor current_input_method_;
ImePropertyList current_ime_properties_;
DISALLOW_COPY_AND_ASSIGN(InputMethodLibraryStubImpl);
};
// static
InputMethodLibrary* InputMethodLibrary::GetImpl(bool stub) {
if (stub)
return new InputMethodLibraryStubImpl();
else
return new InputMethodLibraryImpl();
}
} // namespace chromeos
// Allows InvokeLater without adding refcounting. This class is a Singleton and
// won't be deleted until it's last InvokeLater is run.
DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::InputMethodLibraryImpl);
|