merge b2g-inbound to mozilla-central
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 11 Sep 2013 09:36:35 +0200
changeset 159412 9e9f74116749a2326dc275304871f03d0fd8a034
parent 159405 f9e8e8ce552c866f3ca3212f6c0c4fad9184021c (current diff)
parent 159411 3b8ed705501ae048b3e41b120208f37426d06f29 (diff)
child 159426 5417e5da2cebc0d34ccc05b16be513b5d8a01e55
child 170304 2afdcd19e4052496ca0fa9424beb5ebfde83a045
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone26.0a1
first release with
nightly linux32
9e9f74116749 / 26.0a1 / 20130911030258 / files
nightly linux64
9e9f74116749 / 26.0a1 / 20130911030258 / files
nightly mac
9e9f74116749 / 26.0a1 / 20130911030258 / files
nightly win32
9e9f74116749 / 26.0a1 / 20130911030258 / files
nightly win64
9e9f74116749 / 26.0a1 / 20130911030258 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
merge b2g-inbound to mozilla-central
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,4 +1,4 @@
 {
-    "revision": "3014a433e3b78fa04aacb919c853fa220d309d70", 
+    "revision": "e3d925b497f5b996c9c397c200805fbcc62bc823", 
     "repo_path": "/integration/gaia-central"
 }
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -601,17 +601,17 @@ NetworkManager.prototype = {
       cmd: "setDefaultRouteAndDNS",
       ifname: this.active.name,
       oldIfname: (oldInterface && oldInterface != this.active) ? oldInterface.name : null,
       gateway_str: this.active.gateway,
       dns1_str: this.active.dns1,
       dns2_str: this.active.dns2
     };
     this.worker.postMessage(options);
-    this.setNetworkProxy();
+    this.setNetworkProxy(this.active);
   },
 
   removeDefaultRoute: function removeDefaultRoute(ifname) {
     debug("Remove default route for " + ifname);
     let options = {
       cmd: "removeDefaultRoute",
       ifname: ifname
     }
@@ -684,43 +684,43 @@ NetworkManager.prototype = {
       cmd: "removeHostRoute",
       ifname: network.name,
       gateway: network.gateway,
       hostnames: hosts
     };
     this.worker.postMessage(options);
   },
 
-  setNetworkProxy: function setNetworkProxy() {
+  setNetworkProxy: function setNetworkProxy(network) {
     try {
-      if (!this.active.httpProxyHost || this.active.httpProxyHost == "") {
+      if (!network.httpProxyHost || network.httpProxyHost == "") {
         // Sets direct connection to internet.
         Services.prefs.clearUserPref("network.proxy.type");
         Services.prefs.clearUserPref("network.proxy.share_proxy_settings");
         Services.prefs.clearUserPref("network.proxy.http");
         Services.prefs.clearUserPref("network.proxy.http_port");
         Services.prefs.clearUserPref("network.proxy.ssl");
         Services.prefs.clearUserPref("network.proxy.ssl_port");
-        debug("No proxy support for " + this.active.name + " network interface.");
+        debug("No proxy support for " + network.name + " network interface.");
         return;
       }
 
-      debug("Going to set proxy settings for " + this.active.name + " network interface.");
+      debug("Going to set proxy settings for " + network.name + " network interface.");
       // Sets manual proxy configuration.
       Services.prefs.setIntPref("network.proxy.type", MANUAL_PROXY_CONFIGURATION);
       // Do not use this proxy server for all protocols.
       Services.prefs.setBoolPref("network.proxy.share_proxy_settings", false);
-      Services.prefs.setCharPref("network.proxy.http", this.active.httpProxyHost);
-      Services.prefs.setCharPref("network.proxy.ssl", this.active.httpProxyHost);
-      let port = this.active.httpProxyPort == "" ? 8080 : this.active.httpProxyPort;
+      Services.prefs.setCharPref("network.proxy.http", network.httpProxyHost);
+      Services.prefs.setCharPref("network.proxy.ssl", network.httpProxyHost);
+      let port = network.httpProxyPort == 0 ? 8080 : network.httpProxyPort;
       Services.prefs.setIntPref("network.proxy.http_port", port);
       Services.prefs.setIntPref("network.proxy.ssl_port", port);
     } catch (ex) {
        debug("Exception " + ex + ". Unable to set proxy setting for "
-             + this.active.name + " network interface.");
+             + network.name + " network interface.");
        return;
     }
   },
 
   // nsISettingsServiceCallback
 
   tetheringSettings: {},
 
--- a/dom/system/gonk/nsINetworkManager.idl
+++ b/dom/system/gonk/nsINetworkManager.idl
@@ -114,17 +114,17 @@ interface nsIWifiOperationModeCallback :
    *        or `null` if it was.
    */
   void wifiOperationModeResult(in jsval error);
 };
 
 /**
  * Manage network interfaces.
  */
