OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 10 #include "extensions/browser/browser_context_keyed_api_factory.h" |
11 #include "extensions/browser/event_router.h" | 11 #include "extensions/browser/event_router.h" |
12 #include "extensions/browser/extension_function.h" | 12 #include "extensions/browser/extension_function.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 class ExtensionInputMethodEventRouter; | 15 class ExtensionInputMethodEventRouter; |
16 } | 16 } |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 // Implements the experimental.inputMethod.get method. | 20 // Implements the experimental.inputMethod.get method. |
(...skipping 19 matching lines...) Expand all Loading... |
40 protected: | 40 protected: |
41 virtual ~StartImeFunction(); | 41 virtual ~StartImeFunction(); |
42 | 42 |
43 virtual bool RunImpl() OVERRIDE; | 43 virtual bool RunImpl() OVERRIDE; |
44 | 44 |
45 private: | 45 private: |
46 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.startIme", | 46 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.startIme", |
47 INPUTMETHODPRIVATE_STARTIME) | 47 INPUTMETHODPRIVATE_STARTIME) |
48 }; | 48 }; |
49 | 49 |
50 class InputMethodAPI : public ProfileKeyedAPI, | 50 class InputMethodAPI : public BrowserContextKeyedAPI, |
51 public extensions::EventRouter::Observer { | 51 public extensions::EventRouter::Observer { |
52 public: | 52 public: |
53 explicit InputMethodAPI(content::BrowserContext* context); | 53 explicit InputMethodAPI(content::BrowserContext* context); |
54 virtual ~InputMethodAPI(); | 54 virtual ~InputMethodAPI(); |
55 | 55 |
56 // Returns input method name for the given XKB (X keyboard extensions in X | 56 // Returns input method name for the given XKB (X keyboard extensions in X |
57 // Window System) id. | 57 // Window System) id. |
58 static std::string GetInputMethodForXkb(const std::string& xkb_id); | 58 static std::string GetInputMethodForXkb(const std::string& xkb_id); |
59 | 59 |
60 // ProfileKeyedAPI implementation. | 60 // BrowserContextKeyedAPI implementation. |
61 static ProfileKeyedAPIFactory<InputMethodAPI>* GetFactoryInstance(); | 61 static BrowserContextKeyedAPIFactory<InputMethodAPI>* GetFactoryInstance(); |
62 | 62 |
63 // ProfileKeyedAPI implementation. | 63 // BrowserContextKeyedAPI implementation. |
64 virtual void Shutdown() OVERRIDE; | 64 virtual void Shutdown() OVERRIDE; |
65 | 65 |
66 // EventRouter::Observer implementation. | 66 // EventRouter::Observer implementation. |
67 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) | 67 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) |
68 OVERRIDE; | 68 OVERRIDE; |
69 | 69 |
70 private: | 70 private: |
71 friend class ProfileKeyedAPIFactory<InputMethodAPI>; | 71 friend class BrowserContextKeyedAPIFactory<InputMethodAPI>; |
72 | 72 |
73 // ProfileKeyedAPI implementation. | 73 // BrowserContextKeyedAPI implementation. |
74 static const char* service_name() { | 74 static const char* service_name() { |
75 return "InputMethodAPI"; | 75 return "InputMethodAPI"; |
76 } | 76 } |
77 static const bool kServiceIsNULLWhileTesting = true; | 77 static const bool kServiceIsNULLWhileTesting = true; |
78 | 78 |
79 content::BrowserContext* const context_; | 79 content::BrowserContext* const context_; |
80 | 80 |
81 // Created lazily upon OnListenerAdded. | 81 // Created lazily upon OnListenerAdded. |
82 scoped_ptr<chromeos::ExtensionInputMethodEventRouter> | 82 scoped_ptr<chromeos::ExtensionInputMethodEventRouter> |
83 input_method_event_router_; | 83 input_method_event_router_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(InputMethodAPI); | 85 DISALLOW_COPY_AND_ASSIGN(InputMethodAPI); |
86 }; | 86 }; |
87 | 87 |
88 } // namespace extensions | 88 } // namespace extensions |
89 | 89 |
90 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ | 90 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ |
OLD | NEW |