| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_LANGUAGE_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_LANGUAGE_MENU_BUTTON_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_STATUS_LANGUAGE_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_LANGUAGE_MENU_BUTTON_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/menus/simple_menu_model.h" | 9 #include "app/menus/simple_menu_model.h" |
| 10 #include "chrome/browser/chromeos/cros/input_method_library.h" | 10 #include "chrome/browser/chromeos/cros/input_method_library.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const NotificationSource& source, | 63 const NotificationSource& source, |
| 64 const NotificationDetails& details); | 64 const NotificationDetails& details); |
| 65 | 65 |
| 66 // Converts an InputMethodDescriptor object into human readable string. | 66 // Converts an InputMethodDescriptor object into human readable string. |
| 67 // Returns a text for the indicator on top right corner of the Chrome window. | 67 // Returns a text for the indicator on top right corner of the Chrome window. |
| 68 static std::wstring GetTextForIndicator( | 68 static std::wstring GetTextForIndicator( |
| 69 const InputMethodDescriptor& input_method); | 69 const InputMethodDescriptor& input_method); |
| 70 | 70 |
| 71 // Converts an InputMethodDescriptor object into human readable string. | 71 // Converts an InputMethodDescriptor object into human readable string. |
| 72 // Returns a string for the drop-down menu and the tooltip for the indicator. | 72 // Returns a string for the drop-down menu and the tooltip for the indicator. |
| 73 static std::wstring GetTextForMenu( | 73 static std::wstring GetTextForMenu(const InputMethodDescriptor& input_method); |
| 74 const InputMethodDescriptor& input_method, bool add_method_name); | |
| 75 | 74 |
| 76 // Registers input method preferences for the login screen. | 75 // Registers input method preferences for the login screen. |
| 77 static void RegisterPrefs(PrefService* local_state); | 76 static void RegisterPrefs(PrefService* local_state); |
| 78 | 77 |
| 79 // Gets the language codes that are ambiguous if we only show the | |
| 80 // language names in the menu. For these languages, we'll show the input | |
| 81 // method names in addition to the language names. The original contents | |
| 82 // of |ambiguous_language_code_set| are lost. | |
| 83 static void GetAmbiguousLanguageCodeSet( | |
| 84 const InputMethodDescriptors& input_method_descriptors, | |
| 85 std::set<std::string>* ambiguous_language_code_set); | |
| 86 | |
| 87 protected: | 78 protected: |
| 88 // views::View implementation. | 79 // views::View implementation. |
| 89 virtual void OnLocaleChanged(); | 80 virtual void OnLocaleChanged(); |
| 90 | 81 |
| 91 private: | 82 private: |
| 92 // views::ViewMenuDelegate implementation. | 83 // views::ViewMenuDelegate implementation. |
| 93 virtual void RunMenu(views::View* source, const gfx::Point& pt); | 84 virtual void RunMenu(views::View* source, const gfx::Point& pt); |
| 94 | 85 |
| 95 // Updates the status area with |name| and tooltip with |tooltip|. | 86 // Updates the status area with |name| and tooltip with |tooltip|. |
| 96 void UpdateIndicator(const std::wstring& name, const std::wstring& tooltip); | 87 void UpdateIndicator(const std::wstring& name, const std::wstring& tooltip); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 116 // item. | 107 // item. |
| 117 bool IndexPointsToConfigureImeMenuItem(int index) const; | 108 bool IndexPointsToConfigureImeMenuItem(int index) const; |
| 118 | 109 |
| 119 // The current input method list. | 110 // The current input method list. |
| 120 scoped_ptr<InputMethodDescriptors> input_method_descriptors_; | 111 scoped_ptr<InputMethodDescriptors> input_method_descriptors_; |
| 121 | 112 |
| 122 // Objects for reading/writing the Chrome prefs. | 113 // Objects for reading/writing the Chrome prefs. |
| 123 StringPrefMember previous_input_method_pref_; | 114 StringPrefMember previous_input_method_pref_; |
| 124 StringPrefMember current_input_method_pref_; | 115 StringPrefMember current_input_method_pref_; |
| 125 | 116 |
| 126 // Language codes that can be ambiguous. See comments at | |
| 127 // GetAmbiguousLanguageCodeSet() for details. | |
| 128 std::set<std::string> ambiguous_language_code_set_; | |
| 129 | |
| 130 // We borrow menus::SimpleMenuModel implementation to maintain the current | 117 // We borrow menus::SimpleMenuModel implementation to maintain the current |
| 131 // content of the pop-up menu. The menus::MenuModel is implemented using this | 118 // content of the pop-up menu. The menus::MenuModel is implemented using this |
| 132 // |model_|. | 119 // |model_|. |
| 133 scoped_ptr<menus::SimpleMenuModel> model_; | 120 scoped_ptr<menus::SimpleMenuModel> model_; |
| 134 | 121 |
| 135 // The language menu which pops up when the button in status area is clicked. | 122 // The language menu which pops up when the button in status area is clicked. |
| 136 views::Menu2 language_menu_; | 123 views::Menu2 language_menu_; |
| 137 | 124 |
| 138 StatusAreaHost* host_; | 125 StatusAreaHost* host_; |
| 139 NotificationRegistrar registrar_; | 126 NotificationRegistrar registrar_; |
| 140 bool logged_in_; | 127 bool logged_in_; |
| 141 | 128 |
| 142 DISALLOW_COPY_AND_ASSIGN(LanguageMenuButton); | 129 DISALLOW_COPY_AND_ASSIGN(LanguageMenuButton); |
| 143 }; | 130 }; |
| 144 | 131 |
| 145 } // namespace chromeos | 132 } // namespace chromeos |
| 146 | 133 |
| 147 #endif // CHROME_BROWSER_CHROMEOS_STATUS_LANGUAGE_MENU_BUTTON_H_ | 134 #endif // CHROME_BROWSER_CHROMEOS_STATUS_LANGUAGE_MENU_BUTTON_H_ |
| OLD | NEW |