Update To 11.40.268.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 ShowMorePlanInfoCallback(const base::ListValue* args);
55   void SetApnCallback(const base::ListValue* args);
56   void SetApnProperties(const base::ListValue* args,
57                         const std::string& service_path,
58                         const base::DictionaryValue& shill_properties);
59   void CarrierStatusCallback();
60   void SetCarrierCallback(const base::ListValue* args);
61   void SimOperationCallback(const base::ListValue* args);
62
63   // networkingPrvate callbacks
64   void DisableNetworkTypeCallback(const base::ListValue* args);
65   void EnableNetworkTypeCallback(const base::ListValue* args);
66   void GetManagedPropertiesCallback(const base::ListValue* args);
67   void RequestNetworkScanCallback(const base::ListValue* args);
68   void StartConnectCallback(const base::ListValue* args);
69   void StartDisconnectCallback(const base::ListValue* args);
70
71   // Retrieves a data url for a resource.
72   std::string GetIconDataUrl(int resource_id) const;
73
74   // Refreshes the display of network information.
75   void RefreshNetworkData();
76
77   // Updates the display of network connection information for the details page
78   // if visible.
79   void UpdateConnectionData(const std::string& service_path);
80
81   // Callback for ManagedNetworkConnectionHandler::GetManagedProperties.
82   // Calls the JS callback |js_callback_function| with the result.
83   void GetManagedPropertiesResult(const std::string& js_callback_function,
84                                   const std::string& service_path,
85                                   const base::DictionaryValue& onc_properties);
86
87   // Called when carrier data has been updated to informs the JS.
88   void UpdateCarrier();
89
90   // NetworkStateHandlerObserver
91   virtual void DeviceListChanged() override;
92   virtual void NetworkListChanged() override;
93   virtual void NetworkConnectionStateChanged(
94       const chromeos::NetworkState* network) override;
95   virtual void NetworkPropertiesUpdated(
96       const chromeos::NetworkState* network) override;
97   virtual void DevicePropertiesUpdated(
98       const chromeos::DeviceState* device) override;
99
100   // Updates the logged in user type.
101   void UpdateLoggedInUserType();
102
103   // Additional callbacks to set network state properties.
104   void SetServerHostnameCallback(const base::ListValue* args);
105   void SetPreferNetworkCallback(const base::ListValue* args);
106   void SetAutoConnectCallback(const base::ListValue* args);
107   void SetIPConfigCallback(const base::ListValue* args);
108   void SetIPConfigProperties(const base::ListValue* args,
109                              const std::string& service_path,
110                              const base::DictionaryValue& shill_properties);
111
112   // Gets the native window for hosting dialogs, etc.
113   gfx::NativeWindow GetNativeWindow() const;
114
115   // Gets the UI scale factor.
116   float GetScaleFactor() const;
117
118   // Gets the user PrefService associated with the WebUI.
119   const PrefService* GetPrefs() const;
120
121   // Additional callbacks for managing networks.
122   void AddConnection(const base::ListValue* args);
123   void ConfigureNetwork(const base::ListValue* args);
124   void ActivateNetwork(const base::ListValue* args);
125   void RemoveNetwork(const base::ListValue* args);
126
127   // Creates the map of wired networks.
128   base::ListValue* GetWiredList();
129
130   // Creates the map of wireless networks.
131   base::ListValue* GetWirelessList();
132
133   // Creates the map of virtual networks.
134   base::ListValue* GetVPNList();
135
136   // Creates the map of remembered networks.
137   base::ListValue* GetRememberedList();
138
139   // Fills network information into JS dictionary for displaying network lists.
140   void FillNetworkInfo(base::DictionaryValue* dictionary);
141
142   // Keep track of the service path for the network shown in the Details view.
143   std::string details_path_;
144
145   // Weak pointer factory so we can start connections at a later time
146   // without worrying that they will actually try to happen after the lifetime
147   // of this object.
148   base::WeakPtrFactory<InternetOptionsHandler> weak_factory_;
149
150   DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler);
151 };
152
153 }  // namespace options
154 }  // namespace chromeos
155
156 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_