OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_BASE_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_BASE_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 #include <utility> | |
11 | |
12 #include "base/observer_list.h" | |
13 #include "chrome/browser/chromeos/input_method/input_method_config.h" | |
14 #include "chrome/browser/chromeos/input_method/input_method_property.h" | |
15 #include "chrome/browser/chromeos/input_method/ibus_controller.h" | |
Seigo Nonaka
2012/04/16 16:17:16
nit: alphabetic order if possible.
Yusuke Sato
2012/04/17 02:23:32
Done.
| |
16 | |
17 namespace chromeos { | |
18 namespace input_method { | |
19 | |
20 // The common implementation of the IBusController. This file does not depend on | |
21 // libibus, hence is unit-testable. | |
22 class IBusControllerBase : public IBusController { | |
23 public: | |
24 IBusControllerBase(); | |
25 virtual ~IBusControllerBase(); | |
26 | |
27 // IBusController overrides. Derived classes should not override these 4 | |
28 // functions. | |
29 virtual void AddObserver(Observer* observer) OVERRIDE; | |
30 virtual void RemoveObserver(Observer* observer) OVERRIDE; | |
31 virtual bool SetInputMethodConfig( | |
32 const std::string& section, | |
33 const std::string& config_name, | |
34 const InputMethodConfigValue& value) OVERRIDE; | |
35 virtual const InputMethodPropertyList& GetCurrentProperties() const OVERRIDE; | |
36 | |
37 // Gets the current input method configuration. | |
38 bool GetInputMethodConfigForTesting(const std::string& section, | |
39 const std::string& config_name, | |
40 InputMethodConfigValue* out_value); | |
41 | |
42 // Notifies all |observers_|. | |
43 void NotifyPropertyChangedForTesting(); | |
44 | |
45 // Updates |current_property_list_|. | |
46 void SetCurrentPropertiesForTesting( | |
47 const InputMethodPropertyList& current_property_list); | |
48 | |
49 protected: | |
50 typedef std::pair<std::string, std::string> ConfigKeyType; | |
51 typedef std::map< | |
52 ConfigKeyType, InputMethodConfigValue> InputMethodConfigRequests; | |
53 | |
54 virtual bool SetInputMethodConfigInternal( | |
55 const ConfigKeyType& key, | |
56 const InputMethodConfigValue& value) = 0; | |
57 | |
58 ObserverList<Observer> observers_; | |
59 | |
60 // Values that have been set via SetInputMethodConfig(). We keep a copy | |
61 // available to (re)send when the system input method framework (re)starts. | |
62 InputMethodConfigRequests current_config_values_; | |
63 | |
64 // The value which will be returned by GetCurrentProperties(). Derived classes | |
65 // should update this variable when needed. | |
66 InputMethodPropertyList current_property_list_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(IBusControllerBase); | |
69 }; | |
70 | |
71 } // namespace input_method | |
72 } // namespace chromeos | |
73 | |
74 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_BASE_H_ | |
OLD | NEW |