/chromium-webcl/src/chrome/browser/chromeos/extensions/input_method_api.h

https://bitbucket.org/peixuan/chromium_r197479_base · C Header · 74 lines · 43 code · 20 blank · 11 comment · 0 complexity · a5afaa4f4d9e94fce933e24d8c87d372 MD5 · raw file

  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_
  5. #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_
  6. #include "base/compiler_specific.h"
  7. #include "base/memory/scoped_ptr.h"
  8. #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
  9. #include "chrome/browser/extensions/event_router.h"
  10. #include "chrome/browser/extensions/extension_function.h"
  11. namespace chromeos {
  12. class ExtensionInputMethodEventRouter;
  13. }
  14. namespace extensions {
  15. // Implements the experimental.inputMethod.get method.
  16. class GetInputMethodFunction : public SyncExtensionFunction {
  17. public:
  18. GetInputMethodFunction();
  19. protected:
  20. virtual ~GetInputMethodFunction();
  21. virtual bool RunImpl() OVERRIDE;
  22. private:
  23. DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.get", INPUTMETHODPRIVATE_GET)
  24. };
  25. class InputMethodAPI : public ProfileKeyedAPI,
  26. public extensions::EventRouter::Observer {
  27. public:
  28. explicit InputMethodAPI(Profile* profile);
  29. virtual ~InputMethodAPI();
  30. // Returns input method name for the given XKB (X keyboard extensions in X
  31. // Window System) id.
  32. static std::string GetInputMethodForXkb(const std::string& xkb_id);
  33. // ProfileKeyedAPI implementation.
  34. static ProfileKeyedAPIFactory<InputMethodAPI>* GetFactoryInstance();
  35. // ProfileKeyedAPI implementation.
  36. virtual void Shutdown() OVERRIDE;
  37. // EventRouter::Observer implementation.
  38. virtual void OnListenerAdded(const extensions::EventListenerInfo& details)
  39. OVERRIDE;
  40. private:
  41. friend class ProfileKeyedAPIFactory<InputMethodAPI>;
  42. // ProfileKeyedAPI implementation.
  43. static const char* service_name() {
  44. return "InputMethodAPI";
  45. }
  46. static const bool kServiceIsNULLWhileTesting = true;
  47. Profile* const profile_;
  48. // Created lazily upon OnListenerAdded.
  49. scoped_ptr<chromeos::ExtensionInputMethodEventRouter>
  50. input_method_event_router_;
  51. DISALLOW_COPY_AND_ASSIGN(InputMethodAPI);
  52. };
  53. } // namespace extensions
  54. #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_