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/component_extension_ime_manager.h" | 5 #include "chromeos/ime/component_extension_ime_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "chromeos/ime/extension_ime_util.h" | 9 #include "chromeos/ime/extension_ime_util.h" |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 ComponentExtensionIME::~ComponentExtensionIME() { | 69 ComponentExtensionIME::~ComponentExtensionIME() { |
70 } | 70 } |
71 | 71 |
72 ComponentExtensionIMEManagerDelegate::ComponentExtensionIMEManagerDelegate() { | 72 ComponentExtensionIMEManagerDelegate::ComponentExtensionIMEManagerDelegate() { |
73 } | 73 } |
74 | 74 |
75 ComponentExtensionIMEManagerDelegate::~ComponentExtensionIMEManagerDelegate() { | 75 ComponentExtensionIMEManagerDelegate::~ComponentExtensionIMEManagerDelegate() { |
76 } | 76 } |
77 | 77 |
78 ComponentExtensionIMEManager::ComponentExtensionIMEManager() | 78 ComponentExtensionIMEManager::ComponentExtensionIMEManager() |
79 : is_initialized_(false) { | 79 : is_initialized_(false), was_initialization_notified_(false) { |
80 for (size_t i = 0; i < arraysize(kLoginLayoutWhitelist); ++i) { | 80 for (size_t i = 0; i < arraysize(kLoginLayoutWhitelist); ++i) { |
81 login_layout_set_.insert(kLoginLayoutWhitelist[i]); | 81 login_layout_set_.insert(kLoginLayoutWhitelist[i]); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 ComponentExtensionIMEManager::~ComponentExtensionIMEManager() { | 85 ComponentExtensionIMEManager::~ComponentExtensionIMEManager() { |
86 } | 86 } |
87 | 87 |
88 void ComponentExtensionIMEManager::Initialize( | 88 void ComponentExtensionIMEManager::Initialize( |
89 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate) { | 89 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate) { |
90 delegate_ = delegate.Pass(); | 90 delegate_ = delegate.Pass(); |
91 component_extension_imes_ = delegate_->ListIME(); | 91 component_extension_imes_ = delegate_->ListIME(); |
92 is_initialized_ = true; | 92 is_initialized_ = true; |
93 FOR_EACH_OBSERVER(Observer, observers_, OnInitialized()); | 93 } |
| 94 |
| 95 void ComponentExtensionIMEManager::NotifyInitialized() { |
| 96 if (is_initialized_ && !was_initialization_notified_) { |
| 97 FOR_EACH_OBSERVER( |
| 98 Observer, observers_, OnImeComponentExtensionInitialized()); |
| 99 was_initialization_notified_ = true; |
| 100 } |
94 } | 101 } |
95 | 102 |
96 bool ComponentExtensionIMEManager::IsInitialized() { | 103 bool ComponentExtensionIMEManager::IsInitialized() { |
97 return is_initialized_; | 104 return is_initialized_; |
98 } | 105 } |
99 | 106 |
100 bool ComponentExtensionIMEManager::LoadComponentExtensionIME( | 107 bool ComponentExtensionIMEManager::LoadComponentExtensionIME( |
101 const std::string& input_method_id) { | 108 const std::string& input_method_id) { |
102 ComponentExtensionIME ime; | 109 ComponentExtensionIME ime; |
103 if (FindEngineEntry(input_method_id, &ime, NULL)) | 110 if (FindEngineEntry(input_method_id, &ime, NULL)) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // Enables extension based xkb keyboards on login screen. | 203 // Enables extension based xkb keyboards on login screen. |
197 extension_ime_util::IsKeyboardLayoutExtension( | 204 extension_ime_util::IsKeyboardLayoutExtension( |
198 input_method_id) && IsInLoginLayoutWhitelist(layouts), | 205 input_method_id) && IsInLoginLayoutWhitelist(layouts), |
199 component_extension_imes_[i].options_page_url, | 206 component_extension_imes_[i].options_page_url, |
200 component_extension_imes_[i].input_view_url)); | 207 component_extension_imes_[i].input_view_url)); |
201 } | 208 } |
202 } | 209 } |
203 return result; | 210 return result; |
204 } | 211 } |
205 | 212 |
| 213 input_method::InputMethodDescriptors |
| 214 ComponentExtensionIMEManager::GetXkbIMEAsInputMethodDescriptor() { |
| 215 input_method::InputMethodDescriptors result; |
| 216 const input_method::InputMethodDescriptors& descriptors = |
| 217 GetAllIMEAsInputMethodDescriptor(); |
| 218 for (size_t i = 0; i < descriptors.size(); ++i) { |
| 219 if (extension_ime_util::IsKeyboardLayoutExtension(descriptors[i].id())) |
| 220 result.push_back(descriptors[i]); |
| 221 } |
| 222 return result; |
| 223 } |
| 224 |
206 void ComponentExtensionIMEManager::AddObserver(Observer* observer) { | 225 void ComponentExtensionIMEManager::AddObserver(Observer* observer) { |
207 observers_.AddObserver(observer); | 226 observers_.AddObserver(observer); |
208 } | 227 } |
209 | 228 |
210 void ComponentExtensionIMEManager::RemoveObserver(Observer* observer) { | 229 void ComponentExtensionIMEManager::RemoveObserver(Observer* observer) { |
211 observers_.RemoveObserver(observer); | 230 observers_.RemoveObserver(observer); |
212 } | 231 } |
213 | 232 |
214 bool ComponentExtensionIMEManager::FindEngineEntry( | 233 bool ComponentExtensionIMEManager::FindEngineEntry( |
215 const std::string& input_method_id, | 234 const std::string& input_method_id, |
(...skipping 26 matching lines...) Expand all Loading... |
242 bool ComponentExtensionIMEManager::IsInLoginLayoutWhitelist( | 261 bool ComponentExtensionIMEManager::IsInLoginLayoutWhitelist( |
243 const std::vector<std::string>& layouts) { | 262 const std::vector<std::string>& layouts) { |
244 for (size_t i = 0; i < layouts.size(); ++i) { | 263 for (size_t i = 0; i < layouts.size(); ++i) { |
245 if (login_layout_set_.find(layouts[i]) != login_layout_set_.end()) | 264 if (login_layout_set_.find(layouts[i]) != login_layout_set_.end()) |
246 return true; | 265 return true; |
247 } | 266 } |
248 return false; | 267 return false; |
249 } | 268 } |
250 | 269 |
251 } // namespace chromeos | 270 } // namespace chromeos |
OLD | NEW |