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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/views/controls/button/menu_button_listener.h"
13 #include "ui/views/controls/menu/menu_delegate.h"
14 #include "ui/views/view.h"
16 class WizardControllerTest_SwitchLanguage_Test;
27 class LanguageSwitchMenu : public views::MenuButtonListener,
28 public views::MenuDelegate {
31 virtual ~LanguageSwitchMenu();
33 // Initializes language selection menu contents.
34 void InitLanguageMenu();
36 // Returns current locale name to be placed on the language menu-button.
37 string16 GetCurrentLocaleName() const;
39 // Sets the minimum width of the first level menu to be shown.
40 void SetFirstLevelMenuWidth(int width);
42 // Switches the current locale, saves the new locale in preferences.
43 // Returns true if it has switched the current locale.
44 static bool SwitchLanguage(const std::string& locale);
46 // Switches the current locale, saves the new locale in preferences.
47 // Enables the keyboard layouts associated with the new locale.
48 static void SwitchLanguageAndEnableKeyboardLayouts(
49 const std::string& locale);
51 static void LoadFontsForCurrentLocale();
54 // Overridden from views::MenuButtonListener:
55 virtual void OnMenuButtonClicked(views::View* source,
56 const gfx::Point& point) OVERRIDE;
58 // Overridden from views::MenuDelegate:
59 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
62 views::MenuItemView* menu_;
64 // Runs and owns |menu_|.
65 scoped_ptr<views::MenuRunner> menu_runner_;
67 // Language locale name storage.
68 scoped_ptr<LanguageList> language_list_;
70 FRIEND_TEST(::WizardControllerTest, SwitchLanguage);
71 DISALLOW_COPY_AND_ASSIGN(LanguageSwitchMenu);
74 } // namespace chromeos
76 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_