GeckoViewContentProtocolHandler.cpp (1785B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 // vim:ts=4 sw=2 sts=2 et cin: 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "GeckoViewContentProtocolHandler.h" 8 #include "GeckoViewContentChannel.h" 9 #include "GeckoViewContentChannelChild.h" 10 #include "nsStandardURL.h" 11 #include "nsURLHelper.h" 12 #include "nsIURIMutator.h" 13 14 #include "nsNetUtil.h" 15 16 //----------------------------------------------------------------------------- 17 18 nsresult GeckoViewContentProtocolHandler::Init() { return NS_OK; } 19 20 NS_IMPL_ISUPPORTS(GeckoViewContentProtocolHandler, nsIProtocolHandler, 21 nsISupportsWeakReference) 22 23 //----------------------------------------------------------------------------- 24 // nsIProtocolHandler methods: 25 26 NS_IMETHODIMP 27 GeckoViewContentProtocolHandler::GetScheme(nsACString& result) { 28 result.AssignLiteral("content"); 29 return NS_OK; 30 } 31 32 NS_IMETHODIMP 33 GeckoViewContentProtocolHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo, 34 nsIChannel** result) { 35 nsresult rv; 36 RefPtr<nsBaseChannel> channel; 37 38 if (XRE_IsParentProcess()) { 39 channel = new GeckoViewContentChannel(uri); 40 } else { 41 channel = new mozilla::net::GeckoViewContentChannelChild(uri); 42 } 43 44 rv = channel->SetLoadInfo(aLoadInfo); 45 if (NS_FAILED(rv)) { 46 return rv; 47 } 48 49 *result = channel.forget().take(); 50 51 return NS_OK; 52 } 53 54 NS_IMETHODIMP 55 GeckoViewContentProtocolHandler::AllowPort(int32_t port, const char* scheme, 56 bool* result) { 57 // don't override anything. 58 *result = false; 59 return NS_OK; 60 }