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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_INPUT_METHOD_MENU_BUTTON_H_ 6 #define CHROME_BROWSER_CHROMEOS_STATUS_INPUT_METHOD_MENU_BUTTON_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "chrome/browser/chromeos/status/input_method_menu.h" 12 #include "chrome/browser/chromeos/status/status_area_button.h" 13 #include "views/controls/menu/view_menu_delegate.h" 14 15 namespace chromeos { 16 17 class StatusAreaHost; 18 19 // A class for the button in the status area which expands the dropdown menu for 20 // switching input method and keyboard layout. 21 class InputMethodMenuButton : public StatusAreaButton, 22 public views::ViewMenuDelegate { 23 public: 24 explicit InputMethodMenuButton(StatusAreaHost* host); ~InputMethodMenuButton()25 virtual ~InputMethodMenuButton() {} 26 27 // views::View implementation. 28 virtual gfx::Size GetPreferredSize(); 29 virtual void OnLocaleChanged(); 30 31 // views::ViewMenuDelegate implementation. 32 virtual void RunMenu(views::View* unused_source, const gfx::Point& pt); 33 34 // InputMethodMenu implementation. 35 virtual void UpdateUI(const std::string& input_method_id, 36 const std::wstring& name, 37 const std::wstring& tooltip, 38 size_t num_active_input_methods); 39 virtual bool ShouldSupportConfigUI(); 40 virtual void OpenConfigUI(); 41 42 // Updates the UI from the current input method. 43 void UpdateUIFromCurrentInputMethod(); 44 45 private: 46 // Returns true if the Chrome window where the button lives is active. 47 bool WindowIsActive(); 48 49 scoped_ptr<InputMethodMenu> menu_; 50 51 DISALLOW_COPY_AND_ASSIGN(InputMethodMenuButton); 52 }; 53 54 } // namespace chromeos 55 56 #endif // CHROME_BROWSER_CHROMEOS_STATUS_INPUT_METHOD_MENU_BUTTON_H_ 57