Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 | #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h" |
| 6 | |
| 7 | #include <ctype.h> |
| 8 | |
| 9 | #include <map> |
| 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
| 13 | #include "ash/shell.h" |
| 14 | #include "ash/shell_delegate.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 15 | #include "ash/system/chromeos/network/network_connect.h" |
| 16 | #include "ash/system/chromeos/network/network_icon.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 17 | #include "base/base64.h" |
| 18 | #include "base/basictypes.h" |
| 19 | #include "base/bind.h" |
| 20 | #include "base/bind_helpers.h" |
| 21 | #include "base/command_line.h" |
| 22 | #include "base/i18n/time_formatting.h" |
| 23 | #include "base/json/json_writer.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 24 | #include "base/strings/string16.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 25 | #include "base/strings/string_number_conversions.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 26 | #include "base/strings/stringprintf.h" |
| 27 | #include "base/strings/utf_string_conversions.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 28 | #include "base/time/time.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 29 | #include "base/values.h" |
| 30 | #include "chrome/browser/browser_process.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 31 | #include "chrome/browser/chrome_notification_types.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 32 | #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 33 | #include "chrome/browser/chromeos/cros/network_library.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 34 | #include "chrome/browser/chromeos/cros/network_property_ui_data.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 35 | #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 36 | #include "chrome/browser/chromeos/login/user.h" |
| 37 | #include "chrome/browser/chromeos/login/user_manager.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 38 | #include "chrome/browser/chromeos/mobile_config.h" |
| 39 | #include "chrome/browser/chromeos/options/network_config_view.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 40 | #include "chrome/browser/chromeos/options/network_connect.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 41 | #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 42 | #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 43 | #include "chrome/browser/chromeos/ui_proxy_config_service.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 44 | #include "chrome/browser/profiles/profile_manager.h" |
| 45 | #include "chrome/browser/ui/browser.h" |
| 46 | #include "chrome/browser/ui/browser_finder.h" |
| 47 | #include "chrome/browser/ui/browser_window.h" |
| 48 | #include "chrome/browser/ui/host_desktop.h" |
| 49 | #include "chrome/browser/ui/singleton_tabs.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 50 | #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.h" |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 51 | #include "chromeos/chromeos_switches.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 52 | #include "chromeos/network/device_state.h" |
| 53 | #include "chromeos/network/favorite_state.h" |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 54 | #include "chromeos/network/managed_network_configuration_handler.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 55 | #include "chromeos/network/network_configuration_handler.h" |
| 56 | #include "chromeos/network/network_connection_handler.h" |
| 57 | #include "chromeos/network/network_device_handler.h" |
| 58 | #include "chromeos/network/network_event_log.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 59 | #include "chromeos/network/network_ip_config.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 60 | #include "chromeos/network/network_profile.h" |
| 61 | #include "chromeos/network/network_profile_handler.h" |
| 62 | #include "chromeos/network/network_state.h" |
| 63 | #include "chromeos/network/network_state_handler.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 64 | #include "chromeos/network/network_ui_data.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 65 | #include "chromeos/network/network_util.h" |
| 66 | #include "chromeos/network/onc/onc_constants.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 67 | #include "content/public/browser/notification_service.h" |
| 68 | #include "content/public/browser/web_contents.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 69 | #include "content/public/browser/web_contents_view.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 70 | #include "content/public/browser/web_ui.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 71 | #include "grit/ash_resources.h" |
| 72 | #include "grit/ash_strings.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 73 | #include "grit/chromium_strings.h" |
| 74 | #include "grit/generated_resources.h" |
| 75 | #include "grit/locale_settings.h" |
| 76 | #include "grit/theme_resources.h" |
| 77 | #include "third_party/cros_system_api/dbus/service_constants.h" |
| 78 | #include "ui/base/l10n/l10n_util.h" |
| 79 | #include "ui/base/layout.h" |
| 80 | #include "ui/base/resource/resource_bundle.h" |
| 81 | #include "ui/gfx/display.h" |
| 82 | #include "ui/gfx/image/image_skia.h" |
| 83 | #include "ui/gfx/screen.h" |
| 84 | #include "ui/views/widget/widget.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 85 | #include "ui/webui/web_ui_util.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 86 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 87 | namespace chromeos { |
| 88 | namespace options { |
| 89 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 90 | namespace { |
| 91 | |
| 92 | // Keys for the network description dictionary passed to the web ui. Make sure |
| 93 | // to keep the strings in sync with what the JavaScript side uses. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 94 | const char kNetworkInfoKeyActivationState[] = "activationState"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 95 | const char kNetworkInfoKeyConnectable[] = "connectable"; |
| 96 | const char kNetworkInfoKeyConnected[] = "connected"; |
| 97 | const char kNetworkInfoKeyConnecting[] = "connecting"; |
| 98 | const char kNetworkInfoKeyIconURL[] = "iconURL"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 99 | const char kNetworkInfoKeyNetworkName[] = "networkName"; |
| 100 | const char kNetworkInfoKeyNetworkStatus[] = "networkStatus"; |
| 101 | const char kNetworkInfoKeyNetworkType[] = "networkType"; |
| 102 | const char kNetworkInfoKeyRemembered[] = "remembered"; |
| 103 | const char kNetworkInfoKeyServicePath[] = "servicePath"; |
| 104 | const char kNetworkInfoKeyPolicyManaged[] = "policyManaged"; |
| 105 | |
| 106 | // These are keys for getting IP information from the web ui. |
| 107 | const char kIpConfigAddress[] = "address"; |
| 108 | const char kIpConfigPrefixLength[] = "prefixLength"; |
| 109 | const char kIpConfigNetmask[] = "netmask"; |
| 110 | const char kIpConfigGateway[] = "gateway"; |
| 111 | const char kIpConfigNameServers[] = "nameServers"; |
| 112 | const char kIpConfigAutoConfig[] = "ipAutoConfig"; |
| 113 | |
| 114 | // These are types of name server selections from the web ui. |
| 115 | const char kNameServerTypeAutomatic[] = "automatic"; |
| 116 | const char kNameServerTypeGoogle[] = "google"; |
| 117 | const char kNameServerTypeUser[] = "user"; |
| 118 | |
| 119 | // These are dictionary names used to send data to the web ui. |
| 120 | const char kDictionaryIpConfig[] = "ipconfig"; |
| 121 | const char kDictionaryStaticIp[] = "staticIP"; |
| 122 | const char kDictionarySavedIp[] = "savedIP"; |
| 123 | |
| 124 | // Google public name servers (DNS). |
| 125 | const char kGoogleNameServers[] = "8.8.4.4,8.8.8.8"; |
| 126 | |
| 127 | // Functions we call in JavaScript. |
| 128 | const char kRefreshNetworkDataFunction[] = |
| 129 | "options.network.NetworkList.refreshNetworkData"; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 130 | const char kSetDefaultNetworkIconsFunction[] = |
| 131 | "options.network.NetworkList.setDefaultNetworkIcons"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 132 | const char kShowDetailedInfoFunction[] = |
| 133 | "options.internet.DetailsInternetPage.showDetailedInfo"; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 134 | const char kUpdateConnectionDataFunction[] = |
| 135 | "options.internet.DetailsInternetPage.updateConnectionData"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 136 | const char kUpdateCarrierFunction[] = |
| 137 | "options.internet.DetailsInternetPage.updateCarrier"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 138 | const char kUpdateSecurityTabFunction[] = |
| 139 | "options.internet.DetailsInternetPage.updateSecurityTab"; |
| 140 | |
| 141 | // These are used to register message handlers with JavaScript. |
| 142 | const char kBuyDataPlanMessage[] = "buyDataPlan"; |
| 143 | const char kChangePinMessage[] = "changePin"; |
| 144 | const char kDisableCellularMessage[] = "disableCellular"; |
| 145 | const char kDisableWifiMessage[] = "disableWifi"; |
| 146 | const char kDisableWimaxMessage[] = "disableWimax"; |
| 147 | const char kEnableCellularMessage[] = "enableCellular"; |
| 148 | const char kEnableWifiMessage[] = "enableWifi"; |
| 149 | const char kEnableWimaxMessage[] = "enableWimax"; |
| 150 | const char kNetworkCommandMessage[] = "networkCommand"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 151 | const char kRefreshNetworksMessage[] = "refreshNetworks"; |
| 152 | const char kSetApnMessage[] = "setApn"; |
| 153 | const char kSetAutoConnectMessage[] = "setAutoConnect"; |
| 154 | const char kSetCarrierMessage[] = "setCarrier"; |
| 155 | const char kSetIPConfigMessage[] = "setIPConfig"; |
| 156 | const char kSetPreferNetworkMessage[] = "setPreferNetwork"; |
| 157 | const char kSetServerHostname[] = "setServerHostname"; |
| 158 | const char kSetSimCardLockMessage[] = "setSimCardLock"; |
| 159 | const char kShowMorePlanInfoMessage[] = "showMorePlanInfo"; |
| 160 | |
| 161 | // These are strings used to communicate with JavaScript. |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 162 | const char kTagActivate[] = "activate"; |
| 163 | const char kTagActivated[] = "activated"; |
| 164 | const char kTagActivationState[] = "activationState"; |
| 165 | const char kTagAddConnection[] = "add"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 166 | const char kTagApn[] = "apn"; |
| 167 | const char kTagAutoConnect[] = "autoConnect"; |
| 168 | const char kTagBssid[] = "bssid"; |
| 169 | const char kTagCarrierSelectFlag[] = "showCarrierSelect"; |
| 170 | const char kTagCarrierUrl[] = "carrierUrl"; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 171 | const char kTagCellular[] = "cellular"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 172 | const char kTagCellularAvailable[] = "cellularAvailable"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 173 | const char kTagCellularEnabled[] = "cellularEnabled"; |
| 174 | const char kTagCellularSupportsScan[] = "cellularSupportsScan"; |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 175 | const char kTagConfigure[] = "configure"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 176 | const char kTagConnect[] = "connect"; |
| 177 | const char kTagConnected[] = "connected"; |
| 178 | const char kTagConnecting[] = "connecting"; |
| 179 | const char kTagConnectionState[] = "connectionState"; |
| 180 | const char kTagControlledBy[] = "controlledBy"; |
| 181 | const char kTagDataRemaining[] = "dataRemaining"; |
| 182 | const char kTagDeviceConnected[] = "deviceConnected"; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 183 | const char kTagDisableConnectButton[] = "disableConnectButton"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 184 | const char kTagDisconnect[] = "disconnect"; |
| 185 | const char kTagEncryption[] = "encryption"; |
| 186 | const char kTagErrorState[] = "errorState"; |
| 187 | const char kTagEsn[] = "esn"; |
| 188 | const char kTagFirmwareRevision[] = "firmwareRevision"; |
| 189 | const char kTagForget[] = "forget"; |
| 190 | const char kTagFrequency[] = "frequency"; |
| 191 | const char kTagGsm[] = "gsm"; |
| 192 | const char kTagHardwareAddress[] = "hardwareAddress"; |
| 193 | const char kTagHardwareRevision[] = "hardwareRevision"; |
| 194 | const char kTagIdentity[] = "identity"; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 195 | const char kTagIccid[] = "iccid"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 196 | const char kTagImei[] = "imei"; |
| 197 | const char kTagImsi[] = "imsi"; |
| 198 | const char kTagLanguage[] = "language"; |
| 199 | const char kTagLastGoodApn[] = "lastGoodApn"; |
| 200 | const char kTagLocalizedName[] = "localizedName"; |
| 201 | const char kTagManufacturer[] = "manufacturer"; |
| 202 | const char kTagMdn[] = "mdn"; |
| 203 | const char kTagMeid[] = "meid"; |
| 204 | const char kTagMin[] = "min"; |
| 205 | const char kTagModelId[] = "modelId"; |
| 206 | const char kTagName[] = "name"; |
| 207 | const char kTagNameServersGoogle[] = "nameServersGoogle"; |
| 208 | const char kTagNameServerType[] = "nameServerType"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 209 | const char kTagNetworkId[] = "networkId"; |
| 210 | const char kTagNetworkName[] = "networkName"; |
| 211 | const char kTagNetworkTechnology[] = "networkTechnology"; |
| 212 | const char kTagOperatorCode[] = "operatorCode"; |
| 213 | const char kTagOperatorName[] = "operatorName"; |
| 214 | const char kTagOptions[] = "options"; |
| 215 | const char kTagPassword[] = "password"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 216 | const char kTagPolicy[] = "policy"; |
| 217 | const char kTagPreferred[] = "preferred"; |
| 218 | const char kTagPrlVersion[] = "prlVersion"; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 219 | const char kTagProviderType[] = "providerType"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 220 | const char kTagProviderApnList[] = "providerApnList"; |
| 221 | const char kTagRecommended[] = "recommended"; |
| 222 | const char kTagRecommendedValue[] = "recommendedValue"; |
| 223 | const char kTagRemembered[] = "remembered"; |
| 224 | const char kTagRememberedList[] = "rememberedList"; |
| 225 | const char kTagRestrictedPool[] = "restrictedPool"; |
| 226 | const char kTagRoamingState[] = "roamingState"; |
| 227 | const char kTagServerHostname[] = "serverHostname"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 228 | const char kTagCarriers[] = "carriers"; |
| 229 | const char kTagCurrentCarrierIndex[] = "currentCarrierIndex"; |
| 230 | const char kTagServiceName[] = "serviceName"; |
| 231 | const char kTagServicePath[] = "servicePath"; |
| 232 | const char kTagShared[] = "shared"; |
| 233 | const char kTagShowActivateButton[] = "showActivateButton"; |
| 234 | const char kTagShowBuyButton[] = "showBuyButton"; |
| 235 | const char kTagShowPreferred[] = "showPreferred"; |
| 236 | const char kTagShowProxy[] = "showProxy"; |
| 237 | const char kTagShowStaticIPConfig[] = "showStaticIPConfig"; |
| 238 | const char kTagShowViewAccountButton[] = "showViewAccountButton"; |
| 239 | const char kTagSimCardLockEnabled[] = "simCardLockEnabled"; |
| 240 | const char kTagSsid[] = "ssid"; |
| 241 | const char kTagStrength[] = "strength"; |
| 242 | const char kTagSupportUrl[] = "supportUrl"; |
| 243 | const char kTagTrue[] = "true"; |
| 244 | const char kTagType[] = "type"; |
| 245 | const char kTagUsername[] = "username"; |
| 246 | const char kTagValue[] = "value"; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 247 | const char kTagVpn[] = "vpn"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 248 | const char kTagVpnList[] = "vpnList"; |
| 249 | const char kTagWarning[] = "warning"; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 250 | const char kTagWifi[] = "wifi"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 251 | const char kTagWifiAvailable[] = "wifiAvailable"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 252 | const char kTagWifiEnabled[] = "wifiEnabled"; |
| 253 | const char kTagWimaxAvailable[] = "wimaxAvailable"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 254 | const char kTagWimaxEnabled[] = "wimaxEnabled"; |
| 255 | const char kTagWiredList[] = "wiredList"; |
| 256 | const char kTagWirelessList[] = "wirelessList"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 257 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 258 | const int kPreferredPriority = 1; |
| 259 | |
| 260 | void ShillError(const std::string& function, |
| 261 | const std::string& error_name, |
| 262 | scoped_ptr<base::DictionaryValue> error_data) { |
| 263 | NET_LOG_ERROR("Shill Error from InternetOptionsHandler: " + error_name, |
| 264 | function); |
| 265 | } |
| 266 | |
| 267 | const NetworkState* GetNetworkState(const std::string& service_path) { |
| 268 | return NetworkHandler::Get()->network_state_handler()-> |
| 269 | GetNetworkState(service_path); |
| 270 | } |
| 271 | |
| 272 | void SetNetworkProperty(const std::string& service_path, |
| 273 | const std::string& property, |
| 274 | base::Value* value) { |
| 275 | NET_LOG_EVENT("SetNetworkProperty: " + property, service_path); |
| 276 | base::DictionaryValue properties; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 277 | properties.SetWithoutPathExpansion(property, value); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 278 | NetworkHandler::Get()->network_configuration_handler()->SetProperties( |
| 279 | service_path, properties, |
| 280 | base::Bind(&base::DoNothing), |
| 281 | base::Bind(&ShillError, "SetNetworkProperty")); |
| 282 | } |
| 283 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 284 | const base::DictionaryValue* FindPolicyForActiveUser( |
| 285 | const NetworkState* network, |
| 286 | onc::ONCSource* onc_source) { |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 287 | const User* user = UserManager::Get()->GetActiveUser(); |
| 288 | std::string username_hash = user ? user->username_hash() : std::string(); |
| 289 | return NetworkHandler::Get()->managed_network_configuration_handler() |
| 290 | ->FindPolicyByGUID(username_hash, network->guid(), onc_source); |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 291 | } |
| 292 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 293 | std::string ActivationStateString(const std::string& activation_state) { |
| 294 | int id; |
| 295 | if (activation_state == flimflam::kActivationStateActivated) |
| 296 | id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATED; |
| 297 | else if (activation_state == flimflam::kActivationStateActivating) |
| 298 | id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATING; |
| 299 | else if (activation_state == flimflam::kActivationStateNotActivated) |
| 300 | id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_NOT_ACTIVATED; |
| 301 | else if (activation_state == flimflam::kActivationStatePartiallyActivated) |
| 302 | id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_PARTIALLY_ACTIVATED; |
| 303 | else |
| 304 | id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_UNKNOWN; |
| 305 | return l10n_util::GetStringUTF8(id); |
| 306 | } |
| 307 | |
| 308 | std::string RoamingStateString(const std::string& roaming_state) { |
| 309 | int id; |
| 310 | if (roaming_state == flimflam::kRoamingStateHome) |
| 311 | id = IDS_CHROMEOS_NETWORK_ROAMING_STATE_HOME; |
| 312 | else if (roaming_state == flimflam::kRoamingStateRoaming) |
| 313 | id = IDS_CHROMEOS_NETWORK_ROAMING_STATE_ROAMING; |
| 314 | else |
| 315 | id = IDS_CHROMEOS_NETWORK_ROAMING_STATE_UNKNOWN; |
| 316 | return l10n_util::GetStringUTF8(id); |
| 317 | } |
| 318 | |
| 319 | std::string ConnectionStateString(const std::string& state) { |
| 320 | int id; |
| 321 | if (state == flimflam::kUnknownString) |
| 322 | id = IDS_CHROMEOS_NETWORK_STATE_UNKNOWN; |
| 323 | else if (state == flimflam::kStateIdle) |
| 324 | id = IDS_CHROMEOS_NETWORK_STATE_IDLE; |
| 325 | else if (state == flimflam::kStateCarrier) |
| 326 | id = IDS_CHROMEOS_NETWORK_STATE_CARRIER; |
| 327 | else if (state == flimflam::kStateAssociation) |
| 328 | id = IDS_CHROMEOS_NETWORK_STATE_ASSOCIATION; |
| 329 | else if (state == flimflam::kStateConfiguration) |
| 330 | id = IDS_CHROMEOS_NETWORK_STATE_CONFIGURATION; |
| 331 | else if (state == flimflam::kStateReady) |
| 332 | id = IDS_CHROMEOS_NETWORK_STATE_READY; |
| 333 | else if (state == flimflam::kStateDisconnect) |
| 334 | id = IDS_CHROMEOS_NETWORK_STATE_DISCONNECT; |
| 335 | else if (state == flimflam::kStateFailure) |
| 336 | id = IDS_CHROMEOS_NETWORK_STATE_FAILURE; |
| 337 | else if (state == flimflam::kStateActivationFailure) |
| 338 | id = IDS_CHROMEOS_NETWORK_STATE_ACTIVATION_FAILURE; |
| 339 | else if (state == flimflam::kStatePortal) |
| 340 | id = IDS_CHROMEOS_NETWORK_STATE_PORTAL; |
| 341 | else if (state == flimflam::kStateOnline) |
| 342 | id = IDS_CHROMEOS_NETWORK_STATE_ONLINE; |
| 343 | else |
| 344 | id = IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED; |
| 345 | return l10n_util::GetStringUTF8(id); |
| 346 | } |
| 347 | |
| 348 | std::string EncryptionString(const std::string& security, |
| 349 | const std::string& eap_method) { |
| 350 | if (security == flimflam::kSecurityNone) |
| 351 | return ""; |
| 352 | if (security == flimflam::kSecurityWpa) |
| 353 | return "WPA"; |
| 354 | if (security == flimflam::kSecurityWep) |
| 355 | return "WEP"; |
| 356 | if (security == flimflam::kSecurityRsn) |
| 357 | return "RSN"; |
| 358 | if (security == flimflam::kSecurityPsk) |
| 359 | return "PSK"; |
| 360 | if (security == flimflam::kSecurity8021x) { |
| 361 | std::string result = "8021X"; |
| 362 | if (eap_method == flimflam::kEapMethodPEAP) |
| 363 | result += "PEAP"; |
| 364 | else if (eap_method == flimflam::kEapMethodTLS) |
| 365 | result += "TLS"; |
| 366 | else if (eap_method == flimflam::kEapMethodTTLS) |
| 367 | result += "TTLS"; |
| 368 | else if (eap_method == flimflam::kEapMethodLEAP) |
| 369 | result += "LEAP"; |
| 370 | return result; |
| 371 | } |
| 372 | return "Unknown"; |
| 373 | } |
| 374 | |
| 375 | std::string ProviderTypeString( |
| 376 | const std::string& provider_type, |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 377 | const base::DictionaryValue& provider_properties) { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 378 | int id; |
| 379 | if (provider_type == flimflam::kProviderL2tpIpsec) { |
| 380 | std::string client_cert_id; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 381 | provider_properties.GetStringWithoutPathExpansion( |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 382 | flimflam::kL2tpIpsecClientCertIdProperty, &client_cert_id); |
| 383 | if (client_cert_id.empty()) |
| 384 | id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_L2TP_IPSEC_PSK; |
| 385 | else |
| 386 | id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_L2TP_IPSEC_USER_CERT; |
| 387 | } else if (provider_type == flimflam::kProviderOpenVpn) { |
| 388 | id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_OPEN_VPN; |
| 389 | } else { |
| 390 | id = IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN; |
| 391 | } |
| 392 | return l10n_util::GetStringUTF8(id); |
| 393 | } |
| 394 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 395 | // A helper class for building network information dictionaries to be sent to |
| 396 | // the webui code. |
| 397 | class NetworkInfoDictionary { |
| 398 | public: |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 399 | // Sets properties based on |network| and sets an appropriate icon based |
| 400 | // on the network type and |icon_scale_factor|. |
| 401 | NetworkInfoDictionary(const NetworkState* network, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 402 | ui::ScaleFactor icon_scale_factor); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 403 | NetworkInfoDictionary(const FavoriteState* network, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 404 | ui::ScaleFactor icon_scale_factor); |
| 405 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 406 | // Builds the DictionaryValue representation from the previously set |
| 407 | // parameters. Ownership of the returned pointer is transferred to the caller. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 408 | base::DictionaryValue* BuildDictionary(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 409 | |
| 410 | private: |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 411 | void SetIcon(const gfx::ImageSkia& icon, |
| 412 | ui::ScaleFactor icon_scale_factor) { |
| 413 | gfx::ImageSkiaRep image_rep = icon.GetRepresentation(icon_scale_factor); |
| 414 | icon_url_ = icon.isNull() ? "" : webui::GetBitmapDataUrl( |
| 415 | image_rep.sk_bitmap()); |
| 416 | } |
| 417 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 418 | std::string service_path_; |
| 419 | std::string icon_url_; |
| 420 | std::string name_; |
| 421 | bool connecting_; |
| 422 | bool connected_; |
| 423 | bool connectable_; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 424 | std::string connection_type_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 425 | bool remembered_; |
| 426 | bool shared_; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 427 | std::string activation_state_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 428 | bool policy_managed_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 429 | |
| 430 | DISALLOW_COPY_AND_ASSIGN(NetworkInfoDictionary); |
| 431 | }; |
| 432 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 433 | NetworkInfoDictionary::NetworkInfoDictionary(const NetworkState* network, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 434 | ui::ScaleFactor icon_scale_factor) |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 435 | : service_path_(network->path()), |
| 436 | name_(network->name()), |
| 437 | connecting_(network->IsConnectingState()), |
| 438 | connected_(network->IsConnectedState()), |
| 439 | connectable_(network->connectable()), |
| 440 | connection_type_(network->type()), |
| 441 | remembered_(false), |
| 442 | shared_(false), |
| 443 | activation_state_(network->activation_state()), |
| 444 | policy_managed_(network->IsManaged()) { |
| 445 | if (network->type() == flimflam::kTypeEthernet) |
| 446 | name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); |
| 447 | gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork( |
| 448 | network, ash::network_icon::ICON_TYPE_LIST); |
| 449 | SetIcon(icon, icon_scale_factor); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 450 | } |
| 451 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 452 | NetworkInfoDictionary::NetworkInfoDictionary(const FavoriteState* favorite, |
| 453 | ui::ScaleFactor icon_scale_factor) |
| 454 | : service_path_(favorite->path()), |
| 455 | name_(favorite->name()), |
| 456 | connecting_(false), |
| 457 | connected_(false), |
| 458 | connectable_(false), |
| 459 | connection_type_(favorite->type()), |
| 460 | remembered_(true), |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 461 | shared_(!favorite->IsPrivate()), |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 462 | policy_managed_(favorite->IsManaged()) { |
| 463 | if (favorite->type() == flimflam::kTypeEthernet) |
| 464 | name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); |
| 465 | gfx::ImageSkia icon = ash::network_icon::GetImageForDisconnectedNetwork( |
| 466 | ash::network_icon::ICON_TYPE_LIST, favorite->type()); |
| 467 | SetIcon(icon, icon_scale_factor); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 468 | } |
| 469 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 470 | base::DictionaryValue* NetworkInfoDictionary::BuildDictionary() { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 471 | std::string status; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 472 | if (remembered_) { |
| 473 | if (shared_) |
| 474 | status = l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SHARED_NETWORK); |
| 475 | } else { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 476 | int id; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 477 | if (connected_) |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 478 | id = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTED; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 479 | else if (connecting_) |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 480 | id = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 481 | else if (!connectable_) |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 482 | id = IDS_STATUSBAR_NETWORK_DEVICE_NOT_CONFIGURED; |
| 483 | else |
| 484 | id = IDS_STATUSBAR_NETWORK_DEVICE_DISCONNECTED; |
| 485 | std::string status = l10n_util::GetStringUTF8(id); |
| 486 | if (connection_type_ == flimflam::kTypeCellular && |
| 487 | activation_state_ != flimflam::kActivationStateActivated) { |
| 488 | status.append(" / "); |
| 489 | status.append(ActivationStateString(activation_state_)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 493 | scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue()); |
| 494 | network_info->SetString(kNetworkInfoKeyActivationState, activation_state_); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 495 | network_info->SetBoolean(kNetworkInfoKeyConnectable, connectable_); |
| 496 | network_info->SetBoolean(kNetworkInfoKeyConnected, connected_); |
| 497 | network_info->SetBoolean(kNetworkInfoKeyConnecting, connecting_); |
| 498 | network_info->SetString(kNetworkInfoKeyIconURL, icon_url_); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 499 | network_info->SetString(kNetworkInfoKeyNetworkName, name_); |
| 500 | network_info->SetString(kNetworkInfoKeyNetworkStatus, status); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 501 | network_info->SetString(kNetworkInfoKeyNetworkType, connection_type_); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 502 | network_info->SetBoolean(kNetworkInfoKeyRemembered, remembered_); |
| 503 | network_info->SetString(kNetworkInfoKeyServicePath, service_path_); |
| 504 | network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, policy_managed_); |
| 505 | return network_info.release(); |
| 506 | } |
| 507 | |
| 508 | // Pulls IP information out of a shill service properties dictionary. If |
| 509 | // |static_ip| is true, then it fetches "StaticIP.*" properties. If not, then it |
| 510 | // fetches "SavedIP.*" properties. Caller must take ownership of returned |
| 511 | // dictionary. If non-NULL, |ip_parameters_set| returns a count of the number |
| 512 | // of IP routing parameters that get set. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 513 | base::DictionaryValue* BuildIPInfoDictionary( |
| 514 | const base::DictionaryValue& shill_properties, |
| 515 | bool static_ip, |
| 516 | int* routing_parameters_set) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 517 | std::string address_key; |
| 518 | std::string prefix_len_key; |
| 519 | std::string gateway_key; |
| 520 | std::string name_servers_key; |
| 521 | if (static_ip) { |
| 522 | address_key = shill::kStaticIPAddressProperty; |
| 523 | prefix_len_key = shill::kStaticIPPrefixlenProperty; |
| 524 | gateway_key = shill::kStaticIPGatewayProperty; |
| 525 | name_servers_key = shill::kStaticIPNameServersProperty; |
| 526 | } else { |
| 527 | address_key = shill::kSavedIPAddressProperty; |
| 528 | prefix_len_key = shill::kSavedIPPrefixlenProperty; |
| 529 | gateway_key = shill::kSavedIPGatewayProperty; |
| 530 | name_servers_key = shill::kSavedIPNameServersProperty; |
| 531 | } |
| 532 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 533 | scoped_ptr<base::DictionaryValue> ip_info_dict(new base::DictionaryValue); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 534 | std::string address; |
| 535 | int routing_parameters = 0; |
| 536 | if (shill_properties.GetStringWithoutPathExpansion(address_key, &address)) { |
| 537 | ip_info_dict->SetString(kIpConfigAddress, address); |
| 538 | VLOG(2) << "Found " << address_key << ": " << address; |
| 539 | routing_parameters++; |
| 540 | } |
| 541 | int prefix_len = -1; |
| 542 | if (shill_properties.GetIntegerWithoutPathExpansion( |
| 543 | prefix_len_key, &prefix_len)) { |
| 544 | ip_info_dict->SetInteger(kIpConfigPrefixLength, prefix_len); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 545 | std::string netmask = network_util::PrefixLengthToNetmask(prefix_len); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 546 | ip_info_dict->SetString(kIpConfigNetmask, netmask); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 547 | VLOG(2) << "Found " << prefix_len_key << ": " |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 548 | << prefix_len << " (" << netmask << ")"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 549 | routing_parameters++; |
| 550 | } |
| 551 | std::string gateway; |
| 552 | if (shill_properties.GetStringWithoutPathExpansion(gateway_key, &gateway)) { |
| 553 | ip_info_dict->SetString(kIpConfigGateway, gateway); |
| 554 | VLOG(2) << "Found " << gateway_key << ": " << gateway; |
| 555 | routing_parameters++; |
| 556 | } |
| 557 | if (routing_parameters_set) |
| 558 | *routing_parameters_set = routing_parameters; |
| 559 | |
| 560 | std::string name_servers; |
| 561 | if (shill_properties.GetStringWithoutPathExpansion( |
| 562 | name_servers_key, &name_servers)) { |
| 563 | ip_info_dict->SetString(kIpConfigNameServers, name_servers); |
| 564 | VLOG(2) << "Found " << name_servers_key << ": " << name_servers; |
| 565 | } |
| 566 | |
| 567 | return ip_info_dict.release(); |
| 568 | } |
| 569 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 570 | static bool CanForgetNetworkType(const std::string& type) { |
| 571 | return type == flimflam::kTypeWifi || |
| 572 | type == flimflam::kTypeWimax || |
| 573 | type == flimflam::kTypeVPN; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 574 | } |
| 575 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 576 | static bool CanAddNetworkType(const std::string& type) { |
| 577 | return type == flimflam::kTypeWifi || |
| 578 | type == flimflam::kTypeVPN || |
| 579 | type == flimflam::kTypeCellular; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does and |
| 583 | // store it under |key| in |settings|. Takes ownership of |value|. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 584 | void SetValueDictionary(base::DictionaryValue* settings, |
| 585 | const char* key, |
| 586 | base::Value* value, |
| 587 | const NetworkPropertyUIData& ui_data) { |
| 588 | base::DictionaryValue* dict = new base::DictionaryValue(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 589 | // DictionaryValue::Set() takes ownership of |value|. |
| 590 | dict->Set(kTagValue, value); |
| 591 | const base::Value* recommended_value = ui_data.default_value(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 592 | if (ui_data.IsManaged()) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 593 | dict->SetString(kTagControlledBy, kTagPolicy); |
| 594 | else if (recommended_value && recommended_value->Equals(value)) |
| 595 | dict->SetString(kTagControlledBy, kTagRecommended); |
| 596 | |
| 597 | if (recommended_value) |
| 598 | dict->Set(kTagRecommendedValue, recommended_value->DeepCopy()); |
| 599 | settings->Set(key, dict); |
| 600 | } |
| 601 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 602 | std::string CopyStringFromDictionary(const base::DictionaryValue& source, |
| 603 | const std::string& src_key, |
| 604 | const std::string& dest_key, |
| 605 | base::DictionaryValue* dest) { |
| 606 | std::string string_value; |
| 607 | if (source.GetStringWithoutPathExpansion(src_key, &string_value)) |
| 608 | dest->SetStringWithoutPathExpansion(dest_key, string_value); |
| 609 | return string_value; |
| 610 | } |
| 611 | |
| 612 | void CopyIntegerFromDictionary(const base::DictionaryValue& source, |
| 613 | const std::string& src_key, |
| 614 | const std::string& dest_key, |
| 615 | bool as_string, |
| 616 | base::DictionaryValue* dest) { |
| 617 | int int_value; |
| 618 | if (!source.GetIntegerWithoutPathExpansion(src_key, &int_value)) |
| 619 | return; |
| 620 | if (as_string) { |
| 621 | std::string str = base::StringPrintf("%d", int_value); |
| 622 | dest->SetStringWithoutPathExpansion(dest_key, str); |
| 623 | } else { |
| 624 | dest->SetIntegerWithoutPathExpansion(dest_key, int_value); |
| 625 | } |
| 626 | } |
| 627 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 628 | // Fills |dictionary| with the configuration details of |vpn|. |onc| is required |
| 629 | // for augmenting the policy-managed information. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 630 | void PopulateVPNDetails(const NetworkState* vpn, |
| 631 | const base::DictionaryValue& shill_properties, |
| 632 | base::DictionaryValue* dictionary) { |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 633 | // Name and Remembered are set in PopulateConnectionDetails(). |
| 634 | // Provider properties are stored in the "Provider" dictionary. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 635 | const base::DictionaryValue* provider_properties = NULL; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 636 | if (!shill_properties.GetDictionaryWithoutPathExpansion( |
| 637 | flimflam::kProviderProperty, &provider_properties)) { |
| 638 | LOG(ERROR) << "No provider properties for VPN: " << vpn->path(); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 639 | return; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 640 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 641 | std::string provider_type; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 642 | provider_properties->GetStringWithoutPathExpansion( |
| 643 | flimflam::kTypeProperty, &provider_type); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 644 | dictionary->SetString(kTagProviderType, |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 645 | ProviderTypeString(provider_type, |
| 646 | *provider_properties)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 647 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 648 | std::string username; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 649 | if (provider_type == flimflam::kProviderOpenVpn) { |
| 650 | provider_properties->GetStringWithoutPathExpansion( |
| 651 | flimflam::kOpenVPNUserProperty, &username); |
| 652 | } else { |
| 653 | provider_properties->GetStringWithoutPathExpansion( |
| 654 | flimflam::kL2tpIpsecUserProperty, &username); |
| 655 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 656 | dictionary->SetString(kTagUsername, username); |
| 657 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 658 | onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
| 659 | const base::DictionaryValue* onc = FindPolicyForActiveUser(vpn, &onc_source); |
| 660 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 661 | NetworkPropertyUIData hostname_ui_data; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 662 | hostname_ui_data.ParseOncProperty( |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 663 | onc_source, |
| 664 | onc, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 665 | base::StringPrintf("%s.%s", onc::network_config::kVPN, onc::vpn::kHost)); |
| 666 | std::string provider_host; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 667 | provider_properties->GetStringWithoutPathExpansion( |
| 668 | flimflam::kHostProperty, &provider_host); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 669 | SetValueDictionary(dictionary, kTagServerHostname, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 670 | new base::StringValue(provider_host), |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 671 | hostname_ui_data); |
| 672 | } |
| 673 | |
| 674 | // Given a list of supported carrier's by the device, return the index of |
| 675 | // the carrier the device is currently using. |
| 676 | int FindCurrentCarrierIndex(const base::ListValue* carriers, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 677 | const DeviceState* device) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 678 | DCHECK(carriers); |
| 679 | DCHECK(device); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 680 | bool gsm = (device->technology_family() == flimflam::kTechnologyFamilyGsm); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 681 | int index = 0; |
| 682 | for (base::ListValue::const_iterator it = carriers->begin(); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 683 | it != carriers->end(); ++it, ++index) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 684 | std::string value; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 685 | if (!(*it)->GetAsString(&value)) |
| 686 | continue; |
| 687 | // For GSM devices the device name will be empty, so simply select |
| 688 | // the Generic UMTS carrier option if present. |
| 689 | if (gsm && (value == shill::kCarrierGenericUMTS)) |
| 690 | return index; |
| 691 | // For other carriers, the service name will match the carrier name. |
| 692 | if (value == device->carrier()) |
| 693 | return index; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 694 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 695 | return -1; |
| 696 | } |
| 697 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 698 | void PopulateWifiDetails(const NetworkState* wifi, |
| 699 | const base::DictionaryValue& shill_properties, |
| 700 | base::DictionaryValue* dictionary); |
| 701 | // TODO(stevenjb): Move implementation here. |
| 702 | |
| 703 | void PopulateWimaxDetails(const NetworkState* wimax, |
| 704 | const base::DictionaryValue& shill_properties, |
| 705 | base::DictionaryValue* dictionary); |
| 706 | // TODO(stevenjb): Move implementation here. |
| 707 | |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 708 | void CreateDictionaryFromCellularApn(const base::DictionaryValue* apn, |
| 709 | base::DictionaryValue* dictionary); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 710 | // TODO(stevenjb): Move implementation here. |
| 711 | |
| 712 | void PopulateCellularDetails(const NetworkState* cellular, |
| 713 | const base::DictionaryValue& shill_properties, |
| 714 | base::DictionaryValue* dictionary); |
| 715 | // TODO(stevenjb): Move implementation here. |
| 716 | |
| 717 | void PopulateConnectionDetails(const NetworkState* network, |
| 718 | const base::DictionaryValue& shill_properties, |
| 719 | base::DictionaryValue* dictionary); |
| 720 | // TODO(stevenjb): Move implementation here. |
| 721 | |
| 722 | // Helper methods for SetIPConfigProperties |
| 723 | void AppendPropertyKeyIfPresent(const std::string& key, |
| 724 | const base::DictionaryValue& old_properties, |
| 725 | std::vector<std::string>* property_keys) { |
| 726 | if (old_properties.HasKey(key)) |
| 727 | property_keys->push_back(key); |
| 728 | } |
| 729 | |
| 730 | void AddStringPropertyIfChanged(const std::string& key, |
| 731 | const std::string& new_value, |
| 732 | const base::DictionaryValue& old_properties, |
| 733 | base::DictionaryValue* new_properties) { |
| 734 | std::string old_value; |
| 735 | if (!old_properties.GetStringWithoutPathExpansion(key, &old_value) || |
| 736 | new_value != old_value) { |
| 737 | new_properties->SetStringWithoutPathExpansion(key, new_value); |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | void AddIntegerPropertyIfChanged(const std::string& key, |
| 742 | int new_value, |
| 743 | const base::DictionaryValue& old_properties, |
| 744 | base::DictionaryValue* new_properties) { |
| 745 | int old_value; |
| 746 | if (!old_properties.GetIntegerWithoutPathExpansion(key, &old_value) || |
| 747 | new_value != old_value) { |
| 748 | new_properties->SetIntegerWithoutPathExpansion(key, new_value); |
| 749 | } |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 750 | } |
| 751 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 752 | } // namespace |
| 753 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 754 | InternetOptionsHandler::InternetOptionsHandler() |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 755 | : weak_factory_(this) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 756 | registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 757 | content::NotificationService::AllSources()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 758 | registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 759 | content::NotificationService::AllSources()); |
| 760 | NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 761 | } |
| 762 | |
| 763 | InternetOptionsHandler::~InternetOptionsHandler() { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 764 | if (NetworkHandler::IsInitialized()) { |
| 765 | NetworkHandler::Get()->network_state_handler()->RemoveObserver( |
| 766 | this, FROM_HERE); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 767 | } |
| 768 | } |
| 769 | |
| 770 | void InternetOptionsHandler::GetLocalizedValues( |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 771 | base::DictionaryValue* localized_strings) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 772 | DCHECK(localized_strings); |
| 773 | |
| 774 | static OptionsStringResource resources[] = { |
| 775 | |
| 776 | // Main settings page. |
| 777 | |
| 778 | { "ethernetTitle", IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET }, |
| 779 | { "wifiTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIFI_NETWORK }, |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 780 | { "wimaxTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIMAX_NETWORK }, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 781 | { "cellularTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_CELLULAR_NETWORK }, |
| 782 | { "vpnTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_PRIVATE_NETWORK }, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 783 | { "networkNotConnected", IDS_OPTIONS_SETTINGS_NETWORK_NOT_CONNECTED }, |
| 784 | { "networkConnected", IDS_CHROMEOS_NETWORK_STATE_READY }, |
| 785 | { "joinOtherNetwork", IDS_OPTIONS_SETTINGS_NETWORK_OTHER }, |
| 786 | { "networkOffline", IDS_OPTIONS_SETTINGS_NETWORK_OFFLINE }, |
| 787 | { "networkDisabled", IDS_OPTIONS_SETTINGS_NETWORK_DISABLED }, |
| 788 | { "networkOnline", IDS_OPTIONS_SETTINGS_NETWORK_ONLINE }, |
| 789 | { "networkOptions", IDS_OPTIONS_SETTINGS_NETWORK_OPTIONS }, |
| 790 | { "turnOffWifi", IDS_OPTIONS_SETTINGS_NETWORK_DISABLE_WIFI }, |
Ben Murdoch | 9ab5563 | 2013-07-18 11:57:30 +0100 | [diff] [blame] | 791 | { "turnOffWimax", IDS_OPTIONS_SETTINGS_NETWORK_DISABLE_WIMAX }, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 792 | { "turnOffCellular", IDS_OPTIONS_SETTINGS_NETWORK_DISABLE_CELLULAR }, |
| 793 | { "disconnectNetwork", IDS_OPTIONS_SETTINGS_DISCONNECT }, |
| 794 | { "preferredNetworks", IDS_OPTIONS_SETTINGS_PREFERRED_NETWORKS_LABEL }, |
| 795 | { "preferredNetworksPage", IDS_OPTIONS_SETTINGS_PREFERRED_NETWORKS_TITLE }, |
| 796 | { "useSharedProxies", IDS_OPTIONS_SETTINGS_USE_SHARED_PROXIES }, |
| 797 | { "addConnectionTitle", |
| 798 | IDS_OPTIONS_SETTINGS_SECTION_TITLE_ADD_CONNECTION }, |
| 799 | { "addConnectionWifi", IDS_OPTIONS_SETTINGS_ADD_CONNECTION_WIFI }, |
| 800 | { "addConnectionVPN", IDS_STATUSBAR_NETWORK_ADD_VPN }, |
| 801 | { "otherCellularNetworks", IDS_OPTIONS_SETTINGS_OTHER_CELLULAR_NETWORKS }, |
| 802 | { "enableDataRoaming", IDS_OPTIONS_SETTINGS_ENABLE_DATA_ROAMING }, |
| 803 | { "disableDataRoaming", IDS_OPTIONS_SETTINGS_DISABLE_DATA_ROAMING }, |
| 804 | { "dataRoamingDisableToggleTooltip", |
| 805 | IDS_OPTIONS_SETTINGS_TOGGLE_DATA_ROAMING_RESTRICTION }, |
| 806 | { "activateNetwork", IDS_STATUSBAR_NETWORK_DEVICE_ACTIVATE }, |
| 807 | |
| 808 | // Internet details dialog. |
| 809 | |
| 810 | { "changeProxyButton", |
| 811 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CHANGE_PROXY_BUTTON }, |
| 812 | { "managedNetwork", IDS_OPTIONS_SETTINGS_MANAGED_NETWORK }, |
| 813 | { "wifiNetworkTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_CONNECTION }, |
| 814 | { "vpnTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_VPN }, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 815 | { "cellularConnTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_CONNECTION }, |
| 816 | { "cellularDeviceTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_DEVICE }, |
| 817 | { "networkTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK }, |
| 818 | { "securityTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_SECURITY }, |
| 819 | { "proxyTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_PROXY }, |
| 820 | { "connectionState", IDS_OPTIONS_SETTINGS_INTERNET_CONNECTION_STATE }, |
| 821 | { "inetAddress", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_ADDRESS }, |
| 822 | { "inetNetmask", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SUBNETMASK }, |
| 823 | { "inetGateway", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_GATEWAY }, |
| 824 | { "inetNameServers", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_DNSSERVER }, |
| 825 | { "ipAutomaticConfiguration", |
| 826 | IDS_OPTIONS_SETTINGS_INTERNET_IP_AUTOMATIC_CONFIGURATION }, |
| 827 | { "automaticNameServers", |
| 828 | IDS_OPTIONS_SETTINGS_INTERNET_AUTOMATIC_NAME_SERVERS }, |
| 829 | { "userNameServer1", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVER_1 }, |
| 830 | { "userNameServer2", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVER_2 }, |
| 831 | { "userNameServer3", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVER_3 }, |
| 832 | { "userNameServer4", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVER_4 }, |
| 833 | { "googleNameServers", IDS_OPTIONS_SETTINGS_INTERNET_GOOGLE_NAME_SERVERS }, |
| 834 | { "userNameServers", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVERS }, |
| 835 | { "hardwareAddress", |
| 836 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_HARDWARE_ADDRESS }, |
| 837 | { "detailsInternetDismiss", IDS_CLOSE }, |
| 838 | { "activateButton", IDS_OPTIONS_SETTINGS_ACTIVATE }, |
| 839 | { "buyplanButton", IDS_OPTIONS_SETTINGS_BUY_PLAN }, |
| 840 | { "connectButton", IDS_OPTIONS_SETTINGS_CONNECT }, |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 841 | { "configureButton", IDS_OPTIONS_SETTINGS_CONFIGURE }, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 842 | { "disconnectButton", IDS_OPTIONS_SETTINGS_DISCONNECT }, |
| 843 | { "viewAccountButton", IDS_STATUSBAR_NETWORK_VIEW_ACCOUNT }, |
| 844 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 845 | { "wimaxConnTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_WIMAX }, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 846 | |
| 847 | // Wifi Tab. |
| 848 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 849 | { "inetSsid", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_ID }, |
| 850 | { "inetBssid", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_BSSID }, |
| 851 | { "inetEncryption", |
| 852 | IDS_OPTIONS_SETTIGNS_INTERNET_OPTIONS_NETWORK_ENCRYPTION }, |
| 853 | { "inetFrequency", |
| 854 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_FREQUENCY }, |
| 855 | { "inetFrequencyFormat", |
| 856 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_FREQUENCY_MHZ }, |
| 857 | { "inetSignalStrength", |
| 858 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_STRENGTH }, |
| 859 | { "inetSignalStrengthFormat", |
| 860 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_STRENGTH_PERCENTAGE }, |
| 861 | { "inetPassProtected", |
| 862 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NET_PROTECTED }, |
| 863 | { "inetNetworkShared", |
| 864 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_SHARED }, |
| 865 | { "inetPreferredNetwork", |
| 866 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PREFER_NETWORK }, |
| 867 | { "inetAutoConnectNetwork", |
| 868 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT }, |
| 869 | { "inetLogin", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN }, |
| 870 | { "inetShowPass", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHOWPASSWORD }, |
| 871 | { "inetPassPrompt", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSWORD }, |
| 872 | { "inetSsidPrompt", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SSID }, |
| 873 | { "inetStatus", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_STATUS_TITLE }, |
| 874 | { "inetConnect", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CONNECT_TITLE }, |
| 875 | |
| 876 | // VPN Tab. |
| 877 | |
| 878 | { "inetServiceName", |
| 879 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVICE_NAME }, |
| 880 | { "inetServerHostname", |
| 881 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVER_HOSTNAME }, |
| 882 | { "inetProviderType", |
| 883 | IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PROVIDER_TYPE }, |
| 884 | { "inetUsername", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USERNAME }, |
| 885 | |
| 886 | // Cellular Tab. |
| 887 | |
| 888 | { "serviceName", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_SERVICE_NAME }, |
| 889 | { "networkTechnology", |
| 890 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_NETWORK_TECHNOLOGY }, |
| 891 | { "operatorName", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_OPERATOR }, |
| 892 | { "operatorCode", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_OPERATOR_CODE }, |
| 893 | { "activationState", |
| 894 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ACTIVATION_STATE }, |
| 895 | { "roamingState", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ROAMING_STATE }, |
| 896 | { "restrictedPool", |
| 897 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_RESTRICTED_POOL }, |
| 898 | { "errorState", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ERROR_STATE }, |
| 899 | { "manufacturer", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_MANUFACTURER }, |
| 900 | { "modelId", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_MODEL_ID }, |
| 901 | { "firmwareRevision", |
| 902 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_FIRMWARE_REVISION }, |
| 903 | { "hardwareRevision", |
| 904 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_HARDWARE_REVISION }, |
| 905 | { "prlVersion", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_PRL_VERSION }, |
| 906 | { "cellularApnLabel", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN }, |
| 907 | { "cellularApnOther", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_OTHER }, |
| 908 | { "cellularApnUsername", |
| 909 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_USERNAME }, |
| 910 | { "cellularApnPassword", |
| 911 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_PASSWORD }, |
| 912 | { "cellularApnUseDefault", |
| 913 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_CLEAR }, |
| 914 | { "cellularApnSet", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_SET }, |
| 915 | { "cellularApnCancel", IDS_CANCEL }, |
| 916 | |
| 917 | // Security Tab. |
| 918 | |
| 919 | { "accessSecurityTabLink", |
| 920 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ACCESS_SECURITY_TAB }, |
| 921 | { "lockSimCard", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_LOCK_SIM_CARD }, |
| 922 | { "changePinButton", |
| 923 | IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_BUTTON }, |
| 924 | }; |
| 925 | |
| 926 | RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 927 | |
| 928 | std::string owner; |
| 929 | chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
| 930 | localized_strings->SetString("ownerUserId", UTF8ToUTF16(owner)); |
| 931 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 932 | base::DictionaryValue* network_dictionary = new base::DictionaryValue; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 933 | FillNetworkInfo(network_dictionary); |
| 934 | localized_strings->Set("networkData", network_dictionary); |
| 935 | } |
| 936 | |
| 937 | void InternetOptionsHandler::InitializePage() { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 938 | base::DictionaryValue dictionary; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 939 | dictionary.SetString(kTagCellular, |
| 940 | GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_BARS_DARK)); |
| 941 | dictionary.SetString(kTagWifi, |
| 942 | GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_ARCS_DARK)); |
| 943 | dictionary.SetString(kTagVpn, |
| 944 | GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_VPN)); |
| 945 | web_ui()->CallJavascriptFunction(kSetDefaultNetworkIconsFunction, |
| 946 | dictionary); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 947 | NetworkHandler::Get()->network_state_handler()->RequestScan(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 948 | } |
| 949 | |
| 950 | void InternetOptionsHandler::RegisterMessages() { |
| 951 | // Setup handlers specific to this panel. |
| 952 | web_ui()->RegisterMessageCallback(kNetworkCommandMessage, |
| 953 | base::Bind(&InternetOptionsHandler::NetworkCommandCallback, |
| 954 | base::Unretained(this))); |
| 955 | web_ui()->RegisterMessageCallback(kRefreshNetworksMessage, |
| 956 | base::Bind(&InternetOptionsHandler::RefreshNetworksCallback, |
| 957 | base::Unretained(this))); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 958 | web_ui()->RegisterMessageCallback(kSetPreferNetworkMessage, |
| 959 | base::Bind(&InternetOptionsHandler::SetPreferNetworkCallback, |
| 960 | base::Unretained(this))); |
| 961 | web_ui()->RegisterMessageCallback(kSetAutoConnectMessage, |
| 962 | base::Bind(&InternetOptionsHandler::SetAutoConnectCallback, |
| 963 | base::Unretained(this))); |
| 964 | web_ui()->RegisterMessageCallback(kSetIPConfigMessage, |
| 965 | base::Bind(&InternetOptionsHandler::SetIPConfigCallback, |
| 966 | base::Unretained(this))); |
| 967 | web_ui()->RegisterMessageCallback(kEnableWifiMessage, |
| 968 | base::Bind(&InternetOptionsHandler::EnableWifiCallback, |
| 969 | base::Unretained(this))); |
| 970 | web_ui()->RegisterMessageCallback(kDisableWifiMessage, |
| 971 | base::Bind(&InternetOptionsHandler::DisableWifiCallback, |
| 972 | base::Unretained(this))); |
| 973 | web_ui()->RegisterMessageCallback(kEnableCellularMessage, |
| 974 | base::Bind(&InternetOptionsHandler::EnableCellularCallback, |
| 975 | base::Unretained(this))); |
| 976 | web_ui()->RegisterMessageCallback(kDisableCellularMessage, |
| 977 | base::Bind(&InternetOptionsHandler::DisableCellularCallback, |
| 978 | base::Unretained(this))); |
| 979 | web_ui()->RegisterMessageCallback(kEnableWimaxMessage, |
| 980 | base::Bind(&InternetOptionsHandler::EnableWimaxCallback, |
| 981 | base::Unretained(this))); |
| 982 | web_ui()->RegisterMessageCallback(kDisableWimaxMessage, |
| 983 | base::Bind(&InternetOptionsHandler::DisableWimaxCallback, |
| 984 | base::Unretained(this))); |
| 985 | web_ui()->RegisterMessageCallback(kBuyDataPlanMessage, |
| 986 | base::Bind(&InternetOptionsHandler::BuyDataPlanCallback, |
| 987 | base::Unretained(this))); |
| 988 | web_ui()->RegisterMessageCallback(kShowMorePlanInfoMessage, |
| 989 | base::Bind(&InternetOptionsHandler::ShowMorePlanInfoCallback, |
| 990 | base::Unretained(this))); |
| 991 | web_ui()->RegisterMessageCallback(kSetApnMessage, |
| 992 | base::Bind(&InternetOptionsHandler::SetApnCallback, |
| 993 | base::Unretained(this))); |
| 994 | web_ui()->RegisterMessageCallback(kSetCarrierMessage, |
| 995 | base::Bind(&InternetOptionsHandler::SetCarrierCallback, |
| 996 | base::Unretained(this))); |
| 997 | web_ui()->RegisterMessageCallback(kSetSimCardLockMessage, |
| 998 | base::Bind(&InternetOptionsHandler::SetSimCardLockCallback, |
| 999 | base::Unretained(this))); |
| 1000 | web_ui()->RegisterMessageCallback(kChangePinMessage, |
| 1001 | base::Bind(&InternetOptionsHandler::ChangePinCallback, |
| 1002 | base::Unretained(this))); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1003 | web_ui()->RegisterMessageCallback(kSetServerHostname, |
| 1004 | base::Bind(&InternetOptionsHandler::SetServerHostnameCallback, |
| 1005 | base::Unretained(this))); |
| 1006 | } |
| 1007 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1008 | void InternetOptionsHandler::EnableWifiCallback(const base::ListValue* args) { |
| 1009 | NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( |
| 1010 | flimflam::kTypeWifi, true, |
| 1011 | base::Bind(&ShillError, "EnableWifiCallback")); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1014 | void InternetOptionsHandler::DisableWifiCallback(const base::ListValue* args) { |
| 1015 | NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( |
| 1016 | flimflam::kTypeWifi, false, |
| 1017 | base::Bind(&ShillError, "DisableWifiCallback")); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1018 | } |
| 1019 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1020 | void InternetOptionsHandler::EnableCellularCallback( |
| 1021 | const base::ListValue* args) { |
| 1022 | NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
Ben Murdoch | 58e6fbe | 2013-07-26 10:20:38 +0100 | [diff] [blame] | 1023 | const DeviceState* device = |
| 1024 | handler->GetDeviceStateByType(flimflam::kTypeCellular); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1025 | if (!device) { |
| 1026 | LOG(ERROR) << "Mobile device not found."; |
| 1027 | return; |
| 1028 | } |
| 1029 | if (!device->sim_lock_type().empty()) { |
| 1030 | SimDialogDelegate::ShowDialog(GetNativeWindow(), |
| 1031 | SimDialogDelegate::SIM_DIALOG_UNLOCK); |
| 1032 | return; |
| 1033 | } |
Ben Murdoch | 58e6fbe | 2013-07-26 10:20:38 +0100 | [diff] [blame] | 1034 | if (!handler->IsTechnologyEnabled(flimflam::kTypeCellular)) { |
| 1035 | handler->SetTechnologyEnabled( |
| 1036 | flimflam::kTypeCellular, true, |
| 1037 | base::Bind(&ShillError, "EnableCellularCallback")); |
| 1038 | return; |
| 1039 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1040 | if (device->IsSimAbsent()) { |
| 1041 | MobileConfig* config = MobileConfig::GetInstance(); |
| 1042 | if (config->IsReady()) { |
| 1043 | const MobileConfig::LocaleConfig* locale_config = |
| 1044 | config->GetLocaleConfig(); |
| 1045 | if (locale_config) { |
| 1046 | std::string setup_url = locale_config->setup_url(); |
| 1047 | if (!setup_url.empty()) { |
| 1048 | chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(setup_url)); |
| 1049 | return; |
| 1050 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1051 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1052 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1053 | // TODO(nkostylev): Show generic error message. http://crosbug.com/15444 |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1054 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1055 | LOG(ERROR) << "EnableCellularCallback called for enabled mobile device"; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1056 | } |
| 1057 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1058 | void InternetOptionsHandler::DisableCellularCallback( |
| 1059 | const base::ListValue* args) { |
| 1060 | NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( |
| 1061 | NetworkStateHandler::kMatchTypeMobile, false, |
| 1062 | base::Bind(&ShillError, "DisableCellularCallback")); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1063 | } |
| 1064 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1065 | void InternetOptionsHandler::EnableWimaxCallback(const base::ListValue* args) { |
| 1066 | NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( |
| 1067 | flimflam::kTypeWimax, true, |
| 1068 | base::Bind(&ShillError, "EnableWimaxCallback")); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1069 | } |
| 1070 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1071 | void InternetOptionsHandler::DisableWimaxCallback(const base::ListValue* args) { |
| 1072 | NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( |
| 1073 | flimflam::kTypeWimax, false, |
| 1074 | base::Bind(&ShillError, "DisableWimaxCallback")); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1075 | } |
| 1076 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1077 | void InternetOptionsHandler::ShowMorePlanInfoCallback( |
| 1078 | const base::ListValue* args) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1079 | if (!web_ui()) |
| 1080 | return; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1081 | std::string service_path; |
| 1082 | if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { |
| 1083 | NOTREACHED(); |
| 1084 | return; |
| 1085 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1086 | network_connect::ShowMobileSetup(service_path); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1087 | } |
| 1088 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1089 | void InternetOptionsHandler::BuyDataPlanCallback(const base::ListValue* args) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1090 | if (!web_ui()) |
| 1091 | return; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1092 | std::string service_path; |
| 1093 | if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { |
| 1094 | NOTREACHED(); |
| 1095 | return; |
| 1096 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1097 | network_connect::ShowMobileSetup(service_path); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1098 | } |
| 1099 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1100 | void InternetOptionsHandler::SetApnCallback(const base::ListValue* args) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1101 | std::string service_path; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1102 | if (!args->GetString(0, &service_path)) { |
| 1103 | NOTREACHED(); |
| 1104 | return; |
| 1105 | } |
| 1106 | NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| 1107 | service_path, |
| 1108 | base::Bind(&InternetOptionsHandler::SetApnProperties, |
| 1109 | weak_factory_.GetWeakPtr(), base::Owned(args->DeepCopy())), |
| 1110 | base::Bind(&ShillError, "SetApnCallback")); |
| 1111 | } |
| 1112 | |
| 1113 | void InternetOptionsHandler::SetApnProperties( |
| 1114 | const base::ListValue* args, |
| 1115 | const std::string& service_path, |
| 1116 | const base::DictionaryValue& shill_properties) { |
| 1117 | std::string apn, username, password; |
| 1118 | if (!args->GetString(1, &apn) || |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1119 | !args->GetString(2, &username) || |
| 1120 | !args->GetString(3, &password)) { |
| 1121 | NOTREACHED(); |
| 1122 | return; |
| 1123 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1124 | NET_LOG_EVENT("SetApnCallback", service_path); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1125 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1126 | if (apn.empty()) { |
| 1127 | std::vector<std::string> properties_to_clear; |
| 1128 | properties_to_clear.push_back(flimflam::kCellularApnProperty); |
| 1129 | NetworkHandler::Get()->network_configuration_handler()->ClearProperties( |
| 1130 | service_path, properties_to_clear, |
| 1131 | base::Bind(&base::DoNothing), |
| 1132 | base::Bind(&ShillError, "ClearCellularApnProperties")); |
| 1133 | return; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1134 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1135 | |
| 1136 | const base::DictionaryValue* shill_apn_dict = NULL; |
| 1137 | std::string network_id; |
| 1138 | if (shill_properties.GetDictionaryWithoutPathExpansion( |
| 1139 | flimflam::kCellularApnProperty, &shill_apn_dict)) { |
| 1140 | shill_apn_dict->GetStringWithoutPathExpansion( |
| 1141 | flimflam::kApnNetworkIdProperty, &network_id); |
| 1142 | } |
| 1143 | base::DictionaryValue properties; |
| 1144 | base::DictionaryValue* apn_dict = new base::DictionaryValue; |
| 1145 | apn_dict->SetStringWithoutPathExpansion(flimflam::kApnProperty, apn); |
| 1146 | apn_dict->SetStringWithoutPathExpansion(flimflam::kApnNetworkIdProperty, |
| 1147 | network_id); |
| 1148 | apn_dict->SetStringWithoutPathExpansion(flimflam::kApnUsernameProperty, |
| 1149 | username); |
| 1150 | apn_dict->SetStringWithoutPathExpansion(flimflam::kApnPasswordProperty, |
| 1151 | password); |
| 1152 | properties.SetWithoutPathExpansion(flimflam::kCellularApnProperty, apn_dict); |
| 1153 | NetworkHandler::Get()->network_configuration_handler()->SetProperties( |
| 1154 | service_path, properties, |
| 1155 | base::Bind(&base::DoNothing), |
| 1156 | base::Bind(&ShillError, "SetApnProperties")); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1157 | } |
| 1158 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1159 | void InternetOptionsHandler::CarrierStatusCallback() { |
| 1160 | NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
| 1161 | const DeviceState* device = |
| 1162 | handler->GetDeviceStateByType(flimflam::kTypeCellular); |
| 1163 | if (device && (device->carrier() == shill::kCarrierSprint)) { |
| 1164 | const NetworkState* network = |
| 1165 | handler->FirstNetworkByType(flimflam::kTypeCellular); |
| 1166 | if (network) { |
| 1167 | chromeos::network_connect::ActivateCellular(network->path()); |
| 1168 | UpdateConnectionData(network->path()); |
| 1169 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1170 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1171 | UpdateCarrier(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1172 | } |
| 1173 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1174 | void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1175 | std::string service_path; |
| 1176 | std::string carrier; |
| 1177 | if (args->GetSize() != 2 || |
| 1178 | !args->GetString(0, &service_path) || |
| 1179 | !args->GetString(1, &carrier)) { |
| 1180 | NOTREACHED(); |
| 1181 | return; |
| 1182 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1183 | const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> |
| 1184 | GetDeviceStateByType(flimflam::kTypeCellular); |
| 1185 | if (!device) { |
| 1186 | LOG(WARNING) << "SetCarrierCallback with no cellular device."; |
| 1187 | return; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1188 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1189 | NetworkHandler::Get()->network_device_handler()->SetCarrier( |
| 1190 | device->path(), |
| 1191 | carrier, |
| 1192 | base::Bind(&InternetOptionsHandler::CarrierStatusCallback, |
| 1193 | weak_factory_.GetWeakPtr()), |
| 1194 | base::Bind(&ShillError, "SetCarrierCallback")); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1195 | } |
| 1196 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1197 | void InternetOptionsHandler::SetSimCardLockCallback( |
| 1198 | const base::ListValue* args) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1199 | bool require_pin_new_value; |
| 1200 | if (!args->GetBoolean(0, &require_pin_new_value)) { |
| 1201 | NOTREACHED(); |
| 1202 | return; |
| 1203 | } |
| 1204 | // 1. Bring up SIM unlock dialog, pass new RequirePin setting in URL. |
| 1205 | // 2. Dialog will ask for current PIN in any case. |
| 1206 | // 3. If card is locked it will first call PIN unlock operation |
| 1207 | // 4. Then it will call Set RequirePin, passing the same PIN. |
| 1208 | // 5. We'll get notified by REQUIRE_PIN_SETTING_CHANGE_ENDED notification. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1209 | SimDialogDelegate::SimDialogMode mode; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1210 | if (require_pin_new_value) |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1211 | mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1212 | else |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1213 | mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF; |
| 1214 | SimDialogDelegate::ShowDialog(GetNativeWindow(), mode); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1215 | } |
| 1216 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1217 | void InternetOptionsHandler::ChangePinCallback(const base::ListValue* args) { |
| 1218 | SimDialogDelegate::ShowDialog(GetNativeWindow(), |
| 1219 | SimDialogDelegate::SIM_DIALOG_CHANGE_PIN); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1220 | } |
| 1221 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1222 | void InternetOptionsHandler::RefreshNetworksCallback( |
| 1223 | const base::ListValue* args) { |
| 1224 | NetworkHandler::Get()->network_state_handler()->RequestScan(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1225 | } |
| 1226 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1227 | std::string InternetOptionsHandler::GetIconDataUrl(int resource_id) const { |
| 1228 | gfx::ImageSkia* icon = |
| 1229 | ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); |
| 1230 | gfx::ImageSkiaRep image_rep = icon->GetRepresentation( |
| 1231 | web_ui()->GetDeviceScaleFactor()); |
| 1232 | return webui::GetBitmapDataUrl(image_rep.sk_bitmap()); |
| 1233 | } |
| 1234 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1235 | void InternetOptionsHandler::RefreshNetworkData() { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1236 | base::DictionaryValue dictionary; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1237 | FillNetworkInfo(&dictionary); |
| 1238 | web_ui()->CallJavascriptFunction( |
| 1239 | kRefreshNetworkDataFunction, dictionary); |
| 1240 | } |
| 1241 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1242 | void InternetOptionsHandler::UpdateConnectionData( |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1243 | const std::string& service_path) { |
| 1244 | NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| 1245 | service_path, |
| 1246 | base::Bind(&InternetOptionsHandler::UpdateConnectionDataCallback, |
| 1247 | weak_factory_.GetWeakPtr()), |
| 1248 | base::Bind(&ShillError, "UpdateConnectionData")); |
| 1249 | } |
| 1250 | |
| 1251 | void InternetOptionsHandler::UpdateConnectionDataCallback( |
| 1252 | const std::string& service_path, |
| 1253 | const base::DictionaryValue& shill_properties) { |
| 1254 | const NetworkState* network = GetNetworkState(service_path); |
| 1255 | if (!network) |
| 1256 | return; |
| 1257 | base::DictionaryValue dictionary; |
| 1258 | PopulateConnectionDetails(network, shill_properties, &dictionary); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 1259 | web_ui()->CallJavascriptFunction(kUpdateConnectionDataFunction, dictionary); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | void InternetOptionsHandler::UpdateCarrier() { |
| 1263 | web_ui()->CallJavascriptFunction(kUpdateCarrierFunction); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1264 | } |
| 1265 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1266 | void InternetOptionsHandler::NetworkManagerChanged() { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1267 | if (!web_ui()) |
| 1268 | return; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1269 | RefreshNetworkData(); |
| 1270 | } |
| 1271 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1272 | void InternetOptionsHandler::NetworkListChanged() { |
| 1273 | if (!web_ui()) |
| 1274 | return; |
| 1275 | RefreshNetworkData(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1276 | } |
| 1277 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1278 | void InternetOptionsHandler::NetworkPropertiesUpdated( |
| 1279 | const NetworkState* network) { |
| 1280 | if (!web_ui()) |
| 1281 | return; |
| 1282 | RefreshNetworkData(); |
| 1283 | UpdateConnectionData(network->path()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1284 | } |
| 1285 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1286 | void InternetOptionsHandler::Observe( |
| 1287 | int type, |
| 1288 | const content::NotificationSource& source, |
| 1289 | const content::NotificationDetails& details) { |
| 1290 | OptionsPageUIHandler::Observe(type, source, details); |
| 1291 | if (type == chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED) { |
| 1292 | base::FundamentalValue require_pin(*content::Details<bool>(details).ptr()); |
| 1293 | web_ui()->CallJavascriptFunction( |
| 1294 | kUpdateSecurityTabFunction, require_pin); |
| 1295 | } else if (type == chrome::NOTIFICATION_ENTER_PIN_ENDED) { |
| 1296 | // We make an assumption (which is valid for now) that the SIM |
| 1297 | // unlock dialog is put up only when the user is trying to enable |
| 1298 | // mobile data. |
| 1299 | bool cancelled = *content::Details<bool>(details).ptr(); |
| 1300 | if (cancelled) |
| 1301 | RefreshNetworkData(); |
| 1302 | // The case in which the correct PIN was entered and the SIM is |
| 1303 | // now unlocked is handled in NetworkMenuButton. |
| 1304 | } |
| 1305 | } |
| 1306 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1307 | void InternetOptionsHandler::SetServerHostnameCallback( |
| 1308 | const base::ListValue* args) { |
| 1309 | std::string service_path, server_hostname; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1310 | if (args->GetSize() < 2 || |
| 1311 | !args->GetString(0, &service_path) || |
| 1312 | !args->GetString(1, &server_hostname)) { |
| 1313 | NOTREACHED(); |
| 1314 | return; |
| 1315 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1316 | SetNetworkProperty(service_path, flimflam::kProviderHostProperty, |
| 1317 | base::Value::CreateStringValue(server_hostname)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1318 | } |
| 1319 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1320 | void InternetOptionsHandler::SetPreferNetworkCallback( |
| 1321 | const base::ListValue* args) { |
| 1322 | std::string service_path, prefer_network_str; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1323 | if (args->GetSize() < 2 || |
| 1324 | !args->GetString(0, &service_path) || |
| 1325 | !args->GetString(1, &prefer_network_str)) { |
| 1326 | NOTREACHED(); |
| 1327 | return; |
| 1328 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1329 | int priority = (prefer_network_str == kTagTrue) ? kPreferredPriority : 0; |
| 1330 | SetNetworkProperty(service_path, flimflam::kPriorityProperty, |
| 1331 | base::Value::CreateIntegerValue(priority)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1332 | } |
| 1333 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1334 | void InternetOptionsHandler::SetAutoConnectCallback( |
| 1335 | const base::ListValue* args) { |
| 1336 | std::string service_path, auto_connect_str; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1337 | if (args->GetSize() < 2 || |
| 1338 | !args->GetString(0, &service_path) || |
| 1339 | !args->GetString(1, &auto_connect_str)) { |
| 1340 | NOTREACHED(); |
| 1341 | return; |
| 1342 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1343 | bool auto_connect = auto_connect_str == kTagTrue; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1344 | SetNetworkProperty(service_path, flimflam::kAutoConnectProperty, |
| 1345 | base::Value::CreateBooleanValue(auto_connect)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1346 | } |
| 1347 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1348 | void InternetOptionsHandler::SetIPConfigCallback(const base::ListValue* args) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1349 | std::string service_path; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1350 | if (!args->GetString(0, &service_path)) { |
| 1351 | NOTREACHED(); |
| 1352 | return; |
| 1353 | } |
| 1354 | NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| 1355 | service_path, |
| 1356 | base::Bind(&InternetOptionsHandler::SetIPConfigProperties, |
| 1357 | weak_factory_.GetWeakPtr(), base::Owned(args->DeepCopy())), |
| 1358 | base::Bind(&ShillError, "SetIPConfigCallback")); |
| 1359 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1360 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1361 | void InternetOptionsHandler::SetIPConfigProperties( |
| 1362 | const base::ListValue* args, |
| 1363 | const std::string& service_path, |
| 1364 | const base::DictionaryValue& shill_properties) { |
| 1365 | std::string address, netmask, gateway, name_server_type, name_servers; |
| 1366 | bool dhcp_for_ip; |
| 1367 | if (!args->GetBoolean(1, &dhcp_for_ip) || |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1368 | !args->GetString(2, &address) || |
| 1369 | !args->GetString(3, &netmask) || |
| 1370 | !args->GetString(4, &gateway) || |
| 1371 | !args->GetString(5, &name_server_type) || |
| 1372 | !args->GetString(6, &name_servers)) { |
| 1373 | NOTREACHED(); |
| 1374 | return; |
| 1375 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1376 | NET_LOG_EVENT("SetIPConfigProperties", service_path); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1377 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1378 | std::vector<std::string> properties_to_clear; |
| 1379 | base::DictionaryValue properties_to_set; |
| 1380 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1381 | if (dhcp_for_ip) { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1382 | AppendPropertyKeyIfPresent(shill::kStaticIPAddressProperty, |
| 1383 | shill_properties, &properties_to_clear); |
| 1384 | AppendPropertyKeyIfPresent(shill::kStaticIPPrefixlenProperty, |
| 1385 | shill_properties, &properties_to_clear); |
| 1386 | AppendPropertyKeyIfPresent(shill::kStaticIPGatewayProperty, |
| 1387 | shill_properties, &properties_to_clear); |
| 1388 | } else { |
| 1389 | AddStringPropertyIfChanged( |
| 1390 | shill::kStaticIPAddressProperty, |
| 1391 | address, shill_properties, &properties_to_set); |
| 1392 | int prefixlen = network_util::NetmaskToPrefixLength(netmask); |
| 1393 | if (prefixlen > 0) { |
| 1394 | LOG(ERROR) << "Invalid prefix length for: " << service_path; |
| 1395 | prefixlen = 0; |
| 1396 | } |
| 1397 | AddIntegerPropertyIfChanged( |
| 1398 | shill::kStaticIPPrefixlenProperty, |
| 1399 | prefixlen, shill_properties, &properties_to_set); |
| 1400 | AddStringPropertyIfChanged( |
| 1401 | shill::kStaticIPGatewayProperty, |
| 1402 | gateway, shill_properties, &properties_to_set); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1403 | } |
| 1404 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1405 | if (name_server_type == kNameServerTypeAutomatic) { |
| 1406 | AppendPropertyKeyIfPresent(shill::kStaticIPNameServersProperty, |
| 1407 | shill_properties, &properties_to_clear); |
| 1408 | } else { |
| 1409 | if (name_server_type == kNameServerTypeGoogle) |
| 1410 | name_servers = kGoogleNameServers; |
| 1411 | AddStringPropertyIfChanged( |
| 1412 | shill::kStaticIPNameServersProperty, |
| 1413 | name_servers, shill_properties, &properties_to_set); |
| 1414 | } |
| 1415 | |
| 1416 | if (!properties_to_clear.empty()) { |
| 1417 | NetworkHandler::Get()->network_configuration_handler()->ClearProperties( |
| 1418 | service_path, properties_to_clear, |
| 1419 | base::Bind(&base::DoNothing), |
| 1420 | base::Bind(&ShillError, "ClearIPConfigProperties")); |
| 1421 | } |
| 1422 | if (!properties_to_set.empty()) { |
| 1423 | NetworkHandler::Get()->network_configuration_handler()->SetProperties( |
| 1424 | service_path, properties_to_set, |
| 1425 | base::Bind(&base::DoNothing), |
| 1426 | base::Bind(&ShillError, "SetIPConfigProperties")); |
| 1427 | } |
| 1428 | std::string device_path; |
| 1429 | shill_properties.GetStringWithoutPathExpansion( |
| 1430 | flimflam::kDeviceProperty, &device_path); |
| 1431 | if (!device_path.empty()) { |
| 1432 | // TODO(stevenjb): Enable this once 18873007 has landed. |
| 1433 | // NetworkHandler::Get()->network_device_handler()->RequestRefreshIPConfigs( |
| 1434 | // device_path); |
| 1435 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1436 | } |
| 1437 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1438 | void InternetOptionsHandler::PopulateDictionaryDetailsCallback( |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1439 | const std::string& service_path, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1440 | const base::DictionaryValue& shill_properties) { |
| 1441 | const NetworkState* network = GetNetworkState(service_path); |
| 1442 | if (!network) { |
| 1443 | LOG(ERROR) << "Network properties not found: " << service_path; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1444 | return; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 1445 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1446 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 1447 | onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
| 1448 | const base::DictionaryValue* onc = |
| 1449 | FindPolicyForActiveUser(network, &onc_source); |
| 1450 | const NetworkPropertyUIData property_ui_data(onc_source); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1451 | |
| 1452 | base::DictionaryValue dictionary; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1453 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1454 | // Device hardware address |
| 1455 | const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> |
| 1456 | GetDeviceState(network->device_path()); |
| 1457 | if (device) |
| 1458 | dictionary.SetString(kTagHardwareAddress, device->mac_address()); |
| 1459 | |
| 1460 | // IP config |
| 1461 | scoped_ptr<base::DictionaryValue> ipconfig_dhcp(new base::DictionaryValue); |
| 1462 | ipconfig_dhcp->SetString(kIpConfigAddress, network->ip_address()); |
| 1463 | ipconfig_dhcp->SetString(kIpConfigNetmask, network->GetNetmask()); |
| 1464 | ipconfig_dhcp->SetString(kIpConfigGateway, network->gateway()); |
| 1465 | std::string ipconfig_name_servers = network->GetDnsServersAsString(); |
| 1466 | ipconfig_dhcp->SetString(kIpConfigNameServers, ipconfig_name_servers); |
| 1467 | SetValueDictionary(&dictionary, |
| 1468 | kDictionaryIpConfig, |
| 1469 | ipconfig_dhcp.release(), |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1470 | property_ui_data); |
| 1471 | |
| 1472 | std::string name_server_type = kNameServerTypeAutomatic; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1473 | int automatic_ip_config = 0; |
| 1474 | scoped_ptr<base::DictionaryValue> static_ip_dict( |
| 1475 | BuildIPInfoDictionary(shill_properties, true, &automatic_ip_config)); |
| 1476 | dictionary.SetBoolean(kIpConfigAutoConfig, automatic_ip_config == 0); |
| 1477 | DCHECK(automatic_ip_config == 3 || automatic_ip_config == 0) |
| 1478 | << "UI doesn't support automatic specification of individual " |
| 1479 | << "static IP parameters."; |
| 1480 | scoped_ptr<base::DictionaryValue> saved_ip_dict( |
| 1481 | BuildIPInfoDictionary(shill_properties, false, NULL)); |
| 1482 | dictionary.Set(kDictionarySavedIp, saved_ip_dict.release()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1483 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1484 | // Determine what kind of name server setting we have by comparing the |
| 1485 | // StaticIP and Google values with the ipconfig values. |
| 1486 | std::string static_ip_nameservers; |
| 1487 | static_ip_dict->GetString(kIpConfigNameServers, &static_ip_nameservers); |
| 1488 | if (!static_ip_nameservers.empty() && |
| 1489 | static_ip_nameservers == ipconfig_name_servers) { |
| 1490 | name_server_type = kNameServerTypeUser; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1491 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1492 | if (ipconfig_name_servers == kGoogleNameServers) { |
| 1493 | name_server_type = kNameServerTypeGoogle; |
| 1494 | } |
| 1495 | SetValueDictionary(&dictionary, |
| 1496 | kDictionaryStaticIp, |
| 1497 | static_ip_dict.release(), |
| 1498 | property_ui_data); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1499 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1500 | std::string type = network->type(); |
| 1501 | dictionary.SetString(kTagType, type); |
| 1502 | dictionary.SetString(kTagServicePath, network->path()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1503 | dictionary.SetString(kTagNameServerType, name_server_type); |
| 1504 | dictionary.SetString(kTagNameServersGoogle, kGoogleNameServers); |
| 1505 | |
| 1506 | // Only show proxy for remembered networks. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1507 | dictionary.SetBoolean(kTagShowProxy, !network->profile_path().empty()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1508 | |
| 1509 | // Enable static ip config for ethernet. For wifi, enable if flag is set. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1510 | bool staticIPConfig = type == flimflam::kTypeEthernet || |
| 1511 | (type == flimflam::kTypeWifi && |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1512 | CommandLine::ForCurrentProcess()->HasSwitch( |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 1513 | chromeos::switches::kEnableStaticIPConfig)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1514 | dictionary.SetBoolean(kTagShowStaticIPConfig, staticIPConfig); |
| 1515 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1516 | dictionary.SetBoolean(kTagShowPreferred, !network->profile_path().empty()); |
| 1517 | bool preferred = network->priority() > 0; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1518 | SetValueDictionary(&dictionary, kTagPreferred, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1519 | new base::FundamentalValue(preferred), |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1520 | property_ui_data); |
| 1521 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 1522 | NetworkPropertyUIData auto_connect_ui_data(onc_source); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1523 | std::string onc_path_to_auto_connect; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1524 | if (type == flimflam::kTypeWifi) { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1525 | onc_path_to_auto_connect = base::StringPrintf( |
| 1526 | "%s.%s", |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1527 | onc::network_config::kWiFi, |
| 1528 | onc::wifi::kAutoConnect); |
| 1529 | } else if (type == flimflam::kTypeVPN) { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1530 | onc_path_to_auto_connect = base::StringPrintf( |
| 1531 | "%s.%s", |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1532 | onc::network_config::kVPN, |
| 1533 | onc::vpn::kAutoConnect); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1534 | } |
| 1535 | if (!onc_path_to_auto_connect.empty()) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1536 | auto_connect_ui_data.ParseOncProperty( |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 1537 | onc_source, onc, onc_path_to_auto_connect); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1538 | } |
| 1539 | SetValueDictionary(&dictionary, kTagAutoConnect, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1540 | new base::FundamentalValue(network->auto_connect()), |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1541 | auto_connect_ui_data); |
| 1542 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1543 | PopulateConnectionDetails(network, shill_properties, &dictionary); |
| 1544 | |
| 1545 | // Show details dialog |
| 1546 | web_ui()->CallJavascriptFunction(kShowDetailedInfoFunction, dictionary); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1547 | } |
| 1548 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1549 | namespace { |
| 1550 | |
| 1551 | void PopulateConnectionDetails(const NetworkState* network, |
| 1552 | const base::DictionaryValue& shill_properties, |
| 1553 | base::DictionaryValue* dictionary) { |
| 1554 | dictionary->SetString(kNetworkInfoKeyServicePath, network->path()); |
| 1555 | dictionary->SetString(kTagServiceName, network->name()); |
| 1556 | dictionary->SetBoolean(kTagConnecting, network->IsConnectingState()); |
| 1557 | dictionary->SetBoolean(kTagConnected, network->IsConnectedState()); |
| 1558 | dictionary->SetString(kTagConnectionState, |
| 1559 | ConnectionStateString(network->connection_state())); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1560 | dictionary->SetString(kTagNetworkName, network->name()); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1561 | dictionary->SetString(kTagErrorState, |
| 1562 | ash::network_connect::ErrorString(network->error())); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1563 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1564 | dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty()); |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 1565 | bool shared = !network->IsPrivate(); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1566 | dictionary->SetBoolean(kTagShared, shared); |
| 1567 | |
| 1568 | const std::string& type = network->type(); |
| 1569 | const NetworkState* connected_network = |
| 1570 | NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( |
| 1571 | type); |
| 1572 | |
| 1573 | dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL); |
| 1574 | |
| 1575 | if (type == flimflam::kTypeWifi) |
| 1576 | PopulateWifiDetails(network, shill_properties, dictionary); |
| 1577 | else if (type == flimflam::kTypeWimax) |
| 1578 | PopulateWimaxDetails(network, shill_properties, dictionary); |
| 1579 | else if (type == flimflam::kTypeCellular) |
| 1580 | PopulateCellularDetails(network, shill_properties, dictionary); |
| 1581 | else if (type == flimflam::kTypeVPN) |
| 1582 | PopulateVPNDetails(network, shill_properties, dictionary); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1583 | } |
| 1584 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1585 | void PopulateWifiDetails(const NetworkState* wifi, |
| 1586 | const base::DictionaryValue& shill_properties, |
| 1587 | base::DictionaryValue* dictionary) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1588 | dictionary->SetString(kTagSsid, wifi->name()); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1589 | dictionary->SetInteger(kTagStrength, wifi->signal_strength()); |
| 1590 | |
| 1591 | std::string security, eap_method; |
| 1592 | shill_properties.GetStringWithoutPathExpansion( |
| 1593 | flimflam::kSecurityProperty, &security); |
| 1594 | shill_properties.GetStringWithoutPathExpansion( |
| 1595 | flimflam::kEapMethodProperty, &eap_method); |
| 1596 | dictionary->SetString(kTagEncryption, EncryptionString(security, eap_method)); |
| 1597 | CopyStringFromDictionary(shill_properties, flimflam::kWifiBSsid, |
| 1598 | kTagBssid, dictionary); |
| 1599 | CopyIntegerFromDictionary(shill_properties, flimflam::kWifiFrequency, |
| 1600 | kTagFrequency, false, dictionary); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1601 | } |
| 1602 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1603 | void PopulateWimaxDetails(const NetworkState* wimax, |
| 1604 | const base::DictionaryValue& shill_properties, |
| 1605 | base::DictionaryValue* dictionary) { |
| 1606 | dictionary->SetInteger(kTagStrength, wimax->signal_strength()); |
| 1607 | CopyStringFromDictionary(shill_properties, flimflam::kEapIdentityProperty, |
| 1608 | kTagIdentity, dictionary); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1609 | } |
| 1610 | |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1611 | void CreateDictionaryFromCellularApn(const base::DictionaryValue* apn, |
| 1612 | base::DictionaryValue* dictionary) { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1613 | CopyStringFromDictionary(*apn, flimflam::kApnProperty, |
| 1614 | kTagApn, dictionary); |
| 1615 | CopyStringFromDictionary(*apn, flimflam::kApnNetworkIdProperty, |
| 1616 | kTagNetworkId, dictionary); |
| 1617 | CopyStringFromDictionary(*apn, flimflam::kApnUsernameProperty, |
| 1618 | kTagUsername, dictionary); |
| 1619 | CopyStringFromDictionary(*apn, flimflam::kApnPasswordProperty, |
| 1620 | kTagPassword, dictionary); |
| 1621 | CopyStringFromDictionary(*apn, flimflam::kApnNameProperty, |
| 1622 | kTagName, dictionary); |
| 1623 | CopyStringFromDictionary(*apn, flimflam::kApnLocalizedNameProperty, |
| 1624 | kTagLocalizedName, dictionary); |
| 1625 | CopyStringFromDictionary(*apn, flimflam::kApnLanguageProperty, |
| 1626 | kTagLanguage, dictionary); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1627 | } |
| 1628 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1629 | void PopulateCellularDetails(const NetworkState* cellular, |
| 1630 | const base::DictionaryValue& shill_properties, |
| 1631 | base::DictionaryValue* dictionary) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1632 | dictionary->SetBoolean(kTagCarrierSelectFlag, |
| 1633 | CommandLine::ForCurrentProcess()->HasSwitch( |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 1634 | chromeos::switches::kEnableCarrierSwitching)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1635 | // Cellular network / connection settings. |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 1636 | dictionary->SetString(kTagNetworkTechnology, cellular->network_technology()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1637 | dictionary->SetString(kTagActivationState, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1638 | ActivationStateString(cellular->activation_state())); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1639 | dictionary->SetString(kTagRoamingState, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1640 | RoamingStateString(cellular->roaming())); |
| 1641 | bool restricted = cellular->connection_state() == flimflam::kStatePortal; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1642 | dictionary->SetString(kTagRestrictedPool, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1643 | restricted ? |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1644 | l10n_util::GetStringUTF8( |
| 1645 | IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL) : |
| 1646 | l10n_util::GetStringUTF8( |
| 1647 | IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)); |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 1648 | |
| 1649 | const base::DictionaryValue* serving_operator = NULL; |
| 1650 | if (shill_properties.GetDictionaryWithoutPathExpansion( |
| 1651 | flimflam::kServingOperatorProperty, &serving_operator)) { |
| 1652 | CopyStringFromDictionary(*serving_operator, flimflam::kOperatorNameKey, |
| 1653 | kTagOperatorName, dictionary); |
| 1654 | CopyStringFromDictionary(*serving_operator, flimflam::kOperatorCodeKey, |
| 1655 | kTagOperatorCode, dictionary); |
| 1656 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1657 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1658 | const base::DictionaryValue* olp = NULL; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1659 | if (shill_properties.GetDictionaryWithoutPathExpansion( |
| 1660 | flimflam::kPaymentPortalProperty, &olp)) { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1661 | std::string url; |
| 1662 | olp->GetStringWithoutPathExpansion(flimflam::kPaymentPortalURL, &url); |
| 1663 | dictionary->SetString(kTagSupportUrl, url); |
| 1664 | } |
| 1665 | |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1666 | base::DictionaryValue* apn = new base::DictionaryValue; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1667 | const base::DictionaryValue* source_apn = NULL; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1668 | if (shill_properties.GetDictionaryWithoutPathExpansion( |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1669 | flimflam::kCellularApnProperty, &source_apn)) { |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1670 | CreateDictionaryFromCellularApn(source_apn, apn); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1671 | } |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1672 | dictionary->Set(kTagApn, apn); |
| 1673 | |
| 1674 | base::DictionaryValue* last_good_apn = new base::DictionaryValue; |
| 1675 | if (shill_properties.GetDictionaryWithoutPathExpansion( |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1676 | flimflam::kCellularLastGoodApnProperty, &source_apn)) { |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1677 | CreateDictionaryFromCellularApn(source_apn, last_good_apn); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1678 | } |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1679 | dictionary->Set(kTagLastGoodApn, last_good_apn); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1680 | |
| 1681 | // These default to empty and are only set if device != NULL. |
| 1682 | std::string carrier_id; |
| 1683 | std::string mdn; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1684 | |
| 1685 | // Device settings. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1686 | const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> |
| 1687 | GetDeviceState(cellular->device_path()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1688 | if (device) { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1689 | // TODO(stevenjb): Add NetworkDeviceHandler::GetProperties() and use that |
| 1690 | // to retrieve the complete dictionary of device properties, instead of |
| 1691 | // caching them (will be done for the new UI). |
| 1692 | const base::DictionaryValue& device_properties = device->properties(); |
| 1693 | const NetworkPropertyUIData cellular_property_ui_data( |
| 1694 | cellular->onc_source()); |
| 1695 | CopyStringFromDictionary(device_properties, flimflam::kManufacturerProperty, |
| 1696 | kTagManufacturer, dictionary); |
| 1697 | CopyStringFromDictionary(device_properties, flimflam::kModelIDProperty, |
| 1698 | kTagModelId, dictionary); |
| 1699 | CopyStringFromDictionary(device_properties, |
| 1700 | flimflam::kFirmwareRevisionProperty, |
| 1701 | kTagFirmwareRevision, dictionary); |
| 1702 | CopyStringFromDictionary(device_properties, |
| 1703 | flimflam::kHardwareRevisionProperty, |
| 1704 | kTagHardwareRevision, dictionary); |
| 1705 | CopyIntegerFromDictionary(device_properties, flimflam::kPRLVersionProperty, |
| 1706 | kTagPrlVersion, true, dictionary); |
| 1707 | CopyStringFromDictionary(device_properties, flimflam::kMeidProperty, |
| 1708 | kTagMeid, dictionary); |
| 1709 | CopyStringFromDictionary(device_properties, flimflam::kIccidProperty, |
| 1710 | kTagIccid, dictionary); |
| 1711 | CopyStringFromDictionary(device_properties, flimflam::kImeiProperty, |
| 1712 | kTagImei, dictionary); |
| 1713 | mdn = CopyStringFromDictionary(device_properties, flimflam::kMdnProperty, |
| 1714 | kTagMdn, dictionary); |
| 1715 | CopyStringFromDictionary(device_properties, flimflam::kImsiProperty, |
| 1716 | kTagImsi, dictionary); |
| 1717 | CopyStringFromDictionary(device_properties, flimflam::kEsnProperty, |
| 1718 | kTagEsn, dictionary); |
| 1719 | CopyStringFromDictionary(device_properties, flimflam::kMinProperty, |
| 1720 | kTagMin, dictionary); |
| 1721 | std::string family; |
| 1722 | device_properties.GetStringWithoutPathExpansion( |
| 1723 | flimflam::kTechnologyFamilyProperty, &family); |
| 1724 | dictionary->SetBoolean(kTagGsm, family == flimflam::kNetworkTechnologyGsm); |
| 1725 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1726 | SetValueDictionary( |
| 1727 | dictionary, kTagSimCardLockEnabled, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1728 | new base::FundamentalValue(device->sim_lock_enabled()), |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1729 | cellular_property_ui_data); |
| 1730 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1731 | carrier_id = device->home_provider_id(); |
| 1732 | |
| 1733 | MobileConfig* config = MobileConfig::GetInstance(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1734 | if (config->IsReady()) { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1735 | const MobileConfig::Carrier* carrier = config->GetCarrier(carrier_id); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1736 | if (carrier && !carrier->top_up_url().empty()) |
| 1737 | dictionary->SetString(kTagCarrierUrl, carrier->top_up_url()); |
| 1738 | } |
| 1739 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1740 | base::ListValue* apn_list_value = new base::ListValue(); |
| 1741 | const base::ListValue* apn_list; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1742 | if (device_properties.GetListWithoutPathExpansion( |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1743 | flimflam::kCellularApnListProperty, &apn_list)) { |
| 1744 | for (base::ListValue::const_iterator iter = apn_list->begin(); |
| 1745 | iter != apn_list->end(); ++iter) { |
| 1746 | const base::DictionaryValue* dict; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1747 | if ((*iter)->GetAsDictionary(&dict)) { |
| 1748 | base::DictionaryValue* apn = new base::DictionaryValue; |
| 1749 | CreateDictionaryFromCellularApn(dict, apn); |
| 1750 | apn_list_value->Append(apn); |
| 1751 | } |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1752 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1753 | } |
| 1754 | SetValueDictionary(dictionary, kTagProviderApnList, apn_list_value, |
| 1755 | cellular_property_ui_data); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1756 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 1757 | chromeos::switches::kEnableCarrierSwitching)) { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1758 | const base::ListValue* supported_carriers; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 1759 | if (device_properties.GetListWithoutPathExpansion( |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1760 | shill::kSupportedCarriersProperty, &supported_carriers)) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1761 | dictionary->Set(kTagCarriers, supported_carriers->DeepCopy()); |
| 1762 | dictionary->SetInteger(kTagCurrentCarrierIndex, |
| 1763 | FindCurrentCarrierIndex(supported_carriers, |
| 1764 | device)); |
| 1765 | } else { |
| 1766 | // In case of any error, set the current carrier tag to -1 indicating |
| 1767 | // to the JS code to fallback to a single carrier. |
| 1768 | dictionary->SetInteger(kTagCurrentCarrierIndex, -1); |
| 1769 | } |
| 1770 | } |
| 1771 | } |
| 1772 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1773 | // Set Cellular Buttons Visibility |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1774 | dictionary->SetBoolean( |
| 1775 | kTagDisableConnectButton, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1776 | cellular->activation_state() == flimflam::kActivationStateActivating || |
| 1777 | cellular->IsConnectingState()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1778 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1779 | if (cellular->activation_state() != flimflam::kActivationStateActivating && |
| 1780 | cellular->activation_state() != flimflam::kActivationStateActivated) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1781 | dictionary->SetBoolean(kTagShowActivateButton, true); |
| 1782 | } else { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1783 | const MobileConfig::Carrier* carrier = |
| 1784 | MobileConfig::GetInstance()->GetCarrier(carrier_id); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1785 | if (carrier && carrier->show_portal_button()) { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1786 | // The button should be shown for a LTE network even when the LTE network |
| 1787 | // is not connected, but CrOS is online. This is done to enable users to |
| 1788 | // update their plan even if they are out of credits. |
| 1789 | // The button should not be shown when the device's mdn is not set, |
| 1790 | // because the network's proper portal url cannot be generated without it |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1791 | const NetworkState* default_network = |
| 1792 | NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 1793 | const std::string& technology = cellular->network_technology(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1794 | bool force_show_view_account_button = |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 1795 | (technology == flimflam::kNetworkTechnologyLte || |
| 1796 | technology == flimflam::kNetworkTechnologyLteAdvanced) && |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1797 | default_network && |
| 1798 | !mdn.empty(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1799 | |
| 1800 | // The button will trigger ShowMorePlanInfoCallback() which will open |
| 1801 | // carrier specific portal. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1802 | if (cellular->IsConnectedState() || force_show_view_account_button) |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1803 | dictionary->SetBoolean(kTagShowViewAccountButton, true); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1804 | } |
| 1805 | } |
| 1806 | } |
| 1807 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1808 | } // namespace |
| 1809 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1810 | gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 1811 | return web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1812 | } |
| 1813 | |
| 1814 | Browser* InternetOptionsHandler::GetAppropriateBrowser() { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1815 | return chrome::FindOrCreateTabbedBrowser( |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1816 | ProfileManager::GetDefaultProfileOrOffTheRecord(), |
| 1817 | chrome::HOST_DESKTOP_TYPE_ASH); |
| 1818 | } |
| 1819 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1820 | void InternetOptionsHandler::NetworkCommandCallback( |
| 1821 | const base::ListValue* args) { |
| 1822 | std::string type; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1823 | std::string service_path; |
| 1824 | std::string command; |
| 1825 | if (args->GetSize() != 3 || |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1826 | !args->GetString(0, &type) || |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1827 | !args->GetString(1, &service_path) || |
| 1828 | !args->GetString(2, &command)) { |
| 1829 | NOTREACHED(); |
| 1830 | return; |
| 1831 | } |
| 1832 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1833 | // Process commands that do not require an existing network. |
| 1834 | if (command == kTagAddConnection) { |
| 1835 | if (CanAddNetworkType(type)) |
| 1836 | AddConnection(type); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1837 | } else if (command == kTagForget) { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1838 | if (CanForgetNetworkType(type)) { |
| 1839 | NetworkHandler::Get()->network_configuration_handler()-> |
| 1840 | RemoveConfiguration( |
| 1841 | service_path, |
| 1842 | base::Bind(&base::DoNothing), |
| 1843 | base::Bind(&ShillError, "NetworkCommand: " + command)); |
| 1844 | } |
| 1845 | } else if (command == kTagOptions) { |
| 1846 | NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1847 | service_path, |
| 1848 | base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1849 | weak_factory_.GetWeakPtr()), |
| 1850 | base::Bind(&ShillError, "NetworkCommand: " + command)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1851 | } else if (command == kTagConnect) { |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1852 | network_connect::ConnectToNetwork( |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1853 | service_path, GetNativeWindow()); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1854 | } else if (command == kTagDisconnect) { |
| 1855 | NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork( |
| 1856 | service_path, |
| 1857 | base::Bind(&base::DoNothing), |
| 1858 | base::Bind(&ShillError, "NetworkCommand: " + command)); |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 1859 | } else if (command == kTagConfigure) { |
| 1860 | NetworkConfigView::ShowForPath(service_path, GetNativeWindow()); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1861 | } else if (command == kTagActivate && type == flimflam::kTypeCellular) { |
| 1862 | network_connect::ActivateCellular(service_path); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1863 | // Activation may update network properties (e.g. ActivationState), so |
| 1864 | // request them here in case they change. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1865 | UpdateConnectionData(service_path); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1866 | } else { |
| 1867 | VLOG(1) << "Unknown command: " << command; |
| 1868 | NOTREACHED(); |
| 1869 | } |
| 1870 | } |
| 1871 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1872 | void InternetOptionsHandler::AddConnection(const std::string& type) { |
| 1873 | if (type == flimflam::kTypeWifi) |
| 1874 | NetworkConfigView::ShowForType(chromeos::TYPE_WIFI, GetNativeWindow()); |
| 1875 | else if (type == flimflam::kTypeVPN) |
| 1876 | NetworkConfigView::ShowForType(chromeos::TYPE_VPN, GetNativeWindow()); |
| 1877 | else if (type == flimflam::kTypeCellular) |
| 1878 | ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); |
| 1879 | else |
| 1880 | NOTREACHED(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1881 | } |
| 1882 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1883 | base::ListValue* InternetOptionsHandler::GetWiredList() { |
| 1884 | base::ListValue* list = new base::ListValue(); |
| 1885 | const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> |
| 1886 | FirstNetworkByType(flimflam::kTypeEthernet); |
| 1887 | if (!network) |
| 1888 | return list; |
| 1889 | NetworkInfoDictionary network_dict(network, web_ui()->GetDeviceScaleFactor()); |
| 1890 | list->Append(network_dict.BuildDictionary()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1891 | return list; |
| 1892 | } |
| 1893 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1894 | base::ListValue* InternetOptionsHandler::GetWirelessList() { |
| 1895 | base::ListValue* list = new base::ListValue(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1896 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1897 | NetworkStateHandler::NetworkStateList networks; |
| 1898 | NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks); |
| 1899 | for (NetworkStateHandler::NetworkStateList::const_iterator iter = |
| 1900 | networks.begin(); iter != networks.end(); ++iter) { |
| 1901 | const NetworkState* network = *iter; |
| 1902 | if (network->type() != flimflam::kTypeWifi && |
| 1903 | network->type() != flimflam::kTypeWimax && |
| 1904 | network->type() != flimflam::kTypeCellular) |
| 1905 | continue; |
| 1906 | NetworkInfoDictionary network_dict( |
| 1907 | network, web_ui()->GetDeviceScaleFactor()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1908 | list->Append(network_dict.BuildDictionary()); |
| 1909 | } |
| 1910 | |
| 1911 | return list; |
| 1912 | } |
| 1913 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1914 | base::ListValue* InternetOptionsHandler::GetVPNList() { |
| 1915 | base::ListValue* list = new base::ListValue(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1916 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1917 | NetworkStateHandler::NetworkStateList networks; |
| 1918 | NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks); |
| 1919 | for (NetworkStateHandler::NetworkStateList::const_iterator iter = |
| 1920 | networks.begin(); iter != networks.end(); ++iter) { |
| 1921 | const NetworkState* network = *iter; |
| 1922 | if (network->type() != flimflam::kTypeVPN) |
| 1923 | continue; |
| 1924 | NetworkInfoDictionary network_dict( |
| 1925 | network, web_ui()->GetDeviceScaleFactor()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1926 | list->Append(network_dict.BuildDictionary()); |
| 1927 | } |
| 1928 | |
| 1929 | return list; |
| 1930 | } |
| 1931 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1932 | base::ListValue* InternetOptionsHandler::GetRememberedList() { |
| 1933 | base::ListValue* list = new base::ListValue(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1934 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1935 | NetworkStateHandler::FavoriteStateList favorites; |
| 1936 | NetworkHandler::Get()->network_state_handler()->GetFavoriteList(&favorites); |
| 1937 | for (NetworkStateHandler::FavoriteStateList::const_iterator iter = |
| 1938 | favorites.begin(); iter != favorites.end(); ++iter) { |
| 1939 | const FavoriteState* favorite = *iter; |
| 1940 | if (favorite->type() != flimflam::kTypeWifi && |
| 1941 | favorite->type() != flimflam::kTypeVPN) |
| 1942 | continue; |
| 1943 | NetworkInfoDictionary network_dict( |
| 1944 | favorite, web_ui()->GetDeviceScaleFactor()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1945 | list->Append(network_dict.BuildDictionary()); |
| 1946 | } |
| 1947 | |
| 1948 | return list; |
| 1949 | } |
| 1950 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1951 | void InternetOptionsHandler::FillNetworkInfo( |
| 1952 | base::DictionaryValue* dictionary) { |
| 1953 | NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1954 | dictionary->Set(kTagWiredList, GetWiredList()); |
| 1955 | dictionary->Set(kTagWirelessList, GetWirelessList()); |
| 1956 | dictionary->Set(kTagVpnList, GetVPNList()); |
| 1957 | dictionary->Set(kTagRememberedList, GetRememberedList()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1958 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1959 | dictionary->SetBoolean(kTagWifiAvailable, |
| 1960 | handler->IsTechnologyAvailable(flimflam::kTypeWifi)); |
| 1961 | dictionary->SetBoolean(kTagWifiEnabled, |
| 1962 | handler->IsTechnologyEnabled(flimflam::kTypeWifi)); |
| 1963 | |
| 1964 | dictionary->SetBoolean(kTagCellularAvailable, |
| 1965 | handler->IsTechnologyAvailable( |
| 1966 | NetworkStateHandler::kMatchTypeMobile)); |
| 1967 | dictionary->SetBoolean(kTagCellularEnabled, |
| 1968 | handler->IsTechnologyEnabled( |
| 1969 | NetworkStateHandler::kMatchTypeMobile)); |
| 1970 | const DeviceState* cellular = |
| 1971 | handler->GetDeviceStateByType(NetworkStateHandler::kMatchTypeMobile); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1972 | dictionary->SetBoolean( |
| 1973 | kTagCellularSupportsScan, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1974 | cellular && cellular->support_network_scan()); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1975 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1976 | dictionary->SetBoolean(kTagWimaxAvailable, |
| 1977 | handler->IsTechnologyAvailable(flimflam::kTypeWimax)); |
| 1978 | dictionary->SetBoolean(kTagWimaxEnabled, |
| 1979 | handler->IsTechnologyEnabled(flimflam::kTypeWimax)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1980 | } |
| 1981 | |
| 1982 | } // namespace options |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1983 | } // namespace chromeos |