|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_dom_indexeddb_checkpermissionshelper_h__ |
|
8 #define mozilla_dom_indexeddb_checkpermissionshelper_h__ |
|
9 |
|
10 // Only meant to be included in IndexedDB source files, not exported. |
|
11 #include "OpenDatabaseHelper.h" |
|
12 |
|
13 #include "nsIInterfaceRequestor.h" |
|
14 #include "nsIObserver.h" |
|
15 #include "nsIRunnable.h" |
|
16 |
|
17 class nsIDOMWindow; |
|
18 class nsIThread; |
|
19 |
|
20 BEGIN_INDEXEDDB_NAMESPACE |
|
21 |
|
22 class CheckPermissionsHelper MOZ_FINAL : public nsIRunnable, |
|
23 public nsIInterfaceRequestor, |
|
24 public nsIObserver |
|
25 { |
|
26 public: |
|
27 NS_DECL_THREADSAFE_ISUPPORTS |
|
28 NS_DECL_NSIRUNNABLE |
|
29 NS_DECL_NSIINTERFACEREQUESTOR |
|
30 NS_DECL_NSIOBSERVER |
|
31 |
|
32 CheckPermissionsHelper(OpenDatabaseHelper* aHelper, |
|
33 nsIDOMWindow* aWindow) |
|
34 : mHelper(aHelper), |
|
35 mWindow(aWindow), |
|
36 // If we're trying to delete the database, we should never prompt the user. |
|
37 // Anything that would prompt is translated to denied. |
|
38 mPromptAllowed(!aHelper->mForDeletion), |
|
39 mHasPrompted(false), |
|
40 mPromptResult(0) |
|
41 { |
|
42 NS_ASSERTION(aHelper, "Null pointer!"); |
|
43 NS_ASSERTION(aHelper->mPersistenceType == quota::PERSISTENCE_TYPE_PERSISTENT, |
|
44 "Checking permission for non persistent databases?!"); |
|
45 } |
|
46 |
|
47 private: |
|
48 nsRefPtr<OpenDatabaseHelper> mHelper; |
|
49 nsCOMPtr<nsIDOMWindow> mWindow; |
|
50 bool mPromptAllowed; |
|
51 bool mHasPrompted; |
|
52 uint32_t mPromptResult; |
|
53 }; |
|
54 |
|
55 END_INDEXEDDB_NAMESPACE |
|
56 |
|
57 #endif // mozilla_dom_indexeddb_checkpermissionshelper_h__ |