Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / login / network_dropdown.h
blob56b6ec9d13961457e0045d608b2e2eb3887d562e
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 "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"
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 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;
36 NetworkDropdown(Actor* actor, content::WebUI* web_ui, bool oobe);
37 virtual ~NetworkDropdown();
39 // This method should be called, when item with the given id is chosen.
40 void OnItemChosen(int id);
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;
49 // NetworkStateHandlerObserver
50 virtual void DefaultNetworkChanged(const NetworkState* network) OVERRIDE;
51 virtual void NetworkConnectionStateChanged(
52 const NetworkState* network) OVERRIDE;
53 virtual void NetworkListChanged() OVERRIDE;
55 // network_icon::AnimationObserver
56 virtual void NetworkIconChanged() OVERRIDE;
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();
63 private:
64 void SetNetworkIconAndText();
66 // Request a network scan and refreshes control state. Should be called
67 // by |network_scan_timer_| only.
68 void RequestNetworkScan();
70 // The Network menu.
71 scoped_ptr<NetworkMenuWebUI> network_menu_;
73 Actor* actor_;
75 content::WebUI* web_ui_;
77 // Is the dropdown shown on one of the OOBE screens.
78 bool oobe_;
80 // Timer used to periodically force network scan.
81 base::RepeatingTimer<NetworkDropdown> network_scan_timer_;
83 DISALLOW_COPY_AND_ASSIGN(NetworkDropdown);
86 } // namespace chromeos
88 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_DROPDOWN_H_