| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/input_method/input_method_manager.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 11 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 11 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 12 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" | 12 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | |
| 14 #include "chrome/browser/profiles/profile_manager.h" | |
| 15 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 19 | 17 |
| 20 namespace { | 18 namespace { |
| 21 | 19 |
| 22 PrefService* GetPrefService() { | |
| 23 Profile* profile = ProfileManager::GetDefaultProfile(); | |
| 24 if (profile) | |
| 25 return profile->GetPrefs(); | |
| 26 return NULL; | |
| 27 } | |
| 28 | |
| 29 // A class which implements interfaces of chromeos::InputMethodMenu. This class | 20 // A class which implements interfaces of chromeos::InputMethodMenu. This class |
| 30 // is just for avoiding multiple inheritance. | 21 // is just for avoiding multiple inheritance. |
| 31 class MenuImpl : public chromeos::InputMethodMenu { | 22 class MenuImpl : public chromeos::InputMethodMenu { |
| 32 public: | 23 public: |
| 33 MenuImpl(chromeos::InputMethodMenuButton* button, | 24 explicit MenuImpl(chromeos::InputMethodMenuButton* button) |
| 34 PrefService* pref_service) | 25 : button_(button) {} |
| 35 : InputMethodMenu(pref_service, false), button_(button) {} | |
| 36 | 26 |
| 37 private: | 27 private: |
| 38 // InputMethodMenu implementation. | 28 // InputMethodMenu implementation. |
| 39 virtual void UpdateUI(const std::string& input_method_id, | 29 virtual void UpdateUI(const std::string& input_method_id, |
| 40 const string16& name, | 30 const string16& name, |
| 41 const string16& tooltip, | 31 const string16& tooltip, |
| 42 size_t num_active_input_methods) { | 32 size_t num_active_input_methods) { |
| 43 button_->UpdateUI(input_method_id, name, tooltip, num_active_input_methods); | 33 button_->UpdateUI(input_method_id, name, tooltip, num_active_input_methods); |
| 44 } | 34 } |
| 45 virtual bool ShouldSupportConfigUI() { | 35 virtual bool ShouldSupportConfigUI() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 } // namespace | 47 } // namespace |
| 58 | 48 |
| 59 namespace chromeos { | 49 namespace chromeos { |
| 60 | 50 |
| 61 //////////////////////////////////////////////////////////////////////////////// | 51 //////////////////////////////////////////////////////////////////////////////// |
| 62 // InputMethodMenuButton | 52 // InputMethodMenuButton |
| 63 | 53 |
| 64 InputMethodMenuButton::InputMethodMenuButton( | 54 InputMethodMenuButton::InputMethodMenuButton( |
| 65 StatusAreaButton::Delegate* delegate) | 55 StatusAreaButton::Delegate* delegate) |
| 66 : StatusAreaButton(delegate, this), | 56 : StatusAreaButton(delegate, this), |
| 67 menu_(new MenuImpl(this, GetPrefService())) { | 57 menu_(new MenuImpl(this)) { |
| 68 set_id(VIEW_ID_STATUS_BUTTON_INPUT_METHOD); | 58 set_id(VIEW_ID_STATUS_BUTTON_INPUT_METHOD); |
| 69 UpdateUIFromCurrentInputMethod(); | 59 UpdateUIFromCurrentInputMethod(); |
| 70 } | 60 } |
| 71 | 61 |
| 72 InputMethodMenuButton::~InputMethodMenuButton() {} | 62 InputMethodMenuButton::~InputMethodMenuButton() {} |
| 73 | 63 |
| 74 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 75 // views::View implementation: | 65 // views::View implementation: |
| 76 | 66 |
| 77 void InputMethodMenuButton::OnLocaleChanged() { | 67 void InputMethodMenuButton::OnLocaleChanged() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 const input_method::InputMethodDescriptor& input_method = | 144 const input_method::InputMethodDescriptor& input_method = |
| 155 input_method_manager->GetCurrentInputMethod(); | 145 input_method_manager->GetCurrentInputMethod(); |
| 156 const string16 name = InputMethodMenu::GetTextForIndicator(input_method); | 146 const string16 name = InputMethodMenu::GetTextForIndicator(input_method); |
| 157 const string16 tooltip = InputMethodMenu::GetTextForMenu(input_method); | 147 const string16 tooltip = InputMethodMenu::GetTextForMenu(input_method); |
| 158 const size_t num_active_input_methods = | 148 const size_t num_active_input_methods = |
| 159 input_method_manager->GetNumActiveInputMethods(); | 149 input_method_manager->GetNumActiveInputMethods(); |
| 160 UpdateUI(input_method.id(), name, tooltip, num_active_input_methods); | 150 UpdateUI(input_method.id(), name, tooltip, num_active_input_methods); |
| 161 } | 151 } |
| 162 | 152 |
| 163 } // namespace chromeos | 153 } // namespace chromeos |
| OLD | NEW |