author | Boris Zbarsky <bzbarsky@mit.edu> |
Fri, 19 Sep 2014 22:58:27 -0400 | |
changeset 206336 | e8b6a242343df52f72ea0e70be63aa51449d5cdc |
parent 206335 | 84e73f166d2146d61ef516f050ce72dec6a50e8c |
child 206337 | 26a02411f50b9892b74530e74cc3d1b06c22f3fe |
push id | 27524 |
push user | cbook@mozilla.com |
push date | Mon, 22 Sep 2014 10:59:09 +0000 |
treeherder | mozilla-central@53f7f5b6d7bf [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | peterv |
bugs | 1066826 |
milestone | 35.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -887,125 +887,16 @@ Navigator::RegisterProtocolHandler(const if (!registrar) { return; } aRv = registrar->RegisterProtocolHandler(aProtocol, aURI, aTitle, mWindow->GetOuterWindow()); } -bool -Navigator::MozIsLocallyAvailable(const nsAString &aURI, - bool aWhenOffline, - ErrorResult& aRv) -{ - nsCOMPtr<nsIURI> uri; - nsresult rv = NS_NewURI(getter_AddRefs(uri), aURI); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return false; - } - - // This method of checking the cache will only work for http/https urls. - bool match; - rv = uri->SchemeIs("http", &match); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return false; - } - - if (!match) { - rv = uri->SchemeIs("https", &match); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return false; - } - if (!match) { - aRv.Throw(NS_ERROR_DOM_BAD_URI); - return false; - } - } - - // Same origin check. - JSContext *cx = nsContentUtils::GetCurrentJSContext(); - if (!cx) { - aRv.Throw(NS_ERROR_FAILURE); - return false; - } - - rv = nsContentUtils::GetSecurityManager()->CheckSameOrigin(cx, uri); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return false; - } - - // These load flags cause an error to be thrown if there is no - // valid cache entry, and skip the load if there is. - // If the cache is busy, assume that it is not yet available rather - // than waiting for it to become available. - uint32_t loadFlags = nsIChannel::INHIBIT_CACHING | - nsICachingChannel::LOAD_NO_NETWORK_IO | - nsICachingChannel::LOAD_ONLY_IF_MODIFIED | - nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY; - - if (aWhenOffline) { - loadFlags |= nsICachingChannel::LOAD_CHECK_OFFLINE_CACHE | - nsICachingChannel::LOAD_ONLY_FROM_CACHE | - nsIRequest::LOAD_FROM_CACHE; - } - - if (!mWindow) { - aRv.Throw(NS_ERROR_UNEXPECTED); - return false; - } - - nsCOMPtr<nsILoadGroup> loadGroup; - nsCOMPtr<nsIDocument> doc = mWindow->GetDoc(); - if (doc) { - loadGroup = doc->GetDocumentLoadGroup(); - } - - nsCOMPtr<nsIChannel> channel; - rv = NS_NewChannel(getter_AddRefs(channel), uri, - nullptr, loadGroup, nullptr, loadFlags); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return false; - } - - nsCOMPtr<nsIInputStream> stream; - rv = channel->Open(getter_AddRefs(stream)); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return false; - } - - stream->Close(); - - nsresult status; - rv = channel->GetStatus(&status); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return false; - } - - if (NS_FAILED(status)) { - return false; - } - - nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel); - bool isAvailable; - rv = httpChannel->GetRequestSucceeded(&isAvailable); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return false; - } - return isAvailable; -} - nsDOMDeviceStorage* Navigator::GetDeviceStorage(const nsAString& aType, ErrorResult& aRv) { if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; }
--- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -202,18 +202,16 @@ public: already_AddRefed<WakeLock> RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv); nsDOMDeviceStorage* GetDeviceStorage(const nsAString& aType, ErrorResult& aRv); void GetDeviceStorages(const nsAString& aType, nsTArray<nsRefPtr<nsDOMDeviceStorage> >& aStores, ErrorResult& aRv); DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv); - bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline, - ErrorResult& aRv); MobileMessageManager* GetMozMobileMessage(); Telephony* GetMozTelephony(ErrorResult& aRv); network::Connection* GetConnection(ErrorResult& aRv); nsDOMCameraManager* GetMozCameras(ErrorResult& aRv); void MozSetMessageHandler(const nsAString& aType, systemMessageCallback* aCallback, ErrorResult& aRv); bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
--- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -248,22 +248,16 @@ partial interface Navigator { }; // nsIDOMNavigatorDesktopNotification partial interface Navigator { [Throws, Pref="notification.feature.enabled"] readonly attribute DesktopNotificationCenter mozNotification; }; -// nsIDOMClientInformation -partial interface Navigator { - [Throws] - boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline); -}; - #ifdef MOZ_WEBSMS_BACKEND partial interface Navigator { [CheckPermissions="sms", Pref="dom.sms.enabled"] readonly attribute MozMobileMessageManager? mozMobileMessage; }; #endif // NetworkInformation