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_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_
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 "extensions/browser/extension_registry_observer.h"
15 #include "ui/gfx/native_widget_types.h"
23 class NetworkStateHandlerObserver
;
37 // ChromeOS internet options page UI handler.
38 class InternetOptionsHandler
: public ::options::OptionsPageUIHandler
,
39 public chromeos::NetworkStateHandlerObserver
,
40 public extensions::ExtensionRegistryObserver
{
42 InternetOptionsHandler();
43 ~InternetOptionsHandler() override
;
46 // OptionsPageUIHandler
47 void GetLocalizedValues(base::DictionaryValue
* localized_strings
) override
;
48 void InitializePage() override
;
50 // WebUIMessageHandler (from OptionsPageUIHandler)
51 void RegisterMessages() override
;
53 // ExtensionRegistryObserver
54 void OnExtensionLoaded(content::BrowserContext
* browser_context
,
55 const extensions::Extension
* extension
) override
;
56 void OnExtensionUnloaded(
57 content::BrowserContext
* browser_context
,
58 const extensions::Extension
* extension
,
59 extensions::UnloadedExtensionInfo::Reason reason
) override
;
60 void OnShutdown(extensions::ExtensionRegistry
* registry
) override
;
62 // Callbacks to set network state properties.
63 void ShowMorePlanInfoCallback(const base::ListValue
* args
);
64 void CarrierStatusCallback();
65 void SetCarrierCallback(const base::ListValue
* args
);
66 void SimOperationCallback(const base::ListValue
* args
);
68 // Sets details_guid_ for event forwarding.
69 void SetNetworkGuidCallback(const base::ListValue
* args
);
71 // networkingPrvate callbacks
72 void GetManagedPropertiesCallback(const base::ListValue
* args
);
73 void StartConnectCallback(const base::ListValue
* args
);
74 void SetPropertiesCallback(const base::ListValue
* args
);
76 // Updates the list of VPN providers enabled in the primary user's profile.
77 void UpdateVPNProviders();
79 // Refreshes the display of network information.
80 void RefreshNetworkData();
82 // Updates the display of network connection information for the details page
84 void UpdateConnectionData(const std::string
& service_path
);
86 // Callback for ManagedNetworkConnectionHandler::GetManagedProperties.
87 // Calls the JS callback |js_callback_function| with the result.
88 void GetManagedPropertiesResult(const std::string
& js_callback_function
,
89 const std::string
& service_path
,
90 const base::DictionaryValue
& onc_properties
);
92 // Called when carrier data has been updated to informs the JS.
95 // NetworkStateHandlerObserver
96 void DeviceListChanged() override
;
97 void NetworkListChanged() override
;
98 void NetworkConnectionStateChanged(
99 const chromeos::NetworkState
* network
) override
;
100 void NetworkPropertiesUpdated(const chromeos::NetworkState
* network
) override
;
101 void DevicePropertiesUpdated(const chromeos::DeviceState
* device
) override
;
103 // Updates the logged in user type.
104 void UpdateLoggedInUserType();
106 // Gets the native window for hosting dialogs, etc.
107 gfx::NativeWindow
GetNativeWindow() const;
109 // Gets the user PrefService associated with the WebUI.
110 const PrefService
* GetPrefs() const;
112 // Additional callbacks for managing networks.
113 void AddVPNConnection(const base::ListValue
* args
);
114 void AddNonVPNConnection(const base::ListValue
* args
);
115 void ConfigureNetwork(const base::ListValue
* args
);
116 void ActivateNetwork(const base::ListValue
* args
);
117 void RemoveNetwork(const base::ListValue
* args
);
119 // Requests that a list of VPN providers enabled in the primary user's
120 // profile be sent to JavaScript.
121 void LoadVPNProvidersCallback(const base::ListValue
* args
);
123 // Creates the map of wired networks.
124 base::ListValue
* GetWiredList();
126 // Creates the map of wireless networks.
127 base::ListValue
* GetWirelessList();
129 // Creates the map of virtual networks.
130 base::ListValue
* GetVPNList();
132 // Creates the map of remembered networks.
133 base::ListValue
* GetRememberedList();
135 // Fills network information into JS dictionary for displaying network lists.
136 void FillNetworkInfo(base::DictionaryValue
* dictionary
);
138 // Keep track of the service path for the network shown in the Details view.
139 std::string details_guid_
;
141 // Weak pointer factory so we can start connections at a later time
142 // without worrying that they will actually try to happen after the lifetime
144 base::WeakPtrFactory
<InternetOptionsHandler
> weak_factory_
;
146 DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler
);
149 } // namespace options
150 } // namespace chromeos
152 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_