Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_) { | |
| 97 FOR_EACH_OBSERVER(Observer, observers_, OnInitialized()); | |
|
Seigo Nonaka
2014/03/07 07:21:21
Why NotifyInitialized function is needed?
It is na
Shu Chen
2014/03/07 07:30:29
Please refer to line 419 of input_method_manager_i
| |
| 98 } | |
| 94 } | 99 } |
| 95 | 100 |
| 96 bool ComponentExtensionIMEManager::IsInitialized() { | 101 bool ComponentExtensionIMEManager::IsInitialized() { |
| 97 return is_initialized_; | 102 return is_initialized_; |
| 98 } | 103 } |
| 99 | 104 |
| 100 bool ComponentExtensionIMEManager::LoadComponentExtensionIME( | 105 bool ComponentExtensionIMEManager::LoadComponentExtensionIME( |
| 101 const std::string& input_method_id) { | 106 const std::string& input_method_id) { |
| 102 ComponentExtensionIME ime; | 107 ComponentExtensionIME ime; |
| 103 if (FindEngineEntry(input_method_id, &ime, NULL)) | 108 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. | 201 // Enables extension based xkb keyboards on login screen. |
| 197 extension_ime_util::IsKeyboardLayoutExtension( | 202 extension_ime_util::IsKeyboardLayoutExtension( |
| 198 input_method_id) && IsInLoginLayoutWhitelist(layouts), | 203 input_method_id) && IsInLoginLayoutWhitelist(layouts), |
| 199 component_extension_imes_[i].options_page_url, | 204 component_extension_imes_[i].options_page_url, |
| 200 component_extension_imes_[i].input_view_url)); | 205 component_extension_imes_[i].input_view_url)); |
| 201 } | 206 } |
| 202 } | 207 } |
| 203 return result; | 208 return result; |
| 204 } | 209 } |
| 205 | 210 |
| 211 input_method::InputMethodDescriptors | |
| 212 ComponentExtensionIMEManager::GetXkbIMEAsInputMethodDescriptor() { | |
| 213 input_method::InputMethodDescriptors result; | |
| 214 input_method::InputMethodDescriptors descriptors = | |
|
Yuki
2014/03/07 07:47:04
Make this a const reference. It's a good practice
Shu Chen
2014/03/07 08:24:09
Done.
| |
| 215 GetAllIMEAsInputMethodDescriptor(); | |
| 216 for (size_t i = 0; i < descriptors.size(); ++i) { | |
| 217 if (extension_ime_util::IsKeyboardLayoutExtension(descriptors[i].id())) | |
| 218 result.push_back(descriptors[i]); | |
| 219 } | |
| 220 return result; | |
| 221 } | |
| 222 | |
| 206 void ComponentExtensionIMEManager::AddObserver(Observer* observer) { | 223 void ComponentExtensionIMEManager::AddObserver(Observer* observer) { |
| 207 observers_.AddObserver(observer); | 224 observers_.AddObserver(observer); |
| 208 } | 225 } |
| 209 | 226 |
| 210 void ComponentExtensionIMEManager::RemoveObserver(Observer* observer) { | 227 void ComponentExtensionIMEManager::RemoveObserver(Observer* observer) { |
| 211 observers_.RemoveObserver(observer); | 228 observers_.RemoveObserver(observer); |
| 212 } | 229 } |
| 213 | 230 |
| 214 bool ComponentExtensionIMEManager::FindEngineEntry( | 231 bool ComponentExtensionIMEManager::FindEngineEntry( |
| 215 const std::string& input_method_id, | 232 const std::string& input_method_id, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 242 bool ComponentExtensionIMEManager::IsInLoginLayoutWhitelist( | 259 bool ComponentExtensionIMEManager::IsInLoginLayoutWhitelist( |
| 243 const std::vector<std::string>& layouts) { | 260 const std::vector<std::string>& layouts) { |
| 244 for (size_t i = 0; i < layouts.size(); ++i) { | 261 for (size_t i = 0; i < layouts.size(); ++i) { |
| 245 if (login_layout_set_.find(layouts[i]) != login_layout_set_.end()) | 262 if (login_layout_set_.find(layouts[i]) != login_layout_set_.end()) |
| 246 return true; | 263 return true; |
| 247 } | 264 } |
| 248 return false; | 265 return false; |
| 249 } | 266 } |
| 250 | 267 |
| 251 } // namespace chromeos | 268 } // namespace chromeos |
| OLD | NEW |