| 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 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | 5 #include "chrome/browser/chromeos/status/input_method_menu_button.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 SetTooltipText(L""); // remove tooltip | 130 SetTooltipText(L""); // remove tooltip |
| 131 } else { | 131 } else { |
| 132 SetEnabled(true); | 132 SetEnabled(true); |
| 133 SetTooltipText(tooltip); | 133 SetTooltipText(tooltip); |
| 134 } | 134 } |
| 135 SetText(name); | 135 SetText(name); |
| 136 | 136 |
| 137 if (WindowIsActive()) { | 137 if (WindowIsActive()) { |
| 138 // We don't call these functions if the |current_window| is not active since | 138 // We don't call these functions if the |current_window| is not active since |
| 139 // the calls are relatively expensive (crosbug.com/9206). Please note that | 139 // the calls are relatively expensive (crosbug.com/9206). Please note that |
| 140 // PrepareMenu() is necessary for fixing crosbug.com/7522 when the window | 140 // PrepareMenuModel() is necessary for fixing crosbug.com/7522 when the |
| 141 // is active. | 141 // window is active. |
| 142 menu_->PrepareMenu(); | 142 menu_->PrepareMenuModel(); |
| 143 SchedulePaint(); | 143 SchedulePaint(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 // TODO(yusukes): For a window which isn't on top, probably it's better to | 146 // TODO(yusukes): For a window which isn't on top, probably it's better to |
| 147 // update the texts when the window gets activated because SetTooltipText() | 147 // update the texts when the window gets activated because SetTooltipText() |
| 148 // and SetText() are also expensive. | 148 // and SetText() are also expensive. |
| 149 } | 149 } |
| 150 | 150 |
| 151 void InputMethodMenuButton::OpenConfigUI() { | 151 void InputMethodMenuButton::OpenConfigUI() { |
| 152 host_->OpenButtonOptions(this); // ask browser to open the WebUI page. | 152 host_->OpenButtonOptions(this); // ask browser to open the WebUI page. |
| 153 } | 153 } |
| 154 | 154 |
| 155 bool InputMethodMenuButton::ShouldSupportConfigUI() { | 155 bool InputMethodMenuButton::ShouldSupportConfigUI() { |
| 156 return host_->ShouldOpenButtonOptions(this); | 156 return host_->ShouldOpenButtonOptions(this); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void InputMethodMenuButton::UpdateUIFromCurrentInputMethod() { | 159 void InputMethodMenuButton::UpdateUIFromCurrentInputMethod() { |
| 160 chromeos::InputMethodLibrary* input_method_library = | 160 chromeos::InputMethodLibrary* input_method_library = |
| 161 chromeos::CrosLibrary::Get()->GetInputMethodLibrary(); | 161 chromeos::CrosLibrary::Get()->GetInputMethodLibrary(); |
| 162 const InputMethodDescriptor& input_method = | 162 const InputMethodDescriptor& input_method = |
| 163 input_method_library->current_input_method(); | 163 input_method_library->current_input_method(); |
| 164 const std::wstring name = InputMethodMenu::GetTextForIndicator(input_method); | 164 const std::wstring name = InputMethodMenu::GetTextForIndicator(input_method); |
| 165 const std::wstring tooltip = InputMethodMenu::GetTextForMenu(input_method); | 165 const std::wstring tooltip = InputMethodMenu::GetTextForMenu(input_method); |
| 166 const size_t num_active_input_methods = | 166 const size_t num_active_input_methods = |
| 167 input_method_library->GetNumActiveInputMethods(); | 167 input_method_library->GetNumActiveInputMethods(); |
| 168 UpdateUI(input_method.id, name, tooltip, num_active_input_methods); | 168 UpdateUI(input_method.id, name, tooltip, num_active_input_methods); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace chromeos | 171 } // namespace chromeos |
| OLD | NEW |