nsCOMPtr<nsIDocument> doc; mRoot->GetDocument(*getter_AddRefs(doc)); NS_ASSERTION(doc, "element has no document"); if (!doc) return NS_ERROR_UNEXPECTED;   nsCOMPtr<nsIPrincipal> docPrincipal; nsresult rv = doc->GetPrincipal(getter_AddRefs(docPrincipal)); if (NS_FAILED(rv)) return rv;  PRBool isTrusted = PR_FALSE; rv = IsSystemPrincipal(docPrincipal.get(), &isTrusted); if (NS_SUCCEEDED(rv) && isTrusted) {  nsAutoString datasourceStr; mRoot->GetAttr(kNameSpaceID_None, nsXULAtoms::statedatasource, datasourceStr);     if (datasourceStr.Length()) { gRDFService->GetDataSource(NS_ConvertUCS2toUTF8(datasourceStr).get(), getter_AddRefs(mPersistStateStore)); } else { gRDFService->GetDataSource("rdf:local-store", getter_AddRefs(mPersistStateStore)); } }
nsXULOutlinerBuilder::SetOutliner(nsIOutlinerBoxObject* outliner){    mBoxObject = outliner;    // XXX seems like there's some frame churn going on here, so we'll    // only try to grab the root element if we don't have it    // already. (It better not change!)    if (! mRoot) {        // Get our root element        nsCOMPtr<nsIDOMElement> body;        mBoxObject->GetOutlinerBody(getter_AddRefs(body));        mRoot = do_QueryInterface(body);        LoadDataSources();        // So we can remember open state.        //        // XXX We should fix this so that if the document is        // ``trusted'', we use the localstore.        mPersistStateStore =            do_CreateInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource");        if (! mPersistStateStore)            return NS_ERROR_FAILURE;        Rebuild();    }    return NS_OK;}