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_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_DROPDOWN_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_DROPDOWN_H_ 7 8 #include "ash/system/chromeos/network/network_icon_animation_observer.h" 9 #include "base/basictypes.h" 10 #include "base/timer/timer.h" 11 #include "chrome/browser/chromeos/status/network_menu.h" 12 #include "chromeos/network/network_state_handler_observer.h" 13 #include "ui/gfx/native_widget_types.h" 14 15 namespace content { 16 class WebUI; 17 } 18 19 namespace chromeos { 20 21 class NetworkMenuWebUI; 22 class NetworkState; 23 24 // Class which implements network dropdown menu using WebUI. 25 class NetworkDropdown : public NetworkMenu::Delegate, 26 public NetworkStateHandlerObserver, 27 public ash::network_icon::AnimationObserver { 28 public: 29 class Actor { 30 public: 31 virtual ~Actor() {} 32 virtual void OnConnectToNetworkRequested( 33 const std::string& service_path) = 0; 34 }; 35 36 NetworkDropdown(Actor* actor, content::WebUI* web_ui, bool oobe); 37 virtual ~NetworkDropdown(); 38 39 // This method should be called, when item with the given id is chosen. 40 void OnItemChosen(int id); 41 42 // NetworkMenu::Delegate 43 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; 44 virtual void OpenButtonOptions() OVERRIDE; 45 virtual bool ShouldOpenButtonOptions() const OVERRIDE; 46 virtual void OnConnectToNetworkRequested( 47 const std::string& service_path) OVERRIDE; 48 49 // NetworkStateHandlerObserver 50 virtual void DefaultNetworkChanged(const NetworkState* network) OVERRIDE; 51 virtual void NetworkConnectionStateChanged( 52 const NetworkState* network) OVERRIDE; 53 virtual void NetworkListChanged() OVERRIDE; 54 55 // network_icon::AnimationObserver 56 virtual void NetworkIconChanged() OVERRIDE; 57 58 // Refreshes control state. Usually there's no need to do it manually 59 // as control refreshes itself on network state change. 60 // Should be called on language change. 61 void Refresh(); 62 63 private: 64 void SetNetworkIconAndText(); 65 66 // Request a network scan and refreshes control state. Should be called 67 // by |network_scan_timer_| only. 68 void RequestNetworkScan(); 69 70 // The Network menu. 71 scoped_ptr<NetworkMenuWebUI> network_menu_; 72 73 Actor* actor_; 74 75 content::WebUI* web_ui_; 76 77 // Is the dropdown shown on one of the OOBE screens. 78 bool oobe_; 79 80 // Timer used to periodically force network scan. 81 base::RepeatingTimer<NetworkDropdown> network_scan_timer_; 82 83 DISALLOW_COPY_AND_ASSIGN(NetworkDropdown); 84 }; 85 86 } // namespace chromeos 87 88 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_DROPDOWN_H_ 89