1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/indexedDB/CheckPermissionsHelper.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_indexeddb_checkpermissionshelper_h__ 1.11 +#define mozilla_dom_indexeddb_checkpermissionshelper_h__ 1.12 + 1.13 +// Only meant to be included in IndexedDB source files, not exported. 1.14 +#include "OpenDatabaseHelper.h" 1.15 + 1.16 +#include "nsIInterfaceRequestor.h" 1.17 +#include "nsIObserver.h" 1.18 +#include "nsIRunnable.h" 1.19 + 1.20 +class nsIDOMWindow; 1.21 +class nsIThread; 1.22 + 1.23 +BEGIN_INDEXEDDB_NAMESPACE 1.24 + 1.25 +class CheckPermissionsHelper MOZ_FINAL : public nsIRunnable, 1.26 + public nsIInterfaceRequestor, 1.27 + public nsIObserver 1.28 +{ 1.29 +public: 1.30 + NS_DECL_THREADSAFE_ISUPPORTS 1.31 + NS_DECL_NSIRUNNABLE 1.32 + NS_DECL_NSIINTERFACEREQUESTOR 1.33 + NS_DECL_NSIOBSERVER 1.34 + 1.35 + CheckPermissionsHelper(OpenDatabaseHelper* aHelper, 1.36 + nsIDOMWindow* aWindow) 1.37 + : mHelper(aHelper), 1.38 + mWindow(aWindow), 1.39 + // If we're trying to delete the database, we should never prompt the user. 1.40 + // Anything that would prompt is translated to denied. 1.41 + mPromptAllowed(!aHelper->mForDeletion), 1.42 + mHasPrompted(false), 1.43 + mPromptResult(0) 1.44 + { 1.45 + NS_ASSERTION(aHelper, "Null pointer!"); 1.46 + NS_ASSERTION(aHelper->mPersistenceType == quota::PERSISTENCE_TYPE_PERSISTENT, 1.47 + "Checking permission for non persistent databases?!"); 1.48 + } 1.49 + 1.50 +private: 1.51 + nsRefPtr<OpenDatabaseHelper> mHelper; 1.52 + nsCOMPtr<nsIDOMWindow> mWindow; 1.53 + bool mPromptAllowed; 1.54 + bool mHasPrompted; 1.55 + uint32_t mPromptResult; 1.56 +}; 1.57 + 1.58 +END_INDEXEDDB_NAMESPACE 1.59 + 1.60 +#endif // mozilla_dom_indexeddb_checkpermissionshelper_h__