Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: chrome/browser/chromeos/status/input_method_menu_button.cc

Issue 6262012: Remove multiple inheritance from input_method_menu_button.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/status/input_method_menu_button.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « chrome/browser/chromeos/status/input_method_menu_button.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698