nsresult nsUnixSystemProxySettings::SetProxyResultFromGSettings(const char* aKeyBase, const char* aType, nsACString& aResult) { nsDependentCString key(aKeyBase); nsCOMPtr<nsIGSettingsCollection> proxy_settings = mSchemeProxySettings.Get(key); nsresult rv; if (!proxy_settings) { rv = mGSettings->GetCollectionForSchema(key, getter_AddRefs(proxy_settings)); NS_ENSURE_SUCCESS(rv, rv); mSchemeProxySettings.Put(key, proxy_settings); } nsAutoCString host; rv = proxy_settings->GetString(NS_LITERAL_CSTRING("host"), host); NS_ENSURE_SUCCESS(rv, rv); if (host.IsEmpty()) return NS_ERROR_FAILURE; int32_t port; rv = proxy_settings->GetInt(NS_LITERAL_CSTRING("port"), &port); NS_ENSURE_SUCCESS(rv, rv); /* When port is 0, proxy is not considered as enabled even if host is set. */ if (port == 0) return NS_ERROR_FAILURE; SetProxyResult(aType, host, port, aResult); return NS_OK; }
bool ContentDialogChild::Recv__delete__(const InfallibleTArray<int>& aIntParams, const InfallibleTArray<nsString>& aStringParams) { nsCOMPtr<nsIDialogParamBlock> params; if (gActiveDialogs.Get(this, getter_AddRefs(params))) { TabChild::ArraysToParams(aIntParams, aStringParams, params); gActiveDialogs.Remove(this); } return true; }
NS_IMETHODIMP TabChild::OpenDialog(PRUint32 aType, const nsACString& aName, const nsACString& aFeatures, nsIDialogParamBlock* aArguments, nsIDOMElement* aFrameElement) { if (!gActiveDialogs.IsInitialized()) { gActiveDialogs.Init(); } InfallibleTArray<PRInt32> intParams; InfallibleTArray<nsString> stringParams; ParamsToArrays(aArguments, intParams, stringParams); PContentDialogChild* dialog = SendPContentDialogConstructor(aType, nsCString(aName), nsCString(aFeatures), intParams, stringParams); gActiveDialogs.Put(dialog, aArguments); nsIThread *thread = NS_GetCurrentThread(); while (gActiveDialogs.GetWeak(dialog)) { if (!NS_ProcessNextEvent(thread)) { break; } } return NS_OK; }
nsresult nsXTFService::CreateElement(nsIContent** aResult, nsINodeInfo* aNodeInfo) { nsCOMPtr<nsIXTFElementFactory> factory; // Check if we have an xtf factory for the given namespaceid in our cache: if (!mFactoryHash.Get(aNodeInfo->NamespaceID(), getter_AddRefs(factory))) { // No. See if there is one registered with the component manager: nsCAutoString xtf_contract_id(NS_XTF_ELEMENT_FACTORY_CONTRACTID_PREFIX); nsAutoString uri; aNodeInfo->GetNamespaceURI(uri); AppendUTF16toUTF8(uri, xtf_contract_id); #ifdef DEBUG_xtf_verbose printf("Testing for XTF factory at %s\n", xtf_contract_id.get()); #endif factory = do_GetService(xtf_contract_id.get()); if (factory) { #ifdef DEBUG printf("We've got an XTF factory: %s \n", xtf_contract_id.get()); #endif // Put into hash: mFactoryHash.Put(aNodeInfo->NamespaceID(), factory); } } if (!factory) return NS_ERROR_FAILURE; // We have an xtf factory. Now try to create an element for the given tag name: nsCOMPtr<nsIXTFElement> elem; nsAutoString tagName; aNodeInfo->GetName(tagName); factory->CreateElement(tagName, getter_AddRefs(elem)); if (!elem) return NS_ERROR_FAILURE; // We've got an xtf element. Create a wrapper for it: return NS_NewXTFElementWrapper(elem, aNodeInfo, aResult); }
nsresult RDFContentSinkImpl::GetResourceAttribute(const PRUnichar** aAttributes, nsIRDFResource** aResource) { nsCOMPtr<nsIAtom> localName; nsAutoString nodeID; for (; *aAttributes; aAttributes += 2) { const nsDependentSubstring& nameSpaceURI = SplitExpatName(aAttributes[0], getter_AddRefs(localName)); // We'll accept `resource' or `rdf:resource', under the spirit // that we should be liberal towards the input that we // receive. if (!nameSpaceURI.IsEmpty() && !nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI)) { continue; } // XXX you can't specify both, but we'll just pick up the // first thing that was specified and ignore the other. if (localName == kResourceAtom) { // XXX Take the URI and make it fully qualified by // sticking it into the document's URL. This may not be // appropriate... nsAutoString relURI(aAttributes[1]); if (rdf_RequiresAbsoluteURI(relURI)) { nsresult rv; nsCAutoString uri; rv = mDocumentURL->Resolve(NS_ConvertUTF16toUTF8(aAttributes[1]), uri); if (NS_FAILED(rv)) return rv; return gRDFService->GetResource(uri, aResource); } return gRDFService->GetResource(NS_ConvertUTF16toUTF8(aAttributes[1]), aResource); } else if (localName == kNodeIdAtom) { nodeID.Assign(aAttributes[1]); } } // If nodeID is present, check if we already know about it. If we've seen // the nodeID before, use the same resource, otherwise generate a new one. if (!nodeID.IsEmpty()) { mNodeIDMap.Get(nodeID,aResource); if (!*aResource) { nsresult rv; rv = gRDFService->GetAnonymousResource(aResource); if (NS_FAILED(rv)) { return rv; } mNodeIDMap.Put(nodeID,*aResource); } return NS_OK; } return NS_ERROR_FAILURE; }
nsresult RDFContentSinkImpl::GetIdAboutAttribute(const PRUnichar** aAttributes, nsIRDFResource** aResource, bool* aIsAnonymous) { // This corresponds to the dirty work of production [6.5] nsresult rv = NS_OK; nsAutoString nodeID; nsCOMPtr<nsIAtom> localName; for (; *aAttributes; aAttributes += 2) { const nsDependentSubstring& nameSpaceURI = SplitExpatName(aAttributes[0], getter_AddRefs(localName)); // We'll accept either `ID' or `rdf:ID' (ibid with `about' or // `rdf:about') in the spirit of being liberal towards the // input that we receive. if (!nameSpaceURI.IsEmpty() && !nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI)) { continue; } // XXX you can't specify both, but we'll just pick up the // first thing that was specified and ignore the other. if (localName == kAboutAtom) { if (aIsAnonymous) *aIsAnonymous = false; nsAutoString relURI(aAttributes[1]); if (rdf_RequiresAbsoluteURI(relURI)) { nsCAutoString uri; rv = mDocumentURL->Resolve(NS_ConvertUTF16toUTF8(aAttributes[1]), uri); if (NS_FAILED(rv)) return rv; return gRDFService->GetResource(uri, aResource); } return gRDFService->GetResource(NS_ConvertUTF16toUTF8(aAttributes[1]), aResource); } else if (localName == kIdAtom) { if (aIsAnonymous) *aIsAnonymous = false; // In the spirit of leniency, we do not bother trying to // enforce that this be a valid "XML Name" (see // http://www.w3.org/TR/REC-xml#NT-Nmtoken), as per // 6.21. If we wanted to, this would be where to do it. // Construct an in-line resource whose URI is the // document's URI plus the XML name specified in the ID // attribute. nsCAutoString name; nsCAutoString ref('#'); AppendUTF16toUTF8(aAttributes[1], ref); rv = mDocumentURL->Resolve(ref, name); if (NS_FAILED(rv)) return rv; return gRDFService->GetResource(name, aResource); } else if (localName == kNodeIdAtom) { nodeID.Assign(aAttributes[1]); } else if (localName == kAboutEachAtom) { // XXX we don't deal with aboutEach... //PR_LOG(gLog, PR_LOG_WARNING, // ("rdfxml: ignoring aboutEach at line %d", // aNode.GetSourceLineNumber())); } } // Otherwise, we couldn't find anything, so just gensym one... if (aIsAnonymous) *aIsAnonymous = true; // If nodeID is present, check if we already know about it. If we've seen // the nodeID before, use the same resource, otherwise generate a new one. if (!nodeID.IsEmpty()) { mNodeIDMap.Get(nodeID,aResource); if (!*aResource) { rv = gRDFService->GetAnonymousResource(aResource); mNodeIDMap.Put(nodeID,*aResource); } } else { rv = gRDFService->GetAnonymousResource(aResource); } return rv; }
nsresult nsXTFService::CreateElement(nsIContent** aResult, nsINodeInfo* aNodeInfo) { nsCOMPtr<nsIXTFElementFactory> factory; // Check if we have an xtf factory for the given namespaceid in our cache: if (!mFactoryHash.Get(aNodeInfo->NamespaceID(), getter_AddRefs(factory))) { // No. See if there is one registered with the component manager: nsCAutoString xtf_contract_id(NS_XTF_ELEMENT_FACTORY_CONTRACTID_PREFIX); nsAutoString uri; aNodeInfo->GetNamespaceURI(uri); AppendUTF16toUTF8(uri, xtf_contract_id); #ifdef DEBUG_xtf_verbose printf("Testing for XTF factory at %s\n", xtf_contract_id.get()); #endif factory = do_GetService(xtf_contract_id.get()); if (factory) { #ifdef DEBUG printf("We've got an XTF factory.\n"); #endif // Put into hash: mFactoryHash.Put(aNodeInfo->NamespaceID(), factory); } } if (!factory) return NS_ERROR_FAILURE; // We have an xtf factory. Now try to create an element for the given tag name: nsCOMPtr<nsIXTFElement> elem; nsAutoString tagName; aNodeInfo->GetName(tagName); factory->CreateElement(tagName, getter_AddRefs(elem)); if (!elem) return NS_ERROR_FAILURE; // We've got an xtf element. Create an appropriate wrapper for it: PRUint32 elementType; elem->GetElementType(&elementType); switch (elementType) { case nsIXTFElement::ELEMENT_TYPE_GENERIC_ELEMENT: { nsCOMPtr<nsIXTFGenericElement> elem2 = do_QueryInterface(elem); return NS_NewXTFGenericElementWrapper(elem2, aNodeInfo, aResult); } case nsIXTFElement::ELEMENT_TYPE_BINDABLE: { nsCOMPtr<nsIXTFBindableElement> elem2 = do_QueryInterface(elem); return NS_NewXTFBindableElementWrapper(elem2, aNodeInfo, aResult); } case nsIXTFElement::ELEMENT_TYPE_SVG_VISUAL: { #ifdef MOZ_SVG nsCOMPtr<nsIXTFSVGVisual> elem2 = do_QueryInterface(elem); return NS_NewXTFSVGVisualWrapper(elem2, aNodeInfo, aResult); #else NS_ERROR("xtf svg visuals are only supported in mozilla builds with native svg support"); break; #endif } case nsIXTFElement::ELEMENT_TYPE_XML_VISUAL: { nsCOMPtr<nsIXTFXMLVisual> elem2 = do_QueryInterface(elem); return NS_NewXTFXMLVisualWrapper(elem2, aNodeInfo, aResult); } case nsIXTFElement::ELEMENT_TYPE_XUL_VISUAL: { nsCOMPtr<nsIXTFXULVisual> elem2 = do_QueryInterface(elem); return NS_NewXTFXULVisualWrapper(elem2, aNodeInfo, aResult); } default: NS_ERROR("unknown xtf element type"); break; } return NS_ERROR_FAILURE; }