Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / ime / chromeos / ime_keyboard.cc
blob200d0cadfe59f6c3c2c31f072a79e4454c925b6d
1 // Copyright 2014 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.
5 #include "ui/base/ime/chromeos/ime_keyboard.h"
7 namespace chromeos {
8 namespace input_method {
9 namespace {
11 const char *kISOLevel5ShiftLayoutIds[] = {
12 "ca(multix)",
13 "de(neo)",
16 const char *kAltGrLayoutIds[] = {
17 "be",
18 "be",
19 "be",
20 "bg",
21 "bg(phonetic)",
22 "br",
23 "ca",
24 "ca(eng)",
25 "ca(multix)",
26 "ch",
27 "ch(fr)",
28 "cz",
29 "de",
30 "de(neo)",
31 "dk",
32 "ee",
33 "es",
34 "es(cat)",
35 "fi",
36 "fr",
37 "gb(dvorak)",
38 "gb(extd)",
39 "gr",
40 "hr",
41 "il",
42 "it",
43 "latam",
44 "lt",
45 "no",
46 "pl",
47 "pt",
48 "ro",
49 "se",
50 "si",
51 "sk",
52 "tr",
53 "ua",
54 "us(altgr-intl)",
55 "us(intl)",
58 } // namespace
60 ImeKeyboard::ImeKeyboard()
61 : caps_lock_is_enabled_(false) {
64 ImeKeyboard::~ImeKeyboard() {
67 void ImeKeyboard::AddObserver(Observer* observer) {
68 observers_.AddObserver(observer);
71 void ImeKeyboard::RemoveObserver(Observer* observer) {
72 observers_.RemoveObserver(observer);
75 void ImeKeyboard::SetCapsLockEnabled(bool enable_caps_lock) {
76 bool old_state = caps_lock_is_enabled_;
77 caps_lock_is_enabled_ = enable_caps_lock;
78 if (old_state != enable_caps_lock) {
79 FOR_EACH_OBSERVER(ImeKeyboard::Observer, observers_,
80 OnCapsLockChanged(enable_caps_lock));
84 bool ImeKeyboard::CapsLockIsEnabled() {
85 return caps_lock_is_enabled_;
88 bool ImeKeyboard::IsISOLevel5ShiftAvailable() const {
89 for (size_t i = 0; i < arraysize(kISOLevel5ShiftLayoutIds); ++i) {
90 if (last_layout_ == kISOLevel5ShiftLayoutIds[i])
91 return true;
93 return false;
96 bool ImeKeyboard::IsAltGrAvailable() const {
97 for (size_t i = 0; i < arraysize(kAltGrLayoutIds); ++i) {
98 if (last_layout_ == kAltGrLayoutIds[i])
99 return true;
101 return false;
104 } // namespace input_method
105 } // namespace chromeos