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_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_DROPDOWN_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_DROPDOWN_H_
8 #include "base/basictypes.h"
9 #include "base/timer/timer.h"
10 #include "chrome/browser/chromeos/status/network_menu.h"
11 #include "chromeos/network/network_state_handler_observer.h"
12 #include "ui/chromeos/network/network_icon_animation_observer.h"
13 #include "ui/gfx/native_widget_types.h"
21 class NetworkMenuWebUI
;
24 // Class which implements network dropdown menu using WebUI.
25 class NetworkDropdown
: public NetworkMenu::Delegate
,
26 public NetworkStateHandlerObserver
,
27 public ui::network_icon::AnimationObserver
{
32 virtual void OnConnectToNetworkRequested() = 0;
35 NetworkDropdown(Actor
* actor
, content::WebUI
* web_ui
, bool oobe
);
36 ~NetworkDropdown() override
;
38 // This method should be called, when item with the given id is chosen.
39 void OnItemChosen(int id
);
41 // NetworkMenu::Delegate
42 gfx::NativeWindow
GetNativeWindow() const override
;
43 void OpenButtonOptions() override
;
44 bool ShouldOpenButtonOptions() const override
;
45 void OnConnectToNetworkRequested() override
;
47 // NetworkStateHandlerObserver
48 void DefaultNetworkChanged(const NetworkState
* network
) override
;
49 void NetworkConnectionStateChanged(const NetworkState
* network
) override
;
50 void NetworkListChanged() override
;
52 // network_icon::AnimationObserver
53 void NetworkIconChanged() override
;
55 // Refreshes control state. Usually there's no need to do it manually
56 // as control refreshes itself on network state change.
57 // Should be called on language change.
61 void SetNetworkIconAndText();
63 // Request a network scan and refreshes control state. Should be called
64 // by |network_scan_timer_| only.
65 void RequestNetworkScan();
68 scoped_ptr
<NetworkMenuWebUI
> network_menu_
;
72 content::WebUI
* web_ui_
;
74 // Is the dropdown shown on one of the OOBE screens.
77 // Timer used to periodically force network scan.
78 base::RepeatingTimer
<NetworkDropdown
> network_scan_timer_
;
80 DISALLOW_COPY_AND_ASSIGN(NetworkDropdown
);
83 } // namespace chromeos
85 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_DROPDOWN_H_