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