Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / login / network_dropdown.h
blobe4e60c50d2447554f850e60ad1d2457eee5b2a35
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"
15 namespace content {
16 class WebUI;
19 namespace chromeos {
21 class NetworkMenuWebUI;
22 class NetworkState;
24 // Class which implements network dropdown menu using WebUI.
25 class NetworkDropdown : public NetworkMenu::Delegate,
26 public NetworkStateHandlerObserver,
27 public ui::network_icon::AnimationObserver {
28 public:
29 class Actor {
30 public:
31 virtual ~Actor() {}
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.
58 void Refresh();
60 private:
61 void SetNetworkIconAndText();
63 // Request a network scan and refreshes control state. Should be called
64 // by |network_scan_timer_| only.
65 void RequestNetworkScan();
67 // The Network menu.
68 scoped_ptr<NetworkMenuWebUI> network_menu_;
70 Actor* actor_;
72 content::WebUI* web_ui_;
74 // Is the dropdown shown on one of the OOBE screens.
75 bool oobe_;
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_