| Index: chrome/browser/chromeos/status/input_method_menu_button.cc
|
| diff --git a/chrome/browser/chromeos/status/input_method_menu_button.cc b/chrome/browser/chromeos/status/input_method_menu_button.cc
|
| index ff4db965406f2640994a6c7e84752b160830f935..1767b49f62a047abc2a33c6487caf28ee46af127 100644
|
| --- a/chrome/browser/chromeos/status/input_method_menu_button.cc
|
| +++ b/chrome/browser/chromeos/status/input_method_menu_button.cc
|
| @@ -32,6 +32,35 @@ const int kFontSizeDelta = 0;
|
| const int kFontSizeDelta = 1;
|
| #endif
|
|
|
| +// A class which implements interfaces of chromeos::InputMethodMenu. This class
|
| +// is just for avoiding multiple inheritance.
|
| +class MenuImpl : public chromeos::InputMethodMenu {
|
| + public:
|
| + MenuImpl(chromeos::InputMethodMenuButton* button,
|
| + PrefService* pref_service,
|
| + chromeos::StatusAreaHost::ScreenMode screen_mode)
|
| + : InputMethodMenu(pref_service, screen_mode, false), button_(button) {}
|
| +
|
| + private:
|
| + // InputMethodMenu implementation.
|
| + virtual void UpdateUI(const std::string& input_method_id,
|
| + const std::wstring& name,
|
| + const std::wstring& tooltip,
|
| + size_t num_active_input_methods) {
|
| + button_->UpdateUI(input_method_id, name, tooltip, num_active_input_methods);
|
| + }
|
| + virtual bool ShouldSupportConfigUI() {
|
| + return button_->ShouldSupportConfigUI();
|
| + }
|
| + virtual void OpenConfigUI() {
|
| + button_->OpenConfigUI();
|
| + }
|
| + // The UI (views button) to which this class delegates all requests.
|
| + chromeos::InputMethodMenuButton* button_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MenuImpl);
|
| +};
|
| +
|
| } // namespace
|
|
|
| namespace chromeos {
|
| @@ -41,9 +70,7 @@ namespace chromeos {
|
|
|
| InputMethodMenuButton::InputMethodMenuButton(StatusAreaHost* host)
|
| : StatusAreaButton(this),
|
| - InputMethodMenu(GetPrefService(host),
|
| - host->GetScreenMode(),
|
| - false /* for_out_of_box_experience_dialog */),
|
| + menu_(new MenuImpl(this, GetPrefService(host), host->GetScreenMode())),
|
| host_(host) {
|
| set_border(NULL);
|
| set_use_menu_button_paint(true);
|
| @@ -63,7 +90,7 @@ InputMethodMenuButton::InputMethodMenuButton(StatusAreaHost* host)
|
| // |pref_service| is not available (for example, unit tests) or |pref_service|
|
| // is available, but Chrome preferences are not available (for example,
|
| // initial OS boot).
|
| - InputMethodMenuButton::UpdateUI(hardware_keyboard_id, L"US", L"", 1);
|
| + UpdateUI(hardware_keyboard_id, L"US", L"", 1);
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -84,6 +111,8 @@ void InputMethodMenuButton::OnLocaleChanged() {
|
| chromeos::CrosLibrary::Get()->GetInputMethodLibrary();
|
| const InputMethodDescriptor& input_method =
|
| input_method_library->current_input_method();
|
| + const std::wstring name = InputMethodMenu::GetTextForIndicator(input_method);
|
| + const std::wstring tooltip = InputMethodMenu::GetTextForMenu(input_method);
|
|
|
| // In general, we should not call an input method API in the input method
|
| // button classes (status/input_menu_button*.cc) for performance reasons (see
|
| @@ -92,14 +121,19 @@ void InputMethodMenuButton::OnLocaleChanged() {
|
| // to call GetNumActiveInputMethods here.
|
| const size_t num_active_input_methods =
|
| input_method_library->GetNumActiveInputMethods();
|
| + UpdateUI(input_method.id, name, tooltip, num_active_input_methods);
|
|
|
| - UpdateUIFromInputMethod(input_method, num_active_input_methods);
|
| Layout();
|
| SchedulePaint();
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// InputMethodMenu::InputMethodMenuHost implementation:
|
| +// views::ViewMenuDelegate implementation:
|
| +
|
| +void InputMethodMenuButton::RunMenu(views::View* unused_source,
|
| + const gfx::Point& pt) {
|
| + menu_->RunMenu(unused_source, pt);
|
| +}
|
|
|
| void InputMethodMenuButton::UpdateUI(const std::string& input_method_id,
|
| const std::wstring& name,
|
|
|