| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 if (input_components && event_router) { | 614 if (input_components && event_router) { |
| 615 event_router->RegisterImeExtension(extension->id(), *input_components); | 615 event_router->RegisterImeExtension(extension->id(), *input_components); |
| 616 } | 616 } |
| 617 } | 617 } |
| 618 | 618 |
| 619 void InputImeAPI::OnExtensionUnloaded(content::BrowserContext* browser_context, | 619 void InputImeAPI::OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 620 const Extension* extension, | 620 const Extension* extension, |
| 621 UnloadedExtensionInfo::Reason reason) { | 621 UnloadedExtensionInfo::Reason reason) { |
| 622 const std::vector<InputComponentInfo>* input_components = | 622 const std::vector<InputComponentInfo>* input_components = |
| 623 InputComponents::GetInputComponents(extension); | 623 InputComponents::GetInputComponents(extension); |
| 624 if (!input_components || input_components->empty()) |
| 625 return; |
| 624 InputImeEventRouter* event_router = | 626 InputImeEventRouter* event_router = |
| 625 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context)); | 627 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context)); |
| 626 if (input_components && !input_components->empty() && event_router) { | 628 if (event_router) { |
| 627 event_router->UnregisterAllImes(extension->id()); | 629 event_router->UnregisterAllImes(extension->id()); |
| 628 } | 630 } |
| 629 } | 631 } |
| 630 | 632 |
| 631 void InputImeAPI::OnListenerAdded(const EventListenerInfo& details) { | 633 void InputImeAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 632 if (!details.browser_context) | 634 if (!details.browser_context) |
| 633 return; | 635 return; |
| 634 InputMethodEngine* engine = | 636 InputMethodEngine* engine = |
| 635 GetActiveEngine(Profile::FromBrowserContext(details.browser_context), | 637 GetActiveEngine(Profile::FromBrowserContext(details.browser_context), |
| 636 details.extension_id); | 638 details.extension_id); |
| 637 // Notifies the IME extension for IME ready with onActivate/onFocus events. | 639 // Notifies the IME extension for IME ready with onActivate/onFocus events. |
| 638 if (engine) | 640 if (engine) |
| 639 engine->Enable(engine->GetActiveComponentId()); | 641 engine->Enable(engine->GetActiveComponentId()); |
| 640 } | 642 } |
| 641 | 643 |
| 642 } // namespace extensions | 644 } // namespace extensions |
| OLD | NEW |