Home | History | Annotate | Download | only in login
      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.
      4 
      5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_
      6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_
      7 
      8 #include <string>
      9 
     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"
     15 
     16 class WizardControllerTest_SwitchLanguage_Test;
     17 
     18 namespace views {
     19 class MenuItemView;
     20 class MenuRunner;
     21 }  // namespace views
     22 
     23 namespace chromeos {
     24 
     25 class LanguageList;
     26 
     27 class LanguageSwitchMenu : public views::MenuButtonListener,
     28                            public views::MenuDelegate {
     29  public:
     30   LanguageSwitchMenu();
     31   virtual ~LanguageSwitchMenu();
     32 
     33   // Initializes language selection menu contents.
     34   void InitLanguageMenu();
     35 
     36   // Returns current locale name to be placed on the language menu-button.
     37   string16 GetCurrentLocaleName() const;
     38 
     39   // Sets the minimum width of the first level menu to be shown.
     40   void SetFirstLevelMenuWidth(int width);
     41 
     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);
     45 
     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);
     50 
     51   static void LoadFontsForCurrentLocale();
     52 
     53  private:
     54   // Overridden from views::MenuButtonListener:
     55   virtual void OnMenuButtonClicked(views::View* source,
     56                                    const gfx::Point& point) OVERRIDE;
     57 
     58   // Overridden from views::MenuDelegate:
     59   virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
     60 
     61   // The menu.
     62   views::MenuItemView* menu_;
     63 
     64   // Runs and owns |menu_|.
     65   scoped_ptr<views::MenuRunner> menu_runner_;
     66 
     67   // Language locale name storage.
     68   scoped_ptr<LanguageList> language_list_;
     69 
     70   FRIEND_TEST(::WizardControllerTest, SwitchLanguage);
     71   DISALLOW_COPY_AND_ASSIGN(LanguageSwitchMenu);
     72 };
     73 
     74 }  // namespace chromeos
     75 
     76 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_SWITCH_MENU_H_
     77