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 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_INPUT_METHOD_MENU_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_INPUT_METHOD_MENU_H_ |
6 #define CHROME_BROWSER_CHROMEOS_STATUS_INPUT_METHOD_MENU_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_INPUT_METHOD_MENU_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 12 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
13 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" | |
14 #include "chrome/browser/prefs/pref_member.h" | 13 #include "chrome/browser/prefs/pref_member.h" |
15 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
16 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
17 #include "content/public/browser/notification_types.h" | 16 #include "content/public/browser/notification_types.h" |
18 #include "ui/base/models/menu_model.h" | 17 #include "ui/base/models/menu_model.h" |
19 #include "views/controls/menu/menu_item_view.h" | 18 #include "views/controls/menu/menu_item_view.h" |
20 #include "views/controls/menu/view_menu_delegate.h" | 19 #include "views/controls/menu/view_menu_delegate.h" |
21 | 20 |
22 class PrefService; | 21 class PrefService; |
23 class SkBitmap; | 22 class SkBitmap; |
(...skipping 15 matching lines...) Expand all Loading... |
39 // create a button widget (e.g. views::MenuButton, StatusAreaButton) | 38 // create a button widget (e.g. views::MenuButton, StatusAreaButton) |
40 // which shows the dropdown menu on click. | 39 // which shows the dropdown menu on click. |
41 class InputMethodMenu | 40 class InputMethodMenu |
42 : public views::ViewMenuDelegate, | 41 : public views::ViewMenuDelegate, |
43 public ui::MenuModel, | 42 public ui::MenuModel, |
44 public input_method::InputMethodManager::Observer, | 43 public input_method::InputMethodManager::Observer, |
45 public input_method::InputMethodManager::PreferenceObserver, | 44 public input_method::InputMethodManager::PreferenceObserver, |
46 public content::NotificationObserver { | 45 public content::NotificationObserver { |
47 public: | 46 public: |
48 InputMethodMenu(PrefService* pref_service, | 47 InputMethodMenu(PrefService* pref_service, |
49 StatusAreaViewChromeos::ScreenMode screen_mode, | |
50 bool for_out_of_box_experience_dialog); | 48 bool for_out_of_box_experience_dialog); |
51 virtual ~InputMethodMenu(); | 49 virtual ~InputMethodMenu(); |
52 | 50 |
53 // ui::MenuModel implementation. | 51 // ui::MenuModel implementation. |
54 virtual bool HasIcons() const OVERRIDE; | 52 virtual bool HasIcons() const OVERRIDE; |
55 virtual int GetItemCount() const OVERRIDE; | 53 virtual int GetItemCount() const OVERRIDE; |
56 virtual ui::MenuModel::ItemType GetTypeAt(int index) const OVERRIDE; | 54 virtual ui::MenuModel::ItemType GetTypeAt(int index) const OVERRIDE; |
57 virtual int GetCommandIdAt(int index) const OVERRIDE; | 55 virtual int GetCommandIdAt(int index) const OVERRIDE; |
58 virtual string16 GetLabelAt(int index) const OVERRIDE; | 56 virtual string16 GetLabelAt(int index) const OVERRIDE; |
59 virtual bool IsItemDynamicAt(int index) const OVERRIDE; | 57 virtual bool IsItemDynamicAt(int index) const OVERRIDE; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // property_list.at(property_index) points to the menu item. | 162 // property_list.at(property_index) points to the menu item. |
165 bool GetPropertyIndex(int index, int* property_index) const; | 163 bool GetPropertyIndex(int index, int* property_index) const; |
166 | 164 |
167 // Returns true if the zero-origin |index| points to the "Configure IME" menu | 165 // Returns true if the zero-origin |index| points to the "Configure IME" menu |
168 // item. | 166 // item. |
169 bool IndexPointsToConfigureImeMenuItem(int index) const; | 167 bool IndexPointsToConfigureImeMenuItem(int index) const; |
170 | 168 |
171 // Stops observing InputMethodManager. | 169 // Stops observing InputMethodManager. |
172 void RemoveObservers(); | 170 void RemoveObservers(); |
173 | 171 |
| 172 // Initializes objects for reading/writing Chrome prefs. |
| 173 void InitializePrefMembers(); |
| 174 |
174 // The current input method list. | 175 // The current input method list. |
175 scoped_ptr<input_method::InputMethodDescriptors> input_method_descriptors_; | 176 scoped_ptr<input_method::InputMethodDescriptors> input_method_descriptors_; |
176 | 177 |
177 // Objects for reading/writing the Chrome prefs. | 178 // Objects for reading/writing the Chrome prefs. |
178 StringPrefMember previous_input_method_pref_; | 179 StringPrefMember previous_input_method_pref_; |
179 StringPrefMember current_input_method_pref_; | 180 StringPrefMember current_input_method_pref_; |
180 | 181 |
181 // We borrow ui::SimpleMenuModel implementation to maintain the current | 182 // We borrow ui::SimpleMenuModel implementation to maintain the current |
182 // content of the pop-up menu. The ui::MenuModel is implemented using this | 183 // content of the pop-up menu. The ui::MenuModel is implemented using this |
183 // |model_|. The MenuModelAdapter wraps the model with the | 184 // |model_|. The MenuModelAdapter wraps the model with the |
184 // views::MenuDelegate interface required for MenuItemView. | 185 // views::MenuDelegate interface required for MenuItemView. |
185 scoped_ptr<ui::SimpleMenuModel> model_; | 186 scoped_ptr<ui::SimpleMenuModel> model_; |
186 scoped_ptr<views::MenuModelAdapter> input_method_menu_delegate_; | 187 scoped_ptr<views::MenuModelAdapter> input_method_menu_delegate_; |
187 views::MenuItemView* input_method_menu_; | 188 views::MenuItemView* input_method_menu_; |
188 scoped_ptr<views::MenuRunner> input_method_menu_runner_; | 189 scoped_ptr<views::MenuRunner> input_method_menu_runner_; |
189 | 190 |
190 int minimum_input_method_menu_width_; | 191 int minimum_input_method_menu_width_; |
191 | 192 |
192 // Menu alignment (default TOPRIGHT). | 193 // Menu alignment (default TOPRIGHT). |
193 views::MenuItemView::AnchorPosition menu_alignment_; | 194 views::MenuItemView::AnchorPosition menu_alignment_; |
194 | 195 |
195 PrefService* pref_service_; | 196 PrefService* pref_service_; |
196 content::NotificationRegistrar registrar_; | 197 content::NotificationRegistrar registrar_; |
197 | 198 |
198 // The mode of the host screen (e.g. browser, screen locker, login screen.) | |
199 const StatusAreaViewChromeos::ScreenMode screen_mode_; | |
200 // true if the menu is for a dialog in OOBE screen. In the dialog, we don't | 199 // true if the menu is for a dialog in OOBE screen. In the dialog, we don't |
201 // use radio buttons. | 200 // use radio buttons. |
202 const bool for_out_of_box_experience_dialog_; | 201 const bool for_out_of_box_experience_dialog_; |
203 | 202 |
204 DISALLOW_COPY_AND_ASSIGN(InputMethodMenu); | 203 DISALLOW_COPY_AND_ASSIGN(InputMethodMenu); |
205 }; | 204 }; |
206 | 205 |
207 } // namespace chromeos | 206 } // namespace chromeos |
208 | 207 |
209 #endif // CHROME_BROWSER_CHROMEOS_STATUS_INPUT_METHOD_MENU_H_ | 208 #endif // CHROME_BROWSER_CHROMEOS_STATUS_INPUT_METHOD_MENU_H_ |
OLD | NEW |