зеркало из https://github.com/mozilla/gecko-dev.git
Bug 507749: Implement moz-device: protocol handler. Based on an earlier patch by Brad Lassey. r=jdm a=blocking-fennec
--HG-- extra : rebase_source : 9e9474bf72d880c8a7364c795b451f28a10913c3
This commit is contained in:
Родитель
6071791d22
Коммит
32a548bce5
|
@ -4941,7 +4941,7 @@ NSS_DISABLE_DBM=
|
|||
NECKO_WIFI=1
|
||||
NECKO_COOKIES=1
|
||||
NECKO_DISK_CACHE=1
|
||||
NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource"
|
||||
NECKO_PROTOCOLS_DEFAULT="about data device file ftp http res viewsource"
|
||||
USE_ARM_KUSER=
|
||||
BUILD_CTYPES=1
|
||||
XPC_IDISPATCH_SUPPORT=
|
||||
|
|
|
@ -647,6 +647,19 @@
|
|||
{0xa1, 0x78, 0x00, 0x50, 0x04, 0x1c, 0xaf, 0x44} \
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* netwerk/protocol/device classes
|
||||
*/
|
||||
#define NS_DEVICEPROTOCOLHANDLER_CLASSNAME \
|
||||
"nsDeviceProtocolHandler"
|
||||
#define NS_DEVICEPROTOCOLHANDLER_CID \
|
||||
{ /* 6b0ffe9e-d114-486b-aeb7-da62e7273ed5 */ \
|
||||
0x60ffe9e, \
|
||||
0xd114, \
|
||||
0x486b, \
|
||||
{0xae, 0xb7, 0xda, 0x62, 0xe7, 0x27, 0x3e, 0xd5} \
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* netwerk/protocol/viewsource/ classes
|
||||
*/
|
||||
|
|
|
@ -255,6 +255,11 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsResProtocolHandler, Init)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsResURL)
|
||||
#endif
|
||||
|
||||
#ifdef NECKO_PROTOCOL_device
|
||||
#include "nsDeviceProtocolHandler.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceProtocolHandler)
|
||||
#endif
|
||||
|
||||
#ifdef NECKO_PROTOCOL_viewsource
|
||||
#include "nsViewSourceHandler.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewSourceHandler)
|
||||
|
@ -706,6 +711,9 @@ NS_DEFINE_NAMED_CID(NS_WIFI_MONITOR_COMPONENT_CID);
|
|||
#ifdef NECKO_PROTOCOL_data
|
||||
NS_DEFINE_NAMED_CID(NS_DATAPROTOCOLHANDLER_CID);
|
||||
#endif
|
||||
#ifdef NECKO_PROTOCOL_device
|
||||
NS_DEFINE_NAMED_CID(NS_DEVICEPROTOCOLHANDLER_CID);
|
||||
#endif
|
||||
#ifdef NECKO_PROTOCOL_viewsource
|
||||
NS_DEFINE_NAMED_CID(NS_VIEWSOURCEHANDLER_CID);
|
||||
#endif
|
||||
|
@ -821,6 +829,9 @@ static const mozilla::Module::CIDEntry kNeckoCIDs[] = {
|
|||
#ifdef NECKO_PROTOCOL_data
|
||||
{ &kNS_DATAPROTOCOLHANDLER_CID, false, NULL, nsDataHandler::Create },
|
||||
#endif
|
||||
#ifdef NECKO_PROTOCOL_device
|
||||
{ &kNS_DEVICEPROTOCOLHANDLER_CID, false, NULL, nsDeviceProtocolHandlerConstructor},
|
||||
#endif
|
||||
#ifdef NECKO_PROTOCOL_viewsource
|
||||
{ &kNS_VIEWSOURCEHANDLER_CID, false, NULL, nsViewSourceHandlerConstructor },
|
||||
#endif
|
||||
|
@ -943,6 +954,9 @@ static const mozilla::Module::ContractIDEntry kNeckoContracts[] = {
|
|||
#ifdef NECKO_PROTOCOL_data
|
||||
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "data", &kNS_DATAPROTOCOLHANDLER_CID },
|
||||
#endif
|
||||
#ifdef NECKO_PROTOCOL_device
|
||||
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-device", &kNS_DEVICEPROTOCOLHANDLER_CID },
|
||||
#endif
|
||||
#ifdef NECKO_PROTOCOL_viewsource
|
||||
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "view-source", &kNS_VIEWSOURCEHANDLER_CID },
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#undef NECKO_PROTOCOL_about
|
||||
#undef NECKO_PROTOCOL_data
|
||||
#undef NECKO_PROTOCOL_device
|
||||
#undef NECKO_PROTOCOL_file
|
||||
#undef NECKO_PROTOCOL_ftp
|
||||
#undef NECKO_PROTOCOL_http
|
||||
|
|
|
@ -45,6 +45,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
PARALLEL_DIRS = \
|
||||
about \
|
||||
data \
|
||||
device \
|
||||
file \
|
||||
ftp \
|
||||
http \
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2010
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = deviceprotocol
|
||||
LIBRARY_NAME = nkdevice_s
|
||||
FORCE_STATIC_LIB = 1
|
||||
LIBXUL_LIBRARY = 1
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceChannel.cpp \
|
||||
nsDeviceProtocolHandler.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../../base/src/ \
|
||||
-I$(srcdir)/../file \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,64 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brad Lassey <blassey@mozilla.com>
|
||||
* Kyle Huey <me@kylehuey.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms or
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef nsDeviceCaptureProvider_h_
|
||||
#define nsDeviceCaptureProvider_h_
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
struct nsCaptureParams {
|
||||
PRPackedBool captureAudio;
|
||||
PRPackedBool captureVideo;
|
||||
PRUint32 frameRate;
|
||||
PRUint32 frameLimit;
|
||||
PRUint32 timeLimit;
|
||||
PRUint32 width;
|
||||
PRUint32 height;
|
||||
PRUint32 bpp;
|
||||
};
|
||||
|
||||
class nsDeviceCaptureProvider : public nsISupports
|
||||
{
|
||||
public:
|
||||
virtual nsresult Init(nsACString& aContentType,
|
||||
nsCaptureParams* aParams,
|
||||
nsIInputStream** aStream) = 0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,158 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Camera.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brad Lassey <blassey@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* 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 "plstr.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsDeviceChannel.h"
|
||||
#include "nsDeviceCaptureProvider.h"
|
||||
|
||||
// Copied from modules/libpr0n/decoders/icon/nsIconURI.cpp
|
||||
// takes a string like ?size=32&contentType=text/html and returns a new string
|
||||
// containing just the attribute values. i.e you could pass in this string with
|
||||
// an attribute name of "size=", this will return 32
|
||||
// Assumption: attribute pairs are separated by &
|
||||
void extractAttributeValue(const char* searchString, const char* attributeName, nsCString& result)
|
||||
{
|
||||
result.Truncate();
|
||||
|
||||
if (!searchString || !attributeName)
|
||||
return;
|
||||
|
||||
PRUint32 attributeNameSize = strlen(attributeName);
|
||||
const char *startOfAttribute = PL_strcasestr(searchString, attributeName);
|
||||
if (!startOfAttribute ||
|
||||
!( *(startOfAttribute-1) == '?' || *(startOfAttribute-1) == '&') )
|
||||
return;
|
||||
|
||||
startOfAttribute += attributeNameSize; // Skip the attributeName
|
||||
if (!*startOfAttribute)
|
||||
return;
|
||||
|
||||
const char *endOfAttribute = strchr(startOfAttribute, '&');
|
||||
if (endOfAttribute) {
|
||||
result.Assign(Substring(startOfAttribute, endOfAttribute));
|
||||
} else {
|
||||
result.Assign(startOfAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsDeviceChannel,
|
||||
nsBaseChannel,
|
||||
nsIChannel)
|
||||
|
||||
// nsDeviceChannel methods
|
||||
nsDeviceChannel::nsDeviceChannel()
|
||||
{
|
||||
SetContentType(NS_LITERAL_CSTRING("image/png"));
|
||||
}
|
||||
|
||||
nsDeviceChannel::~nsDeviceChannel()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceChannel::Init(nsIURI* aUri)
|
||||
{
|
||||
nsBaseChannel::Init();
|
||||
nsBaseChannel::SetURI(aUri);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceChannel::OpenContentStream(PRBool aAsync,
|
||||
nsIInputStream** aStream,
|
||||
nsIChannel** aChannel)
|
||||
{
|
||||
if (!aAsync)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
nsCOMPtr<nsIURI> uri = nsBaseChannel::URI();
|
||||
*aStream = nsnull;
|
||||
*aChannel = nsnull;
|
||||
NS_NAMED_LITERAL_CSTRING(width, "width=");
|
||||
NS_NAMED_LITERAL_CSTRING(height, "height=");
|
||||
|
||||
nsCAutoString spec;
|
||||
uri->GetSpec(spec);
|
||||
|
||||
nsCAutoString type;
|
||||
// Because no capture providers are implemented at the moment
|
||||
// capture will always be null and this function will always fail
|
||||
nsRefPtr<nsDeviceCaptureProvider> capture;
|
||||
nsCaptureParams captureParams;
|
||||
if (kNotFound != spec.Find(NS_LITERAL_CSTRING("type=image/png"),
|
||||
PR_TRUE,
|
||||
0,
|
||||
-1)) {
|
||||
type.AssignLiteral("image/png");
|
||||
SetContentType(type);
|
||||
captureParams.captureAudio = PR_FALSE;
|
||||
captureParams.captureVideo = PR_TRUE;
|
||||
captureParams.timeLimit = 0;
|
||||
captureParams.frameLimit = 1;
|
||||
nsCAutoString buffer;
|
||||
extractAttributeValue(spec.get(), "width=", buffer);
|
||||
nsresult err;
|
||||
captureParams.width = buffer.ToInteger(&err);
|
||||
if (!captureParams.width)
|
||||
captureParams.width = 640;
|
||||
extractAttributeValue(spec.get(), "height=", buffer);
|
||||
captureParams.height = buffer.ToInteger(&err);
|
||||
if (!captureParams.height)
|
||||
captureParams.height = 480;
|
||||
captureParams.bpp = 32;
|
||||
} else if (kNotFound != spec.Find(NS_LITERAL_CSTRING("type=video/x-raw-yuv"),
|
||||
PR_TRUE,
|
||||
0,
|
||||
-1)) {
|
||||
type.AssignLiteral("video/x-raw-yuv");
|
||||
SetContentType(type);
|
||||
captureParams.captureAudio = PR_FALSE;
|
||||
captureParams.captureVideo = PR_TRUE;
|
||||
captureParams.width = 640;
|
||||
captureParams.height = 480;
|
||||
captureParams.bpp = 32;
|
||||
captureParams.frameLimit = 6000;
|
||||
} else {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (!capture)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return capture->Init(type, &captureParams, aStream);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Camera.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brad Lassey <blassey@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef nsDeviceChannel_h_
|
||||
#define nsDeviceChannel_h_
|
||||
|
||||
#include "nsBaseChannel.h"
|
||||
|
||||
class nsDeviceChannel : public nsBaseChannel
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsDeviceChannel();
|
||||
~nsDeviceChannel();
|
||||
|
||||
nsresult Init(nsIURI* uri);
|
||||
nsresult OpenContentStream(PRBool aAsync,
|
||||
nsIInputStream **aStream,
|
||||
nsIChannel **aChannel);
|
||||
};
|
||||
#endif
|
|
@ -0,0 +1,108 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Camera.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Nino D'Aversa <ninodaversa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* 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 "nsDeviceProtocolHandler.h"
|
||||
#include "nsDeviceChannel.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsSimpleURI.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsDeviceProtocolHandler,
|
||||
nsIProtocolHandler)
|
||||
|
||||
nsresult
|
||||
nsDeviceProtocolHandler::Init(){
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceProtocolHandler::GetScheme(nsACString &aResult)
|
||||
{
|
||||
aResult.AssignLiteral("moz-device");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceProtocolHandler::GetDefaultPort(PRInt32 *aResult)
|
||||
{
|
||||
*aResult = -1; // no port for moz_device: URLs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceProtocolHandler::GetProtocolFlags(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceProtocolHandler::NewURI(const nsACString &spec,
|
||||
const char *originCharset,
|
||||
nsIURI *baseURI,
|
||||
nsIURI **result)
|
||||
{
|
||||
nsRefPtr<nsSimpleURI> uri = new nsSimpleURI();
|
||||
|
||||
nsresult rv = uri->SetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(uri, result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceProtocolHandler::NewChannel(nsIURI* aURI, nsIChannel **aResult)
|
||||
{
|
||||
nsRefPtr<nsDeviceChannel> channel = new nsDeviceChannel();
|
||||
nsresult rv = channel->Init(aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(channel, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceProtocolHandler::AllowPort(PRInt32 port,
|
||||
const char *scheme,
|
||||
PRBool *aResult)
|
||||
{
|
||||
// don't override anything.
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Camera.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Nino D'Aversa <ninodaversa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef nsDeviceProtocolHandler_h_
|
||||
#define nsDeviceProtocolHandler_h_
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {6b0ffe9e-d114-486b-aeb7-da62e7273ed5}
|
||||
#define NS_DEVICEPROTOCOLHANDLER_CID \
|
||||
{ 0x60ffe9e, 0xd114, 0x486b, \
|
||||
{0xae, 0xb7, 0xda, 0x62, 0xe7, 0x27, 0x3e, 0xd5} }
|
||||
|
||||
class nsDeviceProtocolHandler : public nsIProtocolHandler {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
|
||||
nsDeviceProtocolHandler() {}
|
||||
~nsDeviceProtocolHandler() {}
|
||||
|
||||
nsresult Init();
|
||||
};
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче