Bug 454381: Minefield Nightly brings up Dial-Up Login if a website is unavailable. r=biesi, sr=bsmedberg, a1.9.1b2=beltzner
authorHonza Bambas <honzab@allpeers.com>
Thu, 13 Nov 2008 15:38:02 +0000
changeset 21613 fb294e8e49d047249cd3aa7c5c40b3df4cd23ce0
parent 21612 701ef90e9563c6f295e6ecd4053080747a4e73ec
child 21614 4abab345610973f1f9e6708b4e87633f0ffef642
push id3620
push userdtownsend@mozilla.com
push dateThu, 13 Nov 2008 15:38:35 +0000
treeherdermozilla-central@4abab3456109 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbiesi, bsmedberg
bugs454381
milestone1.9.1b2pre
Bug 454381: Minefield Nightly brings up Dial-Up Login if a website is unavailable. r=biesi, sr=bsmedberg, a1.9.1b2=beltzner
netwerk/base/src/nsIOService.cpp
netwerk/base/src/nsIOService.h
netwerk/base/src/nsNativeConnectionHelper.cpp
--- a/netwerk/base/src/nsIOService.cpp
+++ b/netwerk/base/src/nsIOService.cpp
@@ -578,16 +578,34 @@ nsIOService::NewChannel(const nsACString
     nsresult rv;
     nsCOMPtr<nsIURI> uri;
     rv = NewURI(aSpec, aCharset, aBaseURI, getter_AddRefs(uri));
     if (NS_FAILED(rv)) return rv;
 
     return NewChannelFromURI(uri, result);
 }
 
+PRBool
+nsIOService::IsLinkUp()
+{
+    if (!mNetworkLinkService) {
+        // We cannot decide, assume the link is up
+        return PR_TRUE;
+    }
+
+    PRBool isLinkUp;
+    nsresult rv;
+    rv = mNetworkLinkService->GetIsLinkUp(&isLinkUp);
+    if (NS_FAILED(rv)) {
+        return PR_TRUE;
+    }
+
+    return isLinkUp;
+}
+
 NS_IMETHODIMP
 nsIOService::GetOffline(PRBool *offline)
 {
     *offline = mOffline;
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/netwerk/base/src/nsIOService.h
+++ b/netwerk/base/src/nsIOService.h
@@ -102,16 +102,17 @@ public:
                                PRUint32 flags);
 
     // Gets the array of registered content sniffers
     const nsCOMArray<nsIContentSniffer>& GetContentSniffers() {
       return mContentSniffers.GetEntries();
     }
 
     PRBool IsOffline() { return mOffline; }
+    PRBool IsLinkUp();
 
 private:
     // These shouldn't be called directly:
     // - construct using GetInstance
     // - destroy using Release
     nsIOService() NS_HIDDEN;
     ~nsIOService() NS_HIDDEN;
 
--- a/netwerk/base/src/nsNativeConnectionHelper.cpp
+++ b/netwerk/base/src/nsNativeConnectionHelper.cpp
@@ -33,24 +33,28 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsNativeConnectionHelper.h"
 #include "nsAutodialWin.h"
+#include "nsIOService.h"
+
 //-----------------------------------------------------------------------------
 // API typically invoked on the socket transport thread
 //-----------------------------------------------------------------------------
 
-
 PRBool
 nsNativeConnectionHelper::OnConnectionFailed(const PRUnichar* hostName)
 {
+    if (gIOService->IsLinkUp())
+        return PR_FALSE;
+
     nsRASAutodial autodial;
 
     if (autodial.ShouldDialOnNetworkError()) 
         return NS_SUCCEEDED(autodial.DialDefault(hostName));
     else
         return PR_FALSE;
 }