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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "ui/views/controls/button/menu_button_delegate.h" | 13 #include "ui/views/controls/button/menu_button_listener.h" |
14 #include "ui/views/controls/menu/menu_delegate.h" | 14 #include "ui/views/controls/menu/menu_delegate.h" |
15 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
16 | 16 |
17 class WizardControllerTest_SwitchLanguage_Test; | 17 class WizardControllerTest_SwitchLanguage_Test; |
18 | 18 |
19 namespace views { | 19 namespace views { |
20 class MenuItemView; | 20 class MenuItemView; |
21 class MenuRunner; | 21 class MenuRunner; |
22 } // namespace views | 22 } // namespace views |
23 | 23 |
24 namespace chromeos { | 24 namespace chromeos { |
25 | 25 |
26 class LanguageList; | 26 class LanguageList; |
27 | 27 |
28 class LanguageSwitchMenu : public views::MenuButtonDelegate, | 28 class LanguageSwitchMenu : public views::MenuButtonListener, |
29 public views::MenuDelegate { | 29 public views::MenuDelegate { |
30 public: | 30 public: |
31 LanguageSwitchMenu(); | 31 LanguageSwitchMenu(); |
32 virtual ~LanguageSwitchMenu(); | 32 virtual ~LanguageSwitchMenu(); |
33 | 33 |
34 // Initializes language selection menu contents. | 34 // Initializes language selection menu contents. |
35 void InitLanguageMenu(); | 35 void InitLanguageMenu(); |
36 | 36 |
37 // Returns current locale name to be placed on the language menu-button. | 37 // Returns current locale name to be placed on the language menu-button. |
38 string16 GetCurrentLocaleName() const; | 38 string16 GetCurrentLocaleName() const; |
39 | 39 |
40 // Sets the minimum width of the first level menu to be shown. | 40 // Sets the minimum width of the first level menu to be shown. |
41 void SetFirstLevelMenuWidth(int width); | 41 void SetFirstLevelMenuWidth(int width); |
42 | 42 |
43 // Switches the current locale, saves the new locale in preferences. | 43 // Switches the current locale, saves the new locale in preferences. |
44 // Returns true if it has switched the current locale. | 44 // Returns true if it has switched the current locale. |
45 static bool SwitchLanguage(const std::string& locale); | 45 static bool SwitchLanguage(const std::string& locale); |
46 | 46 |
47 // Switches the current locale, saves the new locale in preferences. | 47 // Switches the current locale, saves the new locale in preferences. |
48 // Enables the keyboard layouts associated with the new locale. | 48 // Enables the keyboard layouts associated with the new locale. |
49 static void SwitchLanguageAndEnableKeyboardLayouts( | 49 static void SwitchLanguageAndEnableKeyboardLayouts( |
50 const std::string& locale); | 50 const std::string& locale); |
51 | 51 |
52 private: | 52 private: |
53 static void LoadFontsForCurrentLocale(); | 53 static void LoadFontsForCurrentLocale(); |
54 | 54 |
55 // views::MenuButtonDelegate implementation. | 55 // Overridden from views::MenuButtonListener: |
56 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; | 56 virtual void OnMenuButtonClicked(views::View* source, |
| 57 const gfx::Point& point) OVERRIDE; |
57 | 58 |
58 // views::MenuDelegate implementation. | 59 // Overridden from views::MenuDelegate: |
59 virtual void ExecuteCommand(int command_id) OVERRIDE; | 60 virtual void ExecuteCommand(int command_id) OVERRIDE; |
60 | 61 |
61 // The menu. | 62 // The menu. |
62 views::MenuItemView* menu_; | 63 views::MenuItemView* menu_; |
63 | 64 |
64 // Runs and owns |menu_|. | 65 // Runs and owns |menu_|. |
65 scoped_ptr<views::MenuRunner> menu_runner_; | 66 scoped_ptr<views::MenuRunner> menu_runner_; |
66 | 67 |
67 // Language locale name storage. | 68 // Language locale name storage. |
68 scoped_ptr<LanguageList> language_list_; | 69 scoped_ptr<LanguageList> language_list_; |
69 | 70 |
70 FRIEND_TEST(::WizardControllerTest, SwitchLanguage); | 71 FRIEND_TEST(::WizardControllerTest, SwitchLanguage); |
71 DISALLOW_COPY_AND_ASSIGN(LanguageSwitchMenu); | 72 DISALLOW_COPY_AND_ASSIGN(LanguageSwitchMenu); |
72 }; | 73 }; |
73 | 74 |
74 } // namespace chromeos | 75 } // namespace chromeos |
75 | 76 |
76 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_ | 77 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_ |
OLD | NEW |