| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 InputComponents::GetInputComponents(extension); | 620 InputComponents::GetInputComponents(extension); |
| 621 InputImeEventRouter* event_router = | 621 InputImeEventRouter* event_router = |
| 622 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context)); | 622 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context)); |
| 623 if (input_components && event_router) { | 623 if (input_components && event_router) { |
| 624 event_router->RegisterImeExtension(extension->id(), *input_components); | 624 event_router->RegisterImeExtension(extension->id(), *input_components); |
| 625 } | 625 } |
| 626 } | 626 } |
| 627 | 627 |
| 628 void InputImeAPI::OnExtensionUnloaded(content::BrowserContext* browser_context, | 628 void InputImeAPI::OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 629 const Extension* extension, | 629 const Extension* extension, |
| 630 UnloadedExtensionInfo::Reason reason) { | 630 UnloadedExtensionReason reason) { |
| 631 const std::vector<InputComponentInfo>* input_components = | 631 const std::vector<InputComponentInfo>* input_components = |
| 632 InputComponents::GetInputComponents(extension); | 632 InputComponents::GetInputComponents(extension); |
| 633 if (!input_components || input_components->empty()) | 633 if (!input_components || input_components->empty()) |
| 634 return; | 634 return; |
| 635 InputImeEventRouter* event_router = | 635 InputImeEventRouter* event_router = |
| 636 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context)); | 636 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context)); |
| 637 if (event_router) { | 637 if (event_router) { |
| 638 event_router->UnregisterAllImes(extension->id()); | 638 event_router->UnregisterAllImes(extension->id()); |
| 639 } | 639 } |
| 640 } | 640 } |
| 641 | 641 |
| 642 void InputImeAPI::OnListenerAdded(const EventListenerInfo& details) { | 642 void InputImeAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 643 if (!details.browser_context) | 643 if (!details.browser_context) |
| 644 return; | 644 return; |
| 645 InputMethodEngine* engine = | 645 InputMethodEngine* engine = |
| 646 GetActiveEngine(Profile::FromBrowserContext(details.browser_context), | 646 GetActiveEngine(Profile::FromBrowserContext(details.browser_context), |
| 647 details.extension_id); | 647 details.extension_id); |
| 648 // Notifies the IME extension for IME ready with onActivate/onFocus events. | 648 // Notifies the IME extension for IME ready with onActivate/onFocus events. |
| 649 if (engine) | 649 if (engine) |
| 650 engine->Enable(engine->GetActiveComponentId()); | 650 engine->Enable(engine->GetActiveComponentId()); |
| 651 } | 651 } |
| 652 | 652 |
| 653 } // namespace extensions | 653 } // namespace extensions |
| OLD | NEW |