Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / options / chromeos / internet_options_handler.h
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_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/ui/webui/options/options_ui.h"
13 #include "chromeos/network/network_state_handler_observer.h"
14 #include "ui/gfx/native_widget_types.h"
15
16 class Browser;
17 class PrefService;
18
19 namespace chromeos {
20 class DeviceState;
21 class NetworkState;
22 class NetworkStateHandlerObserver;
23 }
24
25 namespace gfx {
26 class ImageSkia;
27 }
28
29 namespace views {
30 class WidgetDelegate;
31 }
32
33 namespace chromeos {
34 namespace options {
35
36 // ChromeOS internet options page UI handler.
37 class InternetOptionsHandler
38     : public ::options::OptionsPageUIHandler,
39       public chromeos::NetworkStateHandlerObserver {
40  public:
41   InternetOptionsHandler();
42   virtual ~InternetOptionsHandler();
43
44  private:
45   // OptionsPageUIHandler
46   virtual void GetLocalizedValues(
47       base::DictionaryValue* localized_strings) OVERRIDE;
48   virtual void InitializePage() OVERRIDE;
49
50   // WebUIMessageHandler (from OptionsPageUIHandler)
51   virtual void RegisterMessages() OVERRIDE;
52
53   // Callbacks to set network state properties.
54   void EnableWifiCallback(const base::ListValue* args);
55   void DisableWifiCallback(const base::ListValue* args);
56   void EnableCellularCallback(const base::ListValue* args);
57   void DisableCellularCallback(const base::ListValue* args);
58   void EnableWimaxCallback(const base::ListValue* args);
59   void DisableWimaxCallback(const base::ListValue* args);
60   void ShowMorePlanInfoCallback(const base::ListValue* args);
61   void BuyDataPlanCallback(const base::ListValue* args);
62   void SetApnCallback(const base::ListValue* args);
63   void SetApnProperties(const base::ListValue* args,
64                         const std::string& service_path,
65                         const base::DictionaryValue& shill_properties);
66   void CarrierStatusCallback();
67   void SetCarrierCallback(const base::ListValue* args);
68   void SetSimCardLockCallback(const base::ListValue* args);
69   void ChangePinCallback(const base::ListValue* args);
70   void RefreshNetworksCallback(const base::ListValue* args);
71
72   // Retrieves a data url for a resource.
73   std::string GetIconDataUrl(int resource_id) const;
74
75   // Refreshes the display of network information.
76   void RefreshNetworkData();
77
78   // Updates the display of network connection information for the details page
79   // if visible.
80   void UpdateConnectionData(const std::string& service_path);
81   void UpdateConnectionDataCallback(
82       const std::string& service_path,
83       const base::DictionaryValue& shill_properties);
84   // Called when carrier data has been updated to informs the JS.
85   void UpdateCarrier();
86
87   // NetworkStateHandlerObserver
88   virtual void DeviceListChanged() OVERRIDE;
89   virtual void NetworkListChanged() OVERRIDE;
90   virtual void NetworkConnectionStateChanged(
91       const chromeos::NetworkState* network) OVERRIDE;
92   virtual void NetworkPropertiesUpdated(
93       const chromeos::NetworkState* network) OVERRIDE;
94   virtual void DevicePropertiesUpdated(
95       const chromeos::DeviceState* device) OVERRIDE;
96
97   // Updates the logged in user type.
98   void UpdateLoggedInUserType();
99
100   // Additional callbacks to set network state properties.
101   void SetServerHostnameCallback(const base::ListValue* args);
102   void SetPreferNetworkCallback(const base::ListValue* args);
103   void SetAutoConnectCallback(const base::ListValue* args);
104   void SetIPConfigCallback(const base::ListValue* args);
105   void SetIPConfigProperties(const base::ListValue* args,
106                              const std::string& service_path,
107                              const base::DictionaryValue& shill_properties);
108
109   // Retrieves the properties for |service_path| and calls showDetailedInfo
110   // with the results.
111   void PopulateDictionaryDetailsCallback(
112       const std::string& service_path,
113       const base::DictionaryValue& shill_properties);
114
115   // Gets the native window for hosting dialogs, etc.
116   gfx::NativeWindow GetNativeWindow() const;
117
118   // Gets the UI scale factor.
119   float GetScaleFactor() const;
120
121   // Gets the user PrefService associated with the WebUI.
122   const PrefService* GetPrefs() const;
123
124   // Handle various network commands and clicks on a network item
125   // in the network list.
126   // |args| must be { network_type, service_path, command } with 'command'
127   // one of: [ add, forget, options, connect disconnect, activate ]
128   void NetworkCommandCallback(const base::ListValue* args);
129
130   // Helper functions called by NetworkCommandCallback(...)
131   void AddConnection(const std::string& type);
132
133   // Creates the map of wired networks.
134   base::ListValue* GetWiredList();
135
136   // Creates the map of wireless networks.
137   base::ListValue* GetWirelessList();
138
139   // Creates the map of virtual networks.
140   base::ListValue* GetVPNList();
141
142   // Creates the map of remembered networks.
143   base::ListValue* GetRememberedList();
144
145   // Fills network information into JS dictionary for displaying network lists.
146   void FillNetworkInfo(base::DictionaryValue* dictionary);
147
148   // Keep track of the service path for the network shown in the Details view.
149   std::string details_path_;
150
151   // Weak pointer factory so we can start connections at a later time
152   // without worrying that they will actually try to happen after the lifetime
153   // of this object.
154   base::WeakPtrFactory<InternetOptionsHandler> weak_factory_;
155
156   DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler);
157 };
158
159 }  // namespace options
160 }  // namespace chromeos
161
162 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_