-[scriptable, uuid(5b22c620-f8b9-11e2-b778-0800200c9a66)]
+[scriptable, uuid(fad3fb08-664f-48e3-bba3-423186988c61)]
 interface nsINetworkManager : nsISupports
 {
   /**
    * Register the given network interface with the network manager.
    *
    * Consumers will be notified with the 'network-interface-registered'
    * observer notification.
    *
@@ -226,9 +226,17 @@ interface nsINetworkManager : nsISupport
    *        AP  - Access pointer mode.
    *        P2P - Peer to peer connection mode.
    *        STA - Station mode.
    *
    * @param callback
    *        Callback to notify Wifi firmware reload result.
    */
   void setWifiOperationMode(in DOMString interfaceName, in DOMString mode, in nsIWifiOperationModeCallback callback);
+
+  /**
+   * Set http proxy for specific network
+   *
+   * @param network
+   *        Network interface to register.
+   */
+  void setNetworkProxy(in nsINetworkInterface network);
 };
--- a/dom/wifi/DOMWifiManager.js
+++ b/dom/wifi/DOMWifiManager.js
@@ -82,16 +82,17 @@ DOMWifiManager.prototype = {
     this._lastConnectionInfo = null;
 
     const messages = ["WifiManager:getNetworks:Return:OK", "WifiManager:getNetworks:Return:NO",
                       "WifiManager:getKnownNetworks:Return:OK", "WifiManager:getKnownNetworks:Return:NO",
                       "WifiManager:associate:Return:OK", "WifiManager:associate:Return:NO",
                       "WifiManager:forget:Return:OK", "WifiManager:forget:Return:NO",
                       "WifiManager:wps:Return:OK", "WifiManager:wps:Return:NO",
                       "WifiManager:setPowerSavingMode:Return:OK", "WifiManager:setPowerSavingMode:Return:NO",
+                      "WifiManager:setHttpProxy:Return:OK", "WifiManager:setHttpProxy:Return:NO",
                       "WifiManager:setStaticIpMode:Return:OK", "WifiManager:setStaticIpMode:Return:NO",
                       "WifiManager:wifiDown", "WifiManager:wifiUp",
                       "WifiManager:onconnecting", "WifiManager:onassociate",
                       "WifiManager:onconnect", "WifiManager:ondisconnect",
                       "WifiManager:onwpstimeout", "WifiManager:onwpsfail",
                       "WifiManager:onwpsoverlap", "WifiManager:connectionInfoUpdate",
                       "WifiManager:onconnectingfailed"];
     this.initDOMRequestHelper(aWindow, messages);
@@ -189,16 +190,26 @@ DOMWifiManager.prototype = {
         Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
         break;
 
       case "WifiManager:setPowerSavingMode:Return:NO":
         request = this.takeRequest(msg.rid);
         Services.DOMRequest.fireError(request, msg.data);
         break;
 
+      case "WifiManager:setHttpProxy:Return:OK":
+        request = this.takeRequest(msg.rid);
+        Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
+        break;
+
+      case "WifiManager:setHttpProxy:Return:NO":
+        request = this.takeRequest(msg.rid);
+        Services.DOMRequest.fireError(request, msg.data);
+        break;
+
       case "WifiManager:setStaticIpMode:Return:OK":
         request = this.takeRequest(msg.rid);
         Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
         break;
 
       case "WifiManager:setStaticIpMode:Return:NO":
         request = this.takeRequest(msg.rid);
         Services.DOMRequest.fireError(request, msg.data);
@@ -355,16 +366,24 @@ DOMWifiManager.prototype = {
   setPowerSavingMode: function nsIDOMWifiManager_setPowerSavingMode(enabled) {
     if (!this._hasPrivileges)
       throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
     var request = this.createRequest();
     this._sendMessageForRequest("WifiManager:setPowerSavingMode", enabled, request);
     return request;
   },
 
+  setHttpProxy: function nsIDOMWifiManager_setHttpProxy(network, info) {
+    if (!this._hasPrivileges)
+      throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
+    var request = this.createRequest();
+    this._sendMessageForRequest("WifiManager:setHttpProxy", {network:network, info:info}, request);
+    return request;
+  },
+
   setStaticIpMode: function nsIDOMWifiManager_setStaticIpMode(network, info) {
     if (!this._hasPrivileges)
       throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
     var request = this.createRequest();
     this._sendMessageForRequest("WifiManager:setStaticIpMode", {network: network,info: info}, request);
     return request;
   },
 
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -642,16 +642,58 @@ var WifiManager = (function() {
   }
 
   function resetConnections(ifname, callback) {
     controlMessage({ cmd: "ifc_reset_connections", ifname: ifname }, function(data) {
       callback(!data.status);
     });
   }
 
+  var httpProxyConfig = Object.create(null);
+
+  /**
+   * Given a network, configure http proxy when using wifi.
+   * @param network A network object to update http proxy
+   * @param info Info should have following field:
+   *        - httpProxyHost ip address of http proxy.
+   *        - httpProxyPort port of http proxy, set 0 to use default port 8080.
+   * @param callback callback function.
+   */
+  function configureHttpProxy(network, info, callback) {
+    if (!network)
+      return;
+
+    let networkKey = getNetworkKey(network);
+
+    if (!info || info.httpProxyHost === "") {
+      delete httpProxyConfig[networkKey];
+    } else {
+      httpProxyConfig[networkKey] = network;
+      httpProxyConfig[networkKey].httpProxyHost = info.httpProxyHost;
+      httpProxyConfig[networkKey].httpProxyPort = info.httpProxyPort;
+    }
+
+    callback(true);
+  }
+
+  function getHttpProxyNetwork(network) {
+    if (!network)
+      return null;
+
+    let networkKey = getNetworkKey(network);
+    return ((networkKey in httpProxyConfig) ? httpProxyConfig : null);
+  }
+
+  function setHttpProxy(network) {
+    if (!network)
+      return;
+
+    gNetworkManager.setNetworkProxy(network);
+  }
+
   var staticIpConfig = Object.create(null);
   function setStaticIpMode(network, info, callback) {
     let setNetworkKey = getNetworkKey(network);
     let curNetworkKey = null;
     let currentNetwork = Object.create(null);
     currentNetwork.netId = manager.connectionInfo.id;
 
     manager.getNetworkConfiguration(currentNetwork, function (){
@@ -1543,16 +1585,19 @@ var WifiManager = (function() {
   manager.setBackgroundScan = setBackgroundScan;
   manager.scan = scanCommand;
   manager.wpsPbc = wpsPbcCommand;
   manager.wpsPin = wpsPinCommand;
   manager.wpsCancel = wpsCancelCommand;
   manager.setPowerMode = (sdkVersion >= 16)
                          ? setPowerModeCommandJB
                          : setPowerModeCommandICS;
+  manager.getHttpProxyNetwork = getHttpProxyNetwork;
+  manager.setHttpProxy = setHttpProxy;
+  manager.configureHttpProxy = configureHttpProxy;
   manager.setSuspendOptimizations = setSuspendOptimizationsCommand;
   manager.setStaticIpMode = setStaticIpMode;
   manager.getRssiApprox = getRssiApproxCommand;
   manager.getLinkSpeed = getLinkSpeedCommand;
   manager.getDhcpInfo = function() { return dhcpInfo; }
   manager.getConnectionInfo = (sdkVersion >= 15)
                               ? getConnectionInfoICS
                               : getConnectionInfoGB;
@@ -1846,16 +1891,17 @@ function WifiWorker() {
   var self = this;
 
   this._mm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
                .getService(Ci.nsIMessageListenerManager);
   const messages = ["WifiManager:getNetworks", "WifiManager:getKnownNetworks",
                     "WifiManager:associate", "WifiManager:forget",
                     "WifiManager:wps", "WifiManager:getState",
                     "WifiManager:setPowerSavingMode",
+                    "WifiManager:setHttpProxy",
                     "WifiManager:setStaticIpMode",
                     "child-process-shutdown"];
 
   messages.forEach((function(msgName) {
     this._mm.addMessageListener(msgName, this);
   }).bind(this));
 
   Services.obs.addObserver(this, kMozSettingsChangedObserverTopic, false);
@@ -2155,16 +2201,21 @@ function WifiWorker() {
           // In this case, we connected to an already-connected wpa_supplicant,
           // because of that we need to gather information about the current
           // network here.
           self.currentNetwork = { ssid: quote(WifiManager.connectionInfo.ssid),
                                   netId: WifiManager.connectionInfo.id };
           WifiManager.getNetworkConfiguration(self.currentNetwork, function(){});
         }
 
+        // Update http proxy when connected to network.
+        let netConnect = WifiManager.getHttpProxyNetwork(self.currentNetwork);
+        if (netConnect)
+          WifiManager.setHttpProxy(netConnect);
+
         // The full authentication process is completed, reset the count.
         WifiManager.authenticationFailuresCount = 0;
         WifiManager.loopDetectionCount = 0;
         self._startConnectionInfoTimer();
         self._fireEvent("onassociate", { network: netToDOM(self.currentNetwork) });
         break;
       case "CONNECTED":
         // BSSID is read after connected, update it.
@@ -2177,16 +2228,33 @@ function WifiWorker() {
           this.prevState === "DISCONNECTED" ||
           this.prevState === "INTERFACE_DISABLED" ||
           this.prevState === "INACTIVE" ||
           this.prevState === "UNINITIALIZED") {
           return;
         }
 
         self._fireEvent("ondisconnect", {});
+
+        // When disconnected, clear the http proxy setting if it exists.
+        // Temporarily set http proxy to empty and restore user setting after setHttpProxy.
+        let netDisconnect = WifiManager.getHttpProxyNetwork(self.currentNetwork);
+        if (netDisconnect) {
+          let prehttpProxyHostSetting = netDisconnect.httpProxyHost;
+          let prehttpProxyPortSetting = netDisconnect.httpProxyPort;
+
+          netDisconnect.httpProxyHost = "";
+          netDisconnect.httpProxyPort = 0;
+
+          WifiManager.setHttpProxy(netDisconnect);
+
+          netDisconnect.httpProxyHost = prehttpProxyHostSetting;
+          netDisconnect.httpProxyPort = prehttpProxyPortSetting;
+        }
+
         self.currentNetwork = null;
         self.ipAddress = "";
 
         if (self._turnOnBackgroundScan) {
           self._turnOnBackgroundScan = false;
           WifiManager.setBackgroundScan("ON", function(did_something, ok) {
             WifiManager.reassociate(function() {});
           });
@@ -2711,16 +2779,19 @@ WifiWorker.prototype = {
         this.forget(msg);
         break;
       case "WifiManager:wps":
         this.wps(msg);
         break;
       case "WifiManager:setPowerSavingMode":
         this.setPowerSavingMode(msg);
         break;
+      case "WifiManager:setHttpProxy":
+        this.setHttpProxy(msg);
+        break;
       case "WifiManager:setStaticIpMode":
         this.setStaticIpMode(msg);
         break;
       case "WifiManager:getState": {
         let i;
         if ((i = this._domManagers.indexOf(msg.manager)) === -1) {
           this._domManagers.push(msg.manager);
         }
@@ -3205,16 +3276,40 @@ WifiWorker.prototype = {
           self._sendMessage(message, true, true, msg);
         } else {
           self._sendMessage(message, false, "Set power saving mode failed", msg);
         }
       });
     });
   },
 
+  setHttpProxy: function(msg) {
+    const message = "WifiManager:setHttpProxy:Return";
+    let self = this;
+    let network = msg.data.network;
+    let info = msg.data.info;
+
+    netFromDOM(network, null);
+
+    WifiManager.configureHttpProxy(network, info, function(ok) {
+      if (ok) {
+        // If configured network is current connected network
+        // need update http proxy immediately.
+        let setNetworkKey = getNetworkKey(network);
+        let curNetworkKey = self.currentNetwork ? getNetworkKey(self.currentNetwork) : null;
+        if (setNetworkKey === curNetworkKey)
+          WifiManager.setHttpProxy(network);
+
+        self._sendMessage(message, true, true, msg);
+      } else {
+        self._sendMessage(message, false, "Set http proxy failed", msg);
+      }
+    });
+  },
+
   setStaticIpMode: function(msg) {
     const message = "WifiManager:setStaticMode:Return";
     let self = this;
     let network = msg.data.network;
     let info = msg.data.info;
 
     netFromDOM(network, null);
 
--- a/dom/wifi/nsIWifi.idl
+++ b/dom/wifi/nsIWifi.idl
@@ -54,17 +54,17 @@ interface nsIWifi : nsISupports
      * currently configured networks.
      *
      * On success a callback is notified with the list of networks.
      * On failure after 3 scan retry attempts a callback is notified of failure.
      */
     void getWifiScanResults(in nsIWifiScanResultsReady callback);
 };
 
-[scriptable, uuid(3f21012d-6e75-4632-b87c-acdd7c57fbf3)]
+[scriptable, uuid(e5a72295-1c5f-4848-9cbb-f1d3785c16c1)]
 interface nsIDOMWifiManager : nsISupports
 {
     /**
      * Returns the list of currently available networks.
      * onsuccess: We have obtained the current list of networks. request.value
      *            is an object whose property names are SSIDs and values are
      *            network objects.
      * onerror: We were unable to obtain a list of property names.
@@ -141,16 +141,29 @@ interface nsIDOMWifiManager : nsISupport
      *        - dns2 configured seconf DNS server address
      * onsuccess: We have successfully configure the static ip mode.
      * onerror: We have failed to configure the static ip mode.
      */
     nsIDOMDOMRequest setStaticIpMode(in jsval network,
                                      in jsval info);
 
     /**
+     * Given a network, configure http proxy when using wifi.
+     * @param network A network object with the SSID of the network to set http proxy.
+     * @param info info should have following field:
+     *        - httpProxyHost ip address of http proxy.
+     *        - httpProxyPort port of http proxy, set 0 to use default port 8080.
+     *        set info to null to clear http proxy.
+     * onsuccess: We have successfully configure http proxy.
+     * onerror: We have failed to configure http proxy.
+     */
+    nsIDOMDOMRequest setHttpProxy(in jsval network,
+                                  in jsval info);
+
+    /**
      * Returns whether or not wifi is currently enabled.
      */
     readonly attribute boolean enabled;
 
     /**
      * Returns the MAC address of the wifi adapter.
      */
     readonly attribute DOMString macAddress;