29 #include <nsICategoryManager.h>
30 #include <nsIHttpChannel.h>
31 #include <nsIRequest.h>
32 #include <nsIServiceManager.h>
34 #include <sbIMediacoreTypeSniffer.h>
35 #include <sbIPlaylistReader.h>
37 #include <nsComponentManagerUtils.h>
40 #include <nsServiceManagerUtils.h>
42 #include <nsXPCOMCID.h>
63 nsACString& aSniffedType)
65 NS_ENSURE_ARG_POINTER(aRequest);
70 nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest, &rv);
72 if (NS_SUCCEEDED(rv)) {
73 nsCAutoString requestMethod;
74 rv = httpChannel->GetRequestMethod(requestMethod);
75 NS_ENSURE_SUCCESS(rv, rv);
77 if (!requestMethod.EqualsLiteral(
"GET") &&
78 !requestMethod.EqualsLiteral(
"POST")) {
79 aSniffedType.Truncate();
84 nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest, &rv);
85 NS_ENSURE_SUCCESS(rv, rv);
87 nsCAutoString contentType;
88 rv = channel->GetContentType(contentType);
89 NS_ENSURE_SUCCESS(rv, rv);
93 if (contentType.EqualsLiteral(
"text/html")) {
94 aSniffedType.Truncate();
99 nsCOMPtr<nsIURI> originalURI;
100 rv = channel->GetOriginalURI(getter_AddRefs(originalURI));
101 NS_ENSURE_SUCCESS(rv, rv);
103 nsCAutoString scheme;
104 rv = originalURI->GetScheme(scheme);
105 NS_ENSURE_SUCCESS(rv, rv);
107 if (scheme.EqualsLiteral(
"view-source")) {
108 aSniffedType.Truncate();
112 nsCOMPtr<nsIURI>
uri;
113 rv = channel->GetURI(getter_AddRefs(uri));
114 NS_ENSURE_SUCCESS(rv, rv);
116 nsCOMPtr<sbIMediacoreTypeSniffer> typeSniffer =
118 NS_ENSURE_SUCCESS(rv, rv);
120 PRBool isMediaURL = PR_FALSE;
121 rv = typeSniffer->IsValidMediaURL(uri,
124 if (NS_SUCCEEDED(rv) && isMediaURL) {
130 if( contentType.EqualsLiteral(
"text/html") ||
131 contentType.EqualsLiteral(
"application/atom+xml") ||
132 contentType.EqualsLiteral(
"application/rdf+xml") ||
133 contentType.EqualsLiteral(
"application/rss+xml") ||
134 contentType.EqualsLiteral(
"application/xml")) {
135 return NS_ERROR_NOT_AVAILABLE;
142 PRBool isPlaylistURL = PR_FALSE;
143 rv = typeSniffer->IsValidWebSafePlaylistURL(uri,
145 if (NS_SUCCEEDED(rv) && isPlaylistURL) {
150 aSniffedType.Truncate();
157 const char* aRegistryLocation,
158 const char* aComponentType,
159 const nsModuleComponentInfo* aInfo)
162 nsCOMPtr<nsICategoryManager> catman =
163 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
164 NS_ENSURE_SUCCESS(rv, rv);
166 rv = catman->AddCategoryEntry(NS_CONTENT_SNIFFER_CATEGORY,
169 PR_TRUE, PR_TRUE, nsnull);
170 NS_ENSURE_SUCCESS(rv, rv);
178 const char* aRegistryLocation,
179 const nsModuleComponentInfo* aInfo)
182 nsCOMPtr<nsICategoryManager> catman =
183 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
184 NS_ENSURE_SUCCESS(rv, rv);
186 rv = catman->DeleteCategoryEntry(NS_CONTENT_SNIFFER_CATEGORY,
189 NS_ENSURE_SUCCESS(rv, rv);
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
_updateTextAndScrollDataForFrame aData
const TYPE_MAYBE_PLAYLIST