summaryrefslogtreecommitdiffstats
path: root/ash/system
diff options
context:
space:
mode:
authoryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-18 05:55:34 +0000
committeryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-18 05:55:34 +0000
commitdbc9b198cbc5c00c70e39005497d9e742bb49398 (patch)
treea33ef11679bb7149a3f45ba43d2a53ed6607f5d1 /ash/system
parent3d6d9f84435db479cee00bfe7000b224a1801554 (diff)
downloadchromium_src-dbc9b198cbc5c00c70e39005497d9e742bb49398.zip
chromium_src-dbc9b198cbc5c00c70e39005497d9e742bb49398.tar.gz
chromium_src-dbc9b198cbc5c00c70e39005497d9e742bb49398.tar.bz2
chrome/browser/chromeos/input_method/ refactoring [part 6 of 6].
* Overview of the change The main purpose of this CL is to make InputMethodManager fully unit-testable. To accomplish that, InputMethodManager is modified as follows: - Add setters to set mock versions of IBusController, CandidateWindowController, and XKeyboard. - Move ibus-daemon startup and shutdown code from the manager to IBusControllerImpl. They lived in the manager only for historical reasons. - Remove code for monitoring the status of the connection between Chrome and ibus-daemon (InputMethodManager::OnConnectionChange(bool)). This kind of thing should also be done in IBusControllerImpl. * Details ash/shell.cc: ash/system/ime/tray_ime.cc: ash/system/tray/system_tray*.*: chrome/browser/chromeos/system/ash_system_tray_delegate.cc: Remove unused parameter |is_selection| from the SystemTrayDelegate interface following sadrul's suggestion in http://codereview.chromium.org/10008043/. chrome/browser/chromeos/chrome_browser_main_chromeos.cc: Initialize() and Shutdown() InputMethodManager. chrome/browser/chromeos/extensions/input_method_event_router.h: chrome/browser/chromeos/extensions/input_method_event_router.cc: Follow the interface change of InputMethodManager::Observer. Implementation is not changed at all. chrome/browser/chromeos/input_method/browser_state_monitor.h: chrome/browser/chromeos/input_method/browser_state_monitor.cc: Follow the interface change of InputMethodManager::Observer. Make the class testable by adding some setters and getters. Remove STATE_LOGGING_IN. Since preferences.cc is fixed in #5 of the series of patches, the intermediate state is no longer needed. chrome/browser/chromeos/input_method/browser_state_monitor_unittest.cc: Verify if the implementation updates the correct pref file (i.e. Local\ State or Preferences depending on the browser state). chrome/browser/chromeos/input_method/ibus_controller.h: Simplify the IBusController::Observer interface. Add Start() which is called when a non-XKB input method is enabled. Rename SetImePropertyActivated() to ActivateInputMethodProperty() and remove the second parameter |is_selection| which is no longer needed. Remove CreateInputMethodDescriptor() as we can simply use a constructor in InputMethodDescriptor. chrome/browser/chromeos/input_method/ibus_controller.cc: Move HAVE_IBUS part to chrome/browser/chromeos/input_method/ibus_controller_impl.cc. Move !HAVE_IBUS part to chrome/browser/chromeos/input_method/mock_ibus_controller.cc. Move some functions which do not depend on libibus to chrome/browser/chromeos/input_method/ibus_controller_base.cc. chrome/browser/chromeos/input_method/ibus_controller_base.h: chrome/browser/chromeos/input_method/ibus_controller_base.cc: chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc: Implement some part of the IBusController interface. Since the files do not depend on libibus, they are unit-testable. chrome/browser/chromeos/input_method/ibus_controller_impl.h: chrome/browser/chromeos/input_method/ibus_controller_impl.cc: Implement libibus dependent part of the IBusController interface. Moved ibus-daemon startup and shutdown code from input_method_manager.cc. Most of other part are unchanged. chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc: Tests FindAndUpdateProperty() function in ibus_controller_impl.cc since the function does not use libibus structues/functions. Other functions in ibus_controller_impl.cc will become unit testable soon once crosbug.com/26334 is fixed (by nona@c). chrome/browser/chromeos/input_method/input_method_engine.cc: Follow InputMethodManager interface changes. chrome/browser/chromeos/input_method/input_method_manager.h: Simplify InputMethodManager::Observer interface. Add EnableInputMethods(). We used to set an ibus-daemon config called "preload_engines" to enable input methods, but it is difficult to understand. In addition to the readability problem, the "preload_engines" config has been removed from ibus-1.5. On the daemon side, what we have to do to switch the current input method is just to call ibus_bus_set_global_engine("engine-name") without calling ibus_config_set_value("preload_engiens", ...). So enabling engines by calling SetInputMethodConfig() does not make sense at all now. Rename AddActiveIme() to AddInputMethodExtension(). Do the same for RemoveActiveIme(). Move StartInputMethodDaemon() and StopInputMethodDaemon() to IBusControllerImpl. This should be done automatically in the libibus layer. Add Initialize() and Shutdown() to stop initializing the instance as a singleton. chrome/browser/chromeos/input_method/input_method_manager.cc: Move to input_method_manager_impl.cc. chrome/browser/chromeos/input_method/input_method_manager_impl.h: chrome/browser/chromeos/input_method/input_method_manager_impl.cc: The manager implementation. Fully tested. chrome/browser/chromeos/input_method/input_method_manager_browsertest.cc: chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc: Rename input_method_manager_browsertest.cc to input_method_manager_impl_unittest.cc. Added bunch of unit tests that tests all methods in the manager implementation. chrome/browser/chromeos/login/login_utils_browsertest.cc: chrome/browser/ui/webui/options2/language_options_handler2_unittest.cc: Initialize() and Shutdown() the input method manager instance. chrome/browser/chromeos/login/screen_locker.cc: Move code for changing the set of enabled input methods on lock/unlock to input_method_manager_impl.cc. chrome/browser/chromeos/preferences_unittest.cc: Add a unit test which checks if the correct input method is set as a default one on signing in. Note that the CL compiles and works correctly only with app-i18n/ibus >= 1.4.99. BUG=chromium-os:19655 TEST=try Review URL: https://chromiumcodereview.appspot.com/9999018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system')
-rw-r--r--ash/system/ime/tray_ime.cc11
-rw-r--r--ash/system/tray/system_tray.cc3
-rw-r--r--ash/system/tray/system_tray_delegate.h7
3 files changed, 8 insertions, 13 deletions
diff --git a/ash/system/ime/tray_ime.cc b/ash/system/ime/tray_ime.cc
index 29aa9c0..8f3588e9 100644
--- a/ash/system/ime/tray_ime.cc
+++ b/ash/system/ime/tray_ime.cc
@@ -4,7 +4,6 @@
#include "ash/system/ime/tray_ime.h"
-#include <utility>
#include <vector>
#include "ash/shell.h"
@@ -123,7 +122,7 @@ class IMEDetailedView : public views::View,
property_list[i].name,
property_list[i].selected ? gfx::Font::BOLD : gfx::Font::NORMAL);
properties->AddChildView(container);
- property_map_[container] = property_list[i];
+ property_map_[container] = property_list[i].key;
}
properties->set_border(views::Border::CreateSolidSidedBorder(
0, 0, 1, 0, kBorderLightColor));
@@ -154,11 +153,11 @@ class IMEDetailedView : public views::View,
delegate->SwitchIME(ime_id);
GetWidget()->Close();
} else {
- std::map<views::View*, IMEPropertyInfo>::const_iterator prop_find;
+ std::map<views::View*, std::string>::const_iterator prop_find;
prop_find = property_map_.find(sender);
if (prop_find != property_map_.end()) {
- const IMEPropertyInfo& prop = prop_find->second;
- delegate->ActivateIMEProperty(prop.key, prop.is_selection);
+ const std::string key = prop_find->second;
+ delegate->ActivateIMEProperty(key);
GetWidget()->Close();
}
}
@@ -168,7 +167,7 @@ class IMEDetailedView : public views::View,
user::LoginStatus login_;
std::map<views::View*, std::string> ime_map_;
- std::map<views::View*, IMEPropertyInfo> property_map_;
+ std::map<views::View*, std::string> property_map_;
views::View* header_;
views::View* settings_;
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 478f418..578562d 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -436,8 +436,7 @@ IMEInfo::~IMEInfo() {
}
IMEPropertyInfo::IMEPropertyInfo()
- : selected(false),
- is_selection(false) {
+ : selected(false) {
}
IMEPropertyInfo::~IMEPropertyInfo() {
diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h
index 382c7ec..c399296 100644
--- a/ash/system/tray/system_tray_delegate.h
+++ b/ash/system/tray/system_tray_delegate.h
@@ -48,7 +48,6 @@ struct ASH_EXPORT IMEPropertyInfo {
~IMEPropertyInfo();
bool selected;
- bool is_selection;
std::string key;
string16 name;
};
@@ -161,10 +160,8 @@ class SystemTrayDelegate {
// Switches to the selected input method.
virtual void SwitchIME(const std::string& ime_id) = 0;
- // Activates an IME property. Specify true to |is_selection| if it's a
- // selection item.
- virtual void ActivateIMEProperty(
- const std::string& key, bool is_selection) = 0;
+ // Activates an IME property.
+ virtual void ActivateIMEProperty(const std::string& key) = 0;
// Returns information about the most relevant network. Relevance is
// determined by the implementor (e.g. a connecting network may be more