Bug 786419 - Part 10 - Fix app wrongly reporting an offline status r=jduell
In order for the content process to have an up-to-date table of which apps are
offline, we send that status in TabParent::LoadURL. However, the fact that
IsAppOffline returned true when the browser was offline, caused us to send
the offline status to content processes, and caused
Bug 1058718.
This also updates the UUID for nsIOService.
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -580,17 +580,18 @@ Navigator::CookieEnabled()
return cookieEnabled;
}
bool
Navigator::OnLine()
{
if (mWindow && mWindow->GetDoc()) {
- return !NS_IsAppOffline(mWindow->GetDoc()->NodePrincipal());
+ return !NS_IsOffline() &&
+ !NS_IsAppOffline(mWindow->GetDoc()->NodePrincipal());
}
return !NS_IsOffline();
}
NS_IMETHODIMP
Navigator::GetBuildID(nsAString& aBuildID)
{
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -2615,17 +2615,17 @@ RuntimeService::Observe(nsISupports* aSu
uint32_t notificationAppId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
info->GetAppId(¬ificationAppId);
if (appId != notificationAppId) {
return NS_OK;
}
- SendOfflineStatusChangeEventToAllWorkers(NS_IsAppOffline(appId));
+ SendOfflineStatusChangeEventToAllWorkers(NS_IsOffline() || NS_IsAppOffline(appId));
}
NS_NOTREACHED("Unknown observer topic!");
return NS_OK;
}
/* static */ void
RuntimeService::WorkerPrefChanged(const char* aPrefName, void* aClosure)
--- a/netwerk/base/public/nsIIOService.idl
+++ b/netwerk/base/public/nsIIOService.idl
@@ -14,17 +14,17 @@ interface nsIFile;
* nsIIOService provides a set of network utility functions. This interface
* duplicates many of the nsIProtocolHandler methods in a protocol handler
* independent way (e.g., NewURI inspects the scheme in order to delegate
* creation of the new URI to the appropriate protocol handler). nsIIOService
* also provides a set of URL parsing utility functions. These are provided
* as a convenience to the programmer and in some cases to improve performance
* by eliminating intermediate data structures and interfaces.
*/
-[scriptable, uuid(bddeda3f-9020-4d12-8c70-984ee9f7935e)]
+[scriptable, uuid(2d19475d-7557-43f7-9682-0c44417b6c0f)]
interface nsIIOService : nsISupports
{
/**
* Returns a protocol handler for a given URI scheme.
*
* @param aScheme the URI scheme
* @return reference to corresponding nsIProtocolHandler
*/
@@ -97,16 +97,17 @@ interface nsIIOService : nsISupports
* 'state' must one of nsIAppOfflineInfo::{ONLINE|OFFLINE|WIFI_ONLY}.
*/
void setAppOffline(in uint32_t appId, in long state);
/**
* Returns true if given appId is currently not allowed to make network
* connections. It will return true if the app is in the wifi-only state
* and we are currently on a 3G connection.
+ * The returned value does not depend on the offline state of the browser.
*/
boolean isAppOffline(in uint32_t appId);
/**
* Checks if a port number is banned. This involves consulting a list of
* unsafe ports, corresponding to network services that may be easily
* exploitable. If the given port is considered unsafe, then the protocol
--- a/netwerk/base/src/nsIOService.cpp
+++ b/netwerk/base/src/nsIOService.cpp
@@ -1504,22 +1504,17 @@ nsIOService::SetAppOfflineInternal(uint3
}
}
NS_IMETHODIMP
nsIOService::IsAppOffline(uint32_t aAppId, bool* aResult)
{
NS_ENSURE_ARG(aResult);
- *aResult = mOffline;
-
- if (mOffline) {
- // If the entire browser is offline, return that status
- return NS_OK;
- }
+ *aResult = false;
if (aAppId == NECKO_NO_APP_ID ||
aAppId == NECKO_UNKNOWN_APP_ID) {
return NS_ERROR_NOT_AVAILABLE;
}
int32_t state;
if (mAppsOfflineStatus.Get(aAppId, &state)) {