Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsWindowDataSource.h" |
michael@0 | 7 | #include "nsIXULWindow.h" |
michael@0 | 8 | #include "rdf.h" |
michael@0 | 9 | #include "nsIRDFContainerUtils.h" |
michael@0 | 10 | #include "nsIServiceManager.h" |
michael@0 | 11 | #include "nsReadableUtils.h" |
michael@0 | 12 | #include "nsIObserverService.h" |
michael@0 | 13 | #include "nsIWindowMediator.h" |
michael@0 | 14 | #include "nsXPCOMCID.h" |
michael@0 | 15 | #include "mozilla/ModuleUtils.h" |
michael@0 | 16 | #include "nsString.h" |
michael@0 | 17 | |
michael@0 | 18 | // just to do the reverse-lookup! sheesh. |
michael@0 | 19 | #include "nsIInterfaceRequestorUtils.h" |
michael@0 | 20 | #include "nsIDocShell.h" |
michael@0 | 21 | |
michael@0 | 22 | uint32_t nsWindowDataSource::windowCount = 0; |
michael@0 | 23 | |
michael@0 | 24 | nsIRDFResource* nsWindowDataSource::kNC_Name = nullptr; |
michael@0 | 25 | nsIRDFResource* nsWindowDataSource::kNC_WindowRoot = nullptr; |
michael@0 | 26 | nsIRDFResource* nsWindowDataSource::kNC_KeyIndex = nullptr; |
michael@0 | 27 | |
michael@0 | 28 | nsIRDFService* nsWindowDataSource::gRDFService = nullptr; |
michael@0 | 29 | |
michael@0 | 30 | uint32_t nsWindowDataSource::gRefCnt = 0; |
michael@0 | 31 | |
michael@0 | 32 | static const char kURINC_WindowRoot[] = "NC:WindowMediatorRoot"; |
michael@0 | 33 | |
michael@0 | 34 | DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Name); |
michael@0 | 35 | DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, KeyIndex); |
michael@0 | 36 | |
michael@0 | 37 | nsresult |
michael@0 | 38 | nsWindowDataSource::Init() |
michael@0 | 39 | { |
michael@0 | 40 | nsresult rv; |
michael@0 | 41 | |
michael@0 | 42 | if (gRefCnt++ == 0) { |
michael@0 | 43 | rv = CallGetService("@mozilla.org/rdf/rdf-service;1", &gRDFService); |
michael@0 | 44 | if (NS_FAILED(rv)) return rv; |
michael@0 | 45 | |
michael@0 | 46 | gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_WindowRoot), &kNC_WindowRoot); |
michael@0 | 47 | gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_Name), &kNC_Name); |
michael@0 | 48 | gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_KeyIndex), &kNC_KeyIndex); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | mInner = do_CreateInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource", &rv); |
michael@0 | 52 | if (NS_FAILED(rv)) return rv; |
michael@0 | 53 | |
michael@0 | 54 | nsCOMPtr<nsIRDFContainerUtils> rdfc = |
michael@0 | 55 | do_GetService("@mozilla.org/rdf/container-utils;1", &rv); |
michael@0 | 56 | if (NS_FAILED(rv)) return rv; |
michael@0 | 57 | |
michael@0 | 58 | rv = rdfc->MakeSeq(this, kNC_WindowRoot, getter_AddRefs(mContainer)); |
michael@0 | 59 | if (NS_FAILED(rv)) return rv; |
michael@0 | 60 | |
michael@0 | 61 | nsCOMPtr<nsIWindowMediator> windowMediator = |
michael@0 | 62 | do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv); |
michael@0 | 63 | if (NS_FAILED(rv)) return rv; |
michael@0 | 64 | |
michael@0 | 65 | rv = windowMediator->AddListener(this); |
michael@0 | 66 | if (NS_FAILED(rv)) return rv; |
michael@0 | 67 | |
michael@0 | 68 | nsCOMPtr<nsIObserverService> observerService = |
michael@0 | 69 | do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); |
michael@0 | 70 | if (NS_SUCCEEDED(rv)) { |
michael@0 | 71 | rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, |
michael@0 | 72 | false); |
michael@0 | 73 | } |
michael@0 | 74 | return NS_OK; |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | nsWindowDataSource::~nsWindowDataSource() |
michael@0 | 78 | { |
michael@0 | 79 | if (--gRefCnt == 0) { |
michael@0 | 80 | NS_IF_RELEASE(kNC_Name); |
michael@0 | 81 | NS_IF_RELEASE(kNC_KeyIndex); |
michael@0 | 82 | NS_IF_RELEASE(kNC_WindowRoot); |
michael@0 | 83 | NS_IF_RELEASE(gRDFService); |
michael@0 | 84 | } |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | NS_IMETHODIMP |
michael@0 | 88 | nsWindowDataSource::Observe(nsISupports *aSubject, const char* aTopic, const char16_t *aData) |
michael@0 | 89 | { |
michael@0 | 90 | if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) { |
michael@0 | 91 | // release these objects so that they release their reference |
michael@0 | 92 | // to us |
michael@0 | 93 | mContainer = nullptr; |
michael@0 | 94 | mInner = nullptr; |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | return NS_OK; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | NS_IMPL_CYCLE_COLLECTION_CLASS(nsWindowDataSource) |
michael@0 | 101 | |
michael@0 | 102 | NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsWindowDataSource) |
michael@0 | 103 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsWindowDataSource) |
michael@0 | 104 | // XXX mContainer? |
michael@0 | 105 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInner) |
michael@0 | 106 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
michael@0 | 107 | |
michael@0 | 108 | NS_IMPL_CYCLE_COLLECTING_ADDREF(nsWindowDataSource) |
michael@0 | 109 | NS_IMPL_CYCLE_COLLECTING_RELEASE(nsWindowDataSource) |
michael@0 | 110 | |
michael@0 | 111 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsWindowDataSource) |
michael@0 | 112 | NS_INTERFACE_MAP_ENTRY(nsIObserver) |
michael@0 | 113 | NS_INTERFACE_MAP_ENTRY(nsIWindowMediatorListener) |
michael@0 | 114 | NS_INTERFACE_MAP_ENTRY(nsIWindowDataSource) |
michael@0 | 115 | NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource) |
michael@0 | 116 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver) |
michael@0 | 117 | NS_INTERFACE_MAP_END |
michael@0 | 118 | |
michael@0 | 119 | // nsIWindowMediatorListener implementation |
michael@0 | 120 | // handle notifications from the window mediator and reflect them into |
michael@0 | 121 | // RDF |
michael@0 | 122 | |
michael@0 | 123 | /* void onWindowTitleChange (in nsIXULWindow window, in wstring newTitle); */ |
michael@0 | 124 | NS_IMETHODIMP |
michael@0 | 125 | nsWindowDataSource::OnWindowTitleChange(nsIXULWindow *window, |
michael@0 | 126 | const char16_t *newTitle) |
michael@0 | 127 | { |
michael@0 | 128 | nsresult rv; |
michael@0 | 129 | |
michael@0 | 130 | nsCOMPtr<nsIRDFResource> windowResource; |
michael@0 | 131 | mWindowResources.Get(window, getter_AddRefs(windowResource)); |
michael@0 | 132 | |
michael@0 | 133 | // oops, make sure this window is in the hashtable! |
michael@0 | 134 | if (!windowResource) { |
michael@0 | 135 | OnOpenWindow(window); |
michael@0 | 136 | mWindowResources.Get(window, getter_AddRefs(windowResource)); |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | NS_ENSURE_TRUE(windowResource, NS_ERROR_UNEXPECTED); |
michael@0 | 140 | |
michael@0 | 141 | nsCOMPtr<nsIRDFLiteral> newTitleLiteral; |
michael@0 | 142 | rv = gRDFService->GetLiteral(newTitle, getter_AddRefs(newTitleLiteral)); |
michael@0 | 143 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 144 | |
michael@0 | 145 | // get the old title |
michael@0 | 146 | nsCOMPtr<nsIRDFNode> oldTitleNode; |
michael@0 | 147 | rv = GetTarget(windowResource, kNC_Name, true, |
michael@0 | 148 | getter_AddRefs(oldTitleNode)); |
michael@0 | 149 | |
michael@0 | 150 | // assert the change |
michael@0 | 151 | if (NS_SUCCEEDED(rv) && oldTitleNode) |
michael@0 | 152 | // has an existing window title, update it |
michael@0 | 153 | rv = Change(windowResource, kNC_Name, oldTitleNode, newTitleLiteral); |
michael@0 | 154 | else |
michael@0 | 155 | // removed from the tasklist |
michael@0 | 156 | rv = Assert(windowResource, kNC_Name, newTitleLiteral, true); |
michael@0 | 157 | |
michael@0 | 158 | if (rv != NS_RDF_ASSERTION_ACCEPTED) |
michael@0 | 159 | { |
michael@0 | 160 | NS_ERROR("unable to set window name"); |
michael@0 | 161 | } |
michael@0 | 162 | |
michael@0 | 163 | return NS_OK; |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | /* void onOpenWindow (in nsIXULWindow window); */ |
michael@0 | 167 | NS_IMETHODIMP |
michael@0 | 168 | nsWindowDataSource::OnOpenWindow(nsIXULWindow *window) |
michael@0 | 169 | { |
michael@0 | 170 | nsAutoCString windowId(NS_LITERAL_CSTRING("window-")); |
michael@0 | 171 | windowId.AppendInt(windowCount++, 10); |
michael@0 | 172 | |
michael@0 | 173 | nsCOMPtr<nsIRDFResource> windowResource; |
michael@0 | 174 | gRDFService->GetResource(windowId, getter_AddRefs(windowResource)); |
michael@0 | 175 | |
michael@0 | 176 | mWindowResources.Put(window, windowResource); |
michael@0 | 177 | |
michael@0 | 178 | // assert the new window |
michael@0 | 179 | if (mContainer) |
michael@0 | 180 | mContainer->AppendElement(windowResource); |
michael@0 | 181 | |
michael@0 | 182 | return NS_OK; |
michael@0 | 183 | } |
michael@0 | 184 | |
michael@0 | 185 | /* void onCloseWindow (in nsIXULWindow window); */ |
michael@0 | 186 | NS_IMETHODIMP |
michael@0 | 187 | nsWindowDataSource::OnCloseWindow(nsIXULWindow *window) |
michael@0 | 188 | { |
michael@0 | 189 | nsresult rv; |
michael@0 | 190 | nsCOMPtr<nsIRDFResource> resource; |
michael@0 | 191 | mWindowResources.Get(window, getter_AddRefs(resource)); |
michael@0 | 192 | if (!resource) { |
michael@0 | 193 | return NS_ERROR_UNEXPECTED; |
michael@0 | 194 | } |
michael@0 | 195 | |
michael@0 | 196 | mWindowResources.Remove(window); |
michael@0 | 197 | |
michael@0 | 198 | // make sure we're not shutting down |
michael@0 | 199 | if (!mContainer) return NS_OK; |
michael@0 | 200 | |
michael@0 | 201 | nsCOMPtr<nsIRDFNode> oldKeyNode; |
michael@0 | 202 | nsCOMPtr<nsIRDFInt> oldKeyInt; |
michael@0 | 203 | |
michael@0 | 204 | // get the old keyIndex, if any |
michael@0 | 205 | rv = GetTarget(resource, kNC_KeyIndex, true, |
michael@0 | 206 | getter_AddRefs(oldKeyNode)); |
michael@0 | 207 | if (NS_SUCCEEDED(rv) && (rv != NS_RDF_NO_VALUE)) |
michael@0 | 208 | oldKeyInt = do_QueryInterface(oldKeyNode); |
michael@0 | 209 | |
michael@0 | 210 | |
michael@0 | 211 | // update RDF and keyindex - from this point forward we'll ignore |
michael@0 | 212 | // errors, because they just indicate some kind of RDF inconsistency |
michael@0 | 213 | int32_t winIndex = -1; |
michael@0 | 214 | rv = mContainer->IndexOf(resource, &winIndex); |
michael@0 | 215 | |
michael@0 | 216 | if (NS_FAILED(rv)) |
michael@0 | 217 | return NS_OK; |
michael@0 | 218 | |
michael@0 | 219 | // unassert the old window, ignore any error |
michael@0 | 220 | mContainer->RemoveElement(resource, true); |
michael@0 | 221 | |
michael@0 | 222 | nsCOMPtr<nsISimpleEnumerator> children; |
michael@0 | 223 | rv = mContainer->GetElements(getter_AddRefs(children)); |
michael@0 | 224 | if (NS_FAILED(rv)) |
michael@0 | 225 | return NS_OK; |
michael@0 | 226 | |
michael@0 | 227 | bool more = false; |
michael@0 | 228 | |
michael@0 | 229 | while (NS_SUCCEEDED(rv = children->HasMoreElements(&more)) && more) { |
michael@0 | 230 | nsCOMPtr<nsISupports> sup; |
michael@0 | 231 | rv = children->GetNext(getter_AddRefs(sup)); |
michael@0 | 232 | if (NS_FAILED(rv)) |
michael@0 | 233 | break; |
michael@0 | 234 | |
michael@0 | 235 | nsCOMPtr<nsIRDFResource> windowResource = do_QueryInterface(sup, &rv); |
michael@0 | 236 | if (NS_FAILED(rv)) |
michael@0 | 237 | continue; |
michael@0 | 238 | |
michael@0 | 239 | int32_t currentIndex = -1; |
michael@0 | 240 | mContainer->IndexOf(windowResource, ¤tIndex); |
michael@0 | 241 | |
michael@0 | 242 | // can skip updating windows with lower indexes |
michael@0 | 243 | // than the window that was removed |
michael@0 | 244 | if (currentIndex < winIndex) |
michael@0 | 245 | continue; |
michael@0 | 246 | |
michael@0 | 247 | nsCOMPtr<nsIRDFNode> newKeyNode; |
michael@0 | 248 | nsCOMPtr<nsIRDFInt> newKeyInt; |
michael@0 | 249 | |
michael@0 | 250 | rv = GetTarget(windowResource, kNC_KeyIndex, true, |
michael@0 | 251 | getter_AddRefs(newKeyNode)); |
michael@0 | 252 | if (NS_SUCCEEDED(rv) && (rv != NS_RDF_NO_VALUE)) |
michael@0 | 253 | newKeyInt = do_QueryInterface(newKeyNode); |
michael@0 | 254 | |
michael@0 | 255 | // changing from one key index to another |
michael@0 | 256 | if (oldKeyInt && newKeyInt) |
michael@0 | 257 | Change(windowResource, kNC_KeyIndex, oldKeyInt, newKeyInt); |
michael@0 | 258 | // creating a new keyindex - probably window going |
michael@0 | 259 | // from (none) to "9" |
michael@0 | 260 | else if (newKeyInt) |
michael@0 | 261 | Assert(windowResource, kNC_KeyIndex, newKeyInt, true); |
michael@0 | 262 | |
michael@0 | 263 | // somehow inserting a window above this one, |
michael@0 | 264 | // "9" to (none) |
michael@0 | 265 | else if (oldKeyInt) |
michael@0 | 266 | Unassert(windowResource, kNC_KeyIndex, oldKeyInt); |
michael@0 | 267 | |
michael@0 | 268 | } |
michael@0 | 269 | return NS_OK; |
michael@0 | 270 | } |
michael@0 | 271 | |
michael@0 | 272 | struct findWindowClosure { |
michael@0 | 273 | nsIRDFResource* targetResource; |
michael@0 | 274 | nsIXULWindow *resultWindow; |
michael@0 | 275 | }; |
michael@0 | 276 | |
michael@0 | 277 | static PLDHashOperator |
michael@0 | 278 | findWindow(nsIXULWindow* aWindow, nsIRDFResource* aResource, void* aClosure) |
michael@0 | 279 | { |
michael@0 | 280 | findWindowClosure* closure = static_cast<findWindowClosure*>(aClosure); |
michael@0 | 281 | |
michael@0 | 282 | if (aResource == closure->targetResource) { |
michael@0 | 283 | closure->resultWindow = aWindow; |
michael@0 | 284 | return PL_DHASH_STOP; |
michael@0 | 285 | } |
michael@0 | 286 | return PL_DHASH_NEXT; |
michael@0 | 287 | } |
michael@0 | 288 | |
michael@0 | 289 | // nsIWindowDataSource implementation |
michael@0 | 290 | |
michael@0 | 291 | NS_IMETHODIMP |
michael@0 | 292 | nsWindowDataSource::GetWindowForResource(const char *aResourceString, |
michael@0 | 293 | nsIDOMWindow** aResult) |
michael@0 | 294 | { |
michael@0 | 295 | nsCOMPtr<nsIRDFResource> windowResource; |
michael@0 | 296 | gRDFService->GetResource(nsDependentCString(aResourceString), |
michael@0 | 297 | getter_AddRefs(windowResource)); |
michael@0 | 298 | |
michael@0 | 299 | // now reverse-lookup in the hashtable |
michael@0 | 300 | findWindowClosure closure = { windowResource.get(), nullptr }; |
michael@0 | 301 | mWindowResources.EnumerateRead(findWindow, &closure); |
michael@0 | 302 | if (closure.resultWindow) { |
michael@0 | 303 | |
michael@0 | 304 | // this sucks, we have to jump through docshell to go from |
michael@0 | 305 | // nsIXULWindow -> nsIDOMWindow |
michael@0 | 306 | nsCOMPtr<nsIDocShell> docShell; |
michael@0 | 307 | closure.resultWindow->GetDocShell(getter_AddRefs(docShell)); |
michael@0 | 308 | |
michael@0 | 309 | if (docShell) { |
michael@0 | 310 | nsCOMPtr<nsIDOMWindow> result = do_GetInterface(docShell); |
michael@0 | 311 | |
michael@0 | 312 | *aResult = result; |
michael@0 | 313 | NS_IF_ADDREF(*aResult); |
michael@0 | 314 | } |
michael@0 | 315 | } |
michael@0 | 316 | |
michael@0 | 317 | return NS_OK; |
michael@0 | 318 | } |
michael@0 | 319 | |
michael@0 | 320 | |
michael@0 | 321 | // nsIRDFDataSource implementation |
michael@0 | 322 | // mostly, we just forward to mInner, except: |
michael@0 | 323 | // GetURI() - need to return "rdf:window-mediator" |
michael@0 | 324 | // GetTarget() - need to handle kNC_KeyIndex |
michael@0 | 325 | |
michael@0 | 326 | |
michael@0 | 327 | /* readonly attribute string URI; */ |
michael@0 | 328 | NS_IMETHODIMP nsWindowDataSource::GetURI(char * *aURI) |
michael@0 | 329 | { |
michael@0 | 330 | NS_ENSURE_ARG_POINTER(aURI); |
michael@0 | 331 | |
michael@0 | 332 | *aURI = ToNewCString(NS_LITERAL_CSTRING("rdf:window-mediator")); |
michael@0 | 333 | |
michael@0 | 334 | if (!*aURI) |
michael@0 | 335 | return NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 336 | |
michael@0 | 337 | return NS_OK; |
michael@0 | 338 | } |
michael@0 | 339 | |
michael@0 | 340 | /* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */ |
michael@0 | 341 | NS_IMETHODIMP nsWindowDataSource::GetTarget(nsIRDFResource *aSource, nsIRDFResource *aProperty, bool aTruthValue, nsIRDFNode **_retval) |
michael@0 | 342 | { |
michael@0 | 343 | NS_ENSURE_ARG_POINTER(_retval); |
michael@0 | 344 | |
michael@0 | 345 | // add extra nullptr checking for top-crash bug # 146466 |
michael@0 | 346 | if (!gRDFService) return NS_RDF_NO_VALUE; |
michael@0 | 347 | if (!mInner) return NS_RDF_NO_VALUE; |
michael@0 | 348 | if (!mContainer) return NS_RDF_NO_VALUE; |
michael@0 | 349 | // special case kNC_KeyIndex before we forward to mInner |
michael@0 | 350 | if (aProperty == kNC_KeyIndex) { |
michael@0 | 351 | |
michael@0 | 352 | int32_t theIndex = 0; |
michael@0 | 353 | nsresult rv = mContainer->IndexOf(aSource, &theIndex); |
michael@0 | 354 | if (NS_FAILED(rv)) return rv; |
michael@0 | 355 | |
michael@0 | 356 | // only allow the range of 1 to 9 for single key access |
michael@0 | 357 | if (theIndex < 1 || theIndex > 9) return(NS_RDF_NO_VALUE); |
michael@0 | 358 | |
michael@0 | 359 | nsCOMPtr<nsIRDFInt> indexInt; |
michael@0 | 360 | rv = gRDFService->GetIntLiteral(theIndex, getter_AddRefs(indexInt)); |
michael@0 | 361 | if (NS_FAILED(rv)) return(rv); |
michael@0 | 362 | if (!indexInt) return(NS_ERROR_FAILURE); |
michael@0 | 363 | |
michael@0 | 364 | return CallQueryInterface(indexInt, _retval); |
michael@0 | 365 | } |
michael@0 | 366 | |
michael@0 | 367 | return mInner->GetTarget(aSource, aProperty, aTruthValue, _retval); |
michael@0 | 368 | } |
michael@0 | 369 | |
michael@0 | 370 | /* nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ |
michael@0 | 371 | NS_IMETHODIMP nsWindowDataSource::GetSource(nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, nsIRDFResource **_retval) |
michael@0 | 372 | { |
michael@0 | 373 | if (mInner) |
michael@0 | 374 | return mInner->GetSource(aProperty, aTarget, aTruthValue, _retval); |
michael@0 | 375 | return NS_OK; |
michael@0 | 376 | } |
michael@0 | 377 | |
michael@0 | 378 | /* nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ |
michael@0 | 379 | NS_IMETHODIMP nsWindowDataSource::GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, nsISimpleEnumerator **_retval) |
michael@0 | 380 | { |
michael@0 | 381 | if (mInner) |
michael@0 | 382 | return mInner->GetSources(aProperty, aTarget, aTruthValue, _retval); |
michael@0 | 383 | return NS_OK; |
michael@0 | 384 | } |
michael@0 | 385 | |
michael@0 | 386 | /* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */ |
michael@0 | 387 | NS_IMETHODIMP nsWindowDataSource::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, bool aTruthValue, nsISimpleEnumerator **_retval) |
michael@0 | 388 | { |
michael@0 | 389 | if (mInner) |
michael@0 | 390 | return mInner->GetTargets(aSource, aProperty, aTruthValue, _retval); |
michael@0 | 391 | return NS_OK; |
michael@0 | 392 | } |
michael@0 | 393 | |
michael@0 | 394 | /* void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ |
michael@0 | 395 | NS_IMETHODIMP nsWindowDataSource::Assert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue) |
michael@0 | 396 | { |
michael@0 | 397 | if (mInner) |
michael@0 | 398 | return mInner->Assert(aSource, aProperty, aTarget, aTruthValue); |
michael@0 | 399 | return NS_OK; |
michael@0 | 400 | } |
michael@0 | 401 | |
michael@0 | 402 | /* void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */ |
michael@0 | 403 | NS_IMETHODIMP nsWindowDataSource::Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget) |
michael@0 | 404 | { |
michael@0 | 405 | if (mInner) |
michael@0 | 406 | return mInner->Unassert(aSource, aProperty, aTarget); |
michael@0 | 407 | return NS_OK; |
michael@0 | 408 | } |
michael@0 | 409 | |
michael@0 | 410 | /* void Change (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aOldTarget, in nsIRDFNode aNewTarget); */ |
michael@0 | 411 | NS_IMETHODIMP nsWindowDataSource::Change(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aOldTarget, nsIRDFNode *aNewTarget) |
michael@0 | 412 | { |
michael@0 | 413 | if (mInner) |
michael@0 | 414 | return mInner->Change(aSource, aProperty, aOldTarget, aNewTarget); |
michael@0 | 415 | return NS_OK; |
michael@0 | 416 | } |
michael@0 | 417 | |
michael@0 | 418 | /* void Move (in nsIRDFResource aOldSource, in nsIRDFResource aNewSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */ |
michael@0 | 419 | NS_IMETHODIMP nsWindowDataSource::Move(nsIRDFResource *aOldSource, nsIRDFResource *aNewSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget) |
michael@0 | 420 | { |
michael@0 | 421 | if (mInner) |
michael@0 | 422 | return mInner->Move(aOldSource, aNewSource, aProperty, aTarget); |
michael@0 | 423 | return NS_OK; |
michael@0 | 424 | } |
michael@0 | 425 | |
michael@0 | 426 | /* boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ |
michael@0 | 427 | NS_IMETHODIMP nsWindowDataSource::HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, bool *_retval) |
michael@0 | 428 | { |
michael@0 | 429 | if (mInner) |
michael@0 | 430 | return mInner->HasAssertion(aSource, aProperty, aTarget, aTruthValue, _retval); |
michael@0 | 431 | return NS_OK; |
michael@0 | 432 | } |
michael@0 | 433 | |
michael@0 | 434 | /* void AddObserver (in nsIRDFObserver aObserver); */ |
michael@0 | 435 | NS_IMETHODIMP nsWindowDataSource::AddObserver(nsIRDFObserver *aObserver) |
michael@0 | 436 | { |
michael@0 | 437 | if (mInner) |
michael@0 | 438 | return mInner->AddObserver(aObserver); |
michael@0 | 439 | return NS_OK; |
michael@0 | 440 | } |
michael@0 | 441 | |
michael@0 | 442 | /* void RemoveObserver (in nsIRDFObserver aObserver); */ |
michael@0 | 443 | NS_IMETHODIMP nsWindowDataSource::RemoveObserver(nsIRDFObserver *aObserver) |
michael@0 | 444 | { |
michael@0 | 445 | if (mInner) |
michael@0 | 446 | return mInner->RemoveObserver(aObserver); |
michael@0 | 447 | return NS_OK; |
michael@0 | 448 | } |
michael@0 | 449 | |
michael@0 | 450 | /* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */ |
michael@0 | 451 | NS_IMETHODIMP nsWindowDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval) |
michael@0 | 452 | { |
michael@0 | 453 | if (mInner) |
michael@0 | 454 | return mInner->ArcLabelsIn(aNode, _retval); |
michael@0 | 455 | return NS_OK; |
michael@0 | 456 | } |
michael@0 | 457 | |
michael@0 | 458 | /* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */ |
michael@0 | 459 | NS_IMETHODIMP nsWindowDataSource::ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **_retval) |
michael@0 | 460 | { |
michael@0 | 461 | if (mInner) |
michael@0 | 462 | return mInner->ArcLabelsOut(aSource, _retval); |
michael@0 | 463 | return NS_OK; |
michael@0 | 464 | } |
michael@0 | 465 | |
michael@0 | 466 | /* nsISimpleEnumerator GetAllResources (); */ |
michael@0 | 467 | NS_IMETHODIMP nsWindowDataSource::GetAllResources(nsISimpleEnumerator **_retval) |
michael@0 | 468 | { |
michael@0 | 469 | if (mInner) |
michael@0 | 470 | return mInner->GetAllResources(_retval); |
michael@0 | 471 | return NS_OK; |
michael@0 | 472 | } |
michael@0 | 473 | |
michael@0 | 474 | /* boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */ |
michael@0 | 475 | NS_IMETHODIMP nsWindowDataSource::IsCommandEnabled(nsISupportsArray *aSources, nsIRDFResource *aCommand, nsISupportsArray *aArguments, bool *_retval) |
michael@0 | 476 | { |
michael@0 | 477 | if (mInner) |
michael@0 | 478 | return mInner->IsCommandEnabled(aSources, aCommand, aArguments, _retval); |
michael@0 | 479 | return NS_OK; |
michael@0 | 480 | } |
michael@0 | 481 | |
michael@0 | 482 | /* void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */ |
michael@0 | 483 | NS_IMETHODIMP nsWindowDataSource::DoCommand(nsISupportsArray *aSources, nsIRDFResource *aCommand, nsISupportsArray *aArguments) |
michael@0 | 484 | { |
michael@0 | 485 | if (mInner) |
michael@0 | 486 | return mInner->DoCommand(aSources, aCommand, aArguments); |
michael@0 | 487 | return NS_OK; |
michael@0 | 488 | } |
michael@0 | 489 | |
michael@0 | 490 | /* nsISimpleEnumerator GetAllCmds (in nsIRDFResource aSource); */ |
michael@0 | 491 | NS_IMETHODIMP nsWindowDataSource::GetAllCmds(nsIRDFResource *aSource, nsISimpleEnumerator **_retval) |
michael@0 | 492 | { |
michael@0 | 493 | if (mInner) |
michael@0 | 494 | return mInner->GetAllCmds(aSource, _retval); |
michael@0 | 495 | return NS_OK; |
michael@0 | 496 | } |
michael@0 | 497 | |
michael@0 | 498 | /* boolean hasArcIn (in nsIRDFNode aNode, in nsIRDFResource aArc); */ |
michael@0 | 499 | NS_IMETHODIMP nsWindowDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, bool *_retval) |
michael@0 | 500 | { |
michael@0 | 501 | if (mInner) |
michael@0 | 502 | return mInner->HasArcIn(aNode, aArc, _retval); |
michael@0 | 503 | return NS_OK; |
michael@0 | 504 | } |
michael@0 | 505 | |
michael@0 | 506 | /* boolean hasArcOut (in nsIRDFResource aSource, in nsIRDFResource aArc); */ |
michael@0 | 507 | NS_IMETHODIMP nsWindowDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *_retval) |
michael@0 | 508 | { |
michael@0 | 509 | if (mInner) |
michael@0 | 510 | return mInner->HasArcOut(aSource, aArc, _retval); |
michael@0 | 511 | return NS_OK; |
michael@0 | 512 | } |
michael@0 | 513 | |
michael@0 | 514 | /* void beginUpdateBatch (); */ |
michael@0 | 515 | NS_IMETHODIMP nsWindowDataSource::BeginUpdateBatch() |
michael@0 | 516 | { |
michael@0 | 517 | if (mInner) |
michael@0 | 518 | return mInner->BeginUpdateBatch(); |
michael@0 | 519 | return NS_OK; |
michael@0 | 520 | } |
michael@0 | 521 | |
michael@0 | 522 | /* void endUpdateBatch (); */ |
michael@0 | 523 | NS_IMETHODIMP nsWindowDataSource::EndUpdateBatch() |
michael@0 | 524 | { |
michael@0 | 525 | if (mInner) |
michael@0 | 526 | return mInner->EndUpdateBatch(); |
michael@0 | 527 | return NS_OK; |
michael@0 | 528 | } |
michael@0 | 529 | |
michael@0 | 530 | // The module goop |
michael@0 | 531 | |
michael@0 | 532 | NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowDataSource, Init) |
michael@0 | 533 | |
michael@0 | 534 | NS_DEFINE_NAMED_CID(NS_WINDOWDATASOURCE_CID); |
michael@0 | 535 | |
michael@0 | 536 | static const mozilla::Module::CIDEntry kWindowDSCIDs[] = { |
michael@0 | 537 | { &kNS_WINDOWDATASOURCE_CID, false, nullptr, nsWindowDataSourceConstructor }, |
michael@0 | 538 | { nullptr } |
michael@0 | 539 | }; |
michael@0 | 540 | |
michael@0 | 541 | static const mozilla::Module::ContractIDEntry kWindowDSContracts[] = { |
michael@0 | 542 | { NS_RDF_DATASOURCE_CONTRACTID_PREFIX "window-mediator", &kNS_WINDOWDATASOURCE_CID }, |
michael@0 | 543 | { nullptr } |
michael@0 | 544 | }; |
michael@0 | 545 | |
michael@0 | 546 | static const mozilla::Module::CategoryEntry kWindowDSCategories[] = { |
michael@0 | 547 | { "app-startup", "Window Data Source", "service," NS_RDF_DATASOURCE_CONTRACTID_PREFIX "window-mediator" }, |
michael@0 | 548 | { nullptr } |
michael@0 | 549 | }; |
michael@0 | 550 | |
michael@0 | 551 | static const mozilla::Module kWindowDSModule = { |
michael@0 | 552 | mozilla::Module::kVersion, |
michael@0 | 553 | kWindowDSCIDs, |
michael@0 | 554 | kWindowDSContracts, |
michael@0 | 555 | kWindowDSCategories |
michael@0 | 556 | }; |
michael@0 | 557 | |
michael@0 | 558 | NSMODULE_DEFN(nsWindowDataSourceModule) = &kWindowDSModule; |