OLD | NEW |
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/extensions/api/input_ime/input_ime_api.h" | 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | 9 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
10 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 10 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 if ((*it)->extension_id() == extension_id_ && !(*it)->IsLazy()) | 302 if ((*it)->extension_id() == extension_id_ && !(*it)->IsLazy()) |
303 return true; | 303 return true; |
304 } | 304 } |
305 return false; | 305 return false; |
306 } | 306 } |
307 | 307 |
308 // The component IME extensions need to know the current screen type (e.g. | 308 // The component IME extensions need to know the current screen type (e.g. |
309 // lock screen, login screen, etc.) so that its on-screen keyboard page | 309 // lock screen, login screen, etc.) so that its on-screen keyboard page |
310 // won't open new windows/pages. See crbug.com/395621. | 310 // won't open new windows/pages. See crbug.com/395621. |
311 std::string GetCurrentScreenType() { | 311 std::string GetCurrentScreenType() { |
312 switch (chromeos::input_method::InputMethodManager::Get()->GetState()) { | 312 switch (chromeos::input_method::InputMethodManager::Get() |
| 313 ->GetUISessionState()) { |
313 case chromeos::input_method::InputMethodManager::STATE_LOGIN_SCREEN: | 314 case chromeos::input_method::InputMethodManager::STATE_LOGIN_SCREEN: |
314 return "login"; | 315 return "login"; |
315 case chromeos::input_method::InputMethodManager::STATE_LOCK_SCREEN: | 316 case chromeos::input_method::InputMethodManager::STATE_LOCK_SCREEN: |
316 return "lock"; | 317 return "lock"; |
317 case chromeos::input_method::InputMethodManager::STATE_BROWSER_SCREEN: | 318 case chromeos::input_method::InputMethodManager::STATE_BROWSER_SCREEN: |
318 return UserAddingScreen::Get()->IsRunning() ? "secondary-login" | 319 return UserAddingScreen::Get()->IsRunning() ? "secondary-login" |
319 : "normal"; | 320 : "normal"; |
320 case chromeos::input_method::InputMethodManager::STATE_TERMINATING: | 321 case chromeos::input_method::InputMethodManager::STATE_TERMINATING: |
321 return "normal"; | 322 return "normal"; |
322 } | 323 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 component.options_page_url, | 381 component.options_page_url, |
381 component.input_view_url)); | 382 component.input_view_url)); |
382 } | 383 } |
383 } | 384 } |
384 | 385 |
385 scoped_ptr<chromeos::InputMethodEngineInterface::Observer> observer( | 386 scoped_ptr<chromeos::InputMethodEngineInterface::Observer> observer( |
386 new chromeos::ImeObserver(extension_id)); | 387 new chromeos::ImeObserver(extension_id)); |
387 chromeos::InputMethodEngine* engine = new chromeos::InputMethodEngine(); | 388 chromeos::InputMethodEngine* engine = new chromeos::InputMethodEngine(); |
388 engine->Initialize(observer.Pass(), extension_id.c_str()); | 389 engine->Initialize(observer.Pass(), extension_id.c_str()); |
389 engine_map_[extension_id] = engine; | 390 engine_map_[extension_id] = engine; |
390 manager->AddInputMethodExtension(extension_id, descriptors, engine); | 391 manager->GetActiveIMEState()->AddInputMethodExtension( |
| 392 extension_id, descriptors, engine); |
391 | 393 |
392 return true; | 394 return true; |
393 } | 395 } |
394 | 396 |
395 void InputImeEventRouter::UnregisterAllImes(const std::string& extension_id) { | 397 void InputImeEventRouter::UnregisterAllImes(const std::string& extension_id) { |
396 std::map<std::string, InputMethodEngineInterface*>::iterator it = | 398 std::map<std::string, InputMethodEngineInterface*>::iterator it = |
397 engine_map_.find(extension_id); | 399 engine_map_.find(extension_id); |
398 if (it != engine_map_.end()) { | 400 if (it != engine_map_.end()) { |
399 chromeos::input_method::InputMethodManager::Get() | 401 chromeos::input_method::InputMethodManager::Get() |
| 402 ->GetActiveIMEState() |
400 ->RemoveInputMethodExtension(extension_id); | 403 ->RemoveInputMethodExtension(extension_id); |
401 delete it->second; | 404 delete it->second; |
402 engine_map_.erase(it); | 405 engine_map_.erase(it); |
403 } | 406 } |
404 } | 407 } |
405 | 408 |
406 InputMethodEngineInterface* InputImeEventRouter::GetEngine( | 409 InputMethodEngineInterface* InputImeEventRouter::GetEngine( |
407 const std::string& extension_id, | 410 const std::string& extension_id, |
408 const std::string& component_id) { | 411 const std::string& component_id) { |
409 std::map<std::string, InputMethodEngineInterface*>::iterator it = | 412 std::map<std::string, InputMethodEngineInterface*>::iterator it = |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 // Notifies the IME extension for IME ready with onActivate/onFocus events. | 846 // Notifies the IME extension for IME ready with onActivate/onFocus events. |
844 if (engine) | 847 if (engine) |
845 engine->Enable(engine->GetActiveComponentId()); | 848 engine->Enable(engine->GetActiveComponentId()); |
846 } | 849 } |
847 | 850 |
848 InputImeEventRouter* InputImeAPI::input_ime_event_router() { | 851 InputImeEventRouter* InputImeAPI::input_ime_event_router() { |
849 return InputImeEventRouter::GetInstance(); | 852 return InputImeEventRouter::GetInstance(); |
850 } | 853 } |
851 | 854 |
852 } // namespace extensions | 855 } // namespace extensions |
OLD | NEW |