333751 - land feed preview page. actually turn it on by default + address some review comments from darin to nsFeedSniffer.* r=darin@meer.net for the configure changes and nsFeedSniffer.*
git-svn-id: svn://10.0.0.236/trunk@195992 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
1c2073ef06
commit
75b15f4c7c
@ -176,26 +176,28 @@ nsFeedSniffer::GetMIMETypeFromContent(nsIRequest* request,
|
||||
// RSS 0.91/0.92/2.0
|
||||
dataString.BeginReading(start_iter);
|
||||
dataString.EndReading(end_iter);
|
||||
isFeed = FindInReadable(NS_LITERAL_CSTRING("<rss"), start_iter, end_iter);
|
||||
|
||||
// Only start iter moves, and we don't need to reinitialize it every time
|
||||
// if we use a temporary iterator:
|
||||
nsACString::const_iterator iter = start_iter;
|
||||
isFeed = FindInReadable(NS_LITERAL_CSTRING("<rss"), iter, end_iter);
|
||||
|
||||
// Atom 1.0
|
||||
if (!isFeed) {
|
||||
dataString.BeginReading(start_iter);
|
||||
dataString.EndReading(end_iter);
|
||||
isFeed = FindInReadable(NS_LITERAL_CSTRING("<feed"), start_iter, end_iter);
|
||||
iter = start_iter;
|
||||
isFeed = FindInReadable(NS_LITERAL_CSTRING("<feed"), iter, end_iter);
|
||||
}
|
||||
|
||||
// RSS 1.0
|
||||
if (!isFeed) {
|
||||
dataString.BeginReading(start_iter);
|
||||
dataString.EndReading(end_iter);
|
||||
if (FindInReadable(NS_LITERAL_CSTRING("<rdf:RDF"), start_iter, end_iter)) {
|
||||
dataString.BeginReading(start_iter);
|
||||
dataString.EndReading(end_iter);
|
||||
if (FindInReadable(NS_LITERAL_CSTRING(NS_RDF), start_iter, end_iter)) {
|
||||
dataString.BeginReading(start_iter);
|
||||
dataString.EndReading(end_iter);
|
||||
isFeed = FindInReadable(NS_LITERAL_CSTRING(NS_RSS), start_iter, end_iter);
|
||||
iter = start_iter;
|
||||
isFeed = FindInReadable(NS_LITERAL_CSTRING("<rdf:RDF"), iter, end_iter);
|
||||
if (!isFeed) {
|
||||
iter = start_iter;
|
||||
isFeed = FindInReadable(NS_LITERAL_CSTRING(NS_RDF), iter, end_iter);
|
||||
if (!isFeed) {
|
||||
iter = start_iter;
|
||||
isFeed = FindInReadable(NS_LITERAL_CSTRING(NS_RSS), iter, end_iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,21 +216,28 @@ nsFeedSniffer::OnStartRequest(nsIRequest* request, nsISupports* context)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsFeedSniffer::AppendSegmentToString(nsIInputStream* inputStream,
|
||||
void* closure,
|
||||
const char* rawSegment,
|
||||
PRUint32 toOffset,
|
||||
PRUint32 count,
|
||||
PRUint32* writeCount)
|
||||
{
|
||||
nsCString* decodedData = NS_STATIC_CAST(nsCString*, closure);
|
||||
decodedData->Append(rawSegment, count);
|
||||
*writeCount = count;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFeedSniffer::OnDataAvailable(nsIRequest* request, nsISupports* context,
|
||||
nsIInputStream* stream, PRUint32 offset,
|
||||
PRUint32 count)
|
||||
{
|
||||
char* decodedBytes = (char*)PR_Malloc(sizeof(char) * count);
|
||||
PRUint32 read;
|
||||
nsresult rv = stream->Read(decodedBytes, count, &read);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mDecodedData.Append(decodedBytes, read);
|
||||
|
||||
PR_Free(decodedBytes);
|
||||
decodedBytes = nsnull;
|
||||
|
||||
return rv;
|
||||
return stream->ReadSegments(AppendSegmentToString, &mDecodedData, count,
|
||||
&read);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@ -49,10 +49,18 @@ public:
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
static NS_METHOD AppendSegmentToString(nsIInputStream* inputStream,
|
||||
void* closure,
|
||||
const char* rawSegment,
|
||||
PRUint32 toOffset,
|
||||
PRUint32 count,
|
||||
PRUint32* writeCount);
|
||||
|
||||
static NS_METHOD Register(nsIComponentManager* compMgr, nsIFile* path,
|
||||
const char* registryLocation,
|
||||
const char* componentType,
|
||||
const nsModuleComponentInfo *info);
|
||||
|
||||
protected:
|
||||
nsresult ConvertEncodedData(nsIRequest* request, const PRUint8* data,
|
||||
PRUint32 length);
|
||||
|
||||
@ -4312,7 +4312,7 @@ MOZ_CALENDAR=
|
||||
MOZ_DBGRINFO_MODULES=
|
||||
MOZ_ENABLE_CANVAS=1
|
||||
MOZ_EXTENSIONS_ALL=" cookie wallet xml-rpc help p3p venkman inspector irc typeaheadfind spellcheck gnomevfs sroaming xmlterm datetime finger cview layout-debug tasks sql xforms permissions schema-validation reporter safe-browsing"
|
||||
MOZ_FEEDS=
|
||||
MOZ_FEEDS=1
|
||||
MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp xbm icon"
|
||||
MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
|
||||
MOZ_IPCD=
|
||||
@ -5773,9 +5773,9 @@ dnl ========================================================
|
||||
dnl = Enable feeds (new feed handling/processing - Firefox)
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(feeds,
|
||||
[ --enable-feeds Enable in-page feed handling and processing (Firefox)],
|
||||
MOZ_FEEDS=1,
|
||||
MOZ_FEEDS= )
|
||||
[ --disable-feeds Enable in-page feed handling and processing (Firefox)],
|
||||
MOZ_FEEDS=,
|
||||
MOZ_FEEDS=1 )
|
||||
if test -n "$MOZ_FEEDS"; then
|
||||
AC_DEFINE(MOZ_FEEDS)
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user