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