Bug 791380 - Need on-phone equivalent of about:crashes r=dhylands

This commit is contained in:
Fabrice Desré 2013-08-23 07:59:03 -07:00
parent a4221268e1
commit ef0a016814
3 changed files with 39 additions and 7 deletions

View File

@ -69,6 +69,12 @@ this.PermissionsTable = { geolocation: {
certified: ALLOW_ACTION, certified: ALLOW_ACTION,
access: ["read"] access: ["read"]
}, },
"device-storage:crashes": {
app: DENY_ACTION,
privileged: DENY_ACTION,
certified: ALLOW_ACTION,
access: ["read"]
},
"device-storage:pictures": { "device-storage:pictures": {
app: DENY_ACTION, app: DENY_ACTION,
privileged: PROMPT_ACTION, privileged: PROMPT_ACTION,

View File

@ -21,6 +21,7 @@
#define DEVICESTORAGE_MUSIC "music" #define DEVICESTORAGE_MUSIC "music"
#define DEVICESTORAGE_APPS "apps" #define DEVICESTORAGE_APPS "apps"
#define DEVICESTORAGE_SDCARD "sdcard" #define DEVICESTORAGE_SDCARD "sdcard"
#define DEVICESTORAGE_CRASHES "crashes"
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {

View File

@ -184,6 +184,7 @@ public:
nsCOMPtr<nsIFile> apps; nsCOMPtr<nsIFile> apps;
nsCOMPtr<nsIFile> sdcard; nsCOMPtr<nsIFile> sdcard;
#endif #endif
nsCOMPtr<nsIFile> crashes;
nsCOMPtr<nsIFile> temp; nsCOMPtr<nsIFile> temp;
}; };
@ -268,8 +269,9 @@ DeviceStorageTypeChecker::Check(const nsAString& aType, nsIDOMBlob* aBlob)
} }
if (aType.EqualsLiteral(DEVICESTORAGE_APPS) || if (aType.EqualsLiteral(DEVICESTORAGE_APPS) ||
aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) { aType.EqualsLiteral(DEVICESTORAGE_SDCARD) ||
// Apps and sdcard have no restriction on mime types aType.EqualsLiteral(DEVICESTORAGE_CRASHES)) {
// Apps, crashes and sdcard have no restriction on mime types
return true; return true;
} }
@ -282,8 +284,9 @@ DeviceStorageTypeChecker::Check(const nsAString& aType, nsIFile* aFile)
NS_ASSERTION(aFile, "Calling Check without a file"); NS_ASSERTION(aFile, "Calling Check without a file");
if (aType.EqualsLiteral(DEVICESTORAGE_APPS) || if (aType.EqualsLiteral(DEVICESTORAGE_APPS) ||
aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) { aType.EqualsLiteral(DEVICESTORAGE_SDCARD) ||
// apps have no restrictions on what file extensions used. aType.EqualsLiteral(DEVICESTORAGE_CRASHES)) {
// Apps, crashes and sdcard have no restrictions on what file extensions used.
return true; return true;
} }
@ -362,7 +365,8 @@ DeviceStorageTypeChecker::GetPermissionForType(const nsAString& aType,
!aType.EqualsLiteral(DEVICESTORAGE_VIDEOS) && !aType.EqualsLiteral(DEVICESTORAGE_VIDEOS) &&
!aType.EqualsLiteral(DEVICESTORAGE_MUSIC) && !aType.EqualsLiteral(DEVICESTORAGE_MUSIC) &&
!aType.EqualsLiteral(DEVICESTORAGE_APPS) && !aType.EqualsLiteral(DEVICESTORAGE_APPS) &&
!aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) { !aType.EqualsLiteral(DEVICESTORAGE_SDCARD) &&
!aType.EqualsLiteral(DEVICESTORAGE_CRASHES)) {
// unknown type // unknown type
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -402,11 +406,12 @@ bool
DeviceStorageTypeChecker::IsVolumeBased(const nsAString& aType) DeviceStorageTypeChecker::IsVolumeBased(const nsAString& aType)
{ {
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
// The apps aren't stored in the same place as the media, so // The apps and crashes aren't stored in the same place as the media, so
// we only ever return a single apps object, and not an array // we only ever return a single apps object, and not an array
// with one per volume (as is the case for the remaining // with one per volume (as is the case for the remaining
// storage types). // storage types).
return !aType.EqualsLiteral(DEVICESTORAGE_APPS); return !aType.EqualsLiteral(DEVICESTORAGE_APPS) &&
!aType.EqualsLiteral(DEVICESTORAGE_CRASHES);
#else #else
return false; return false;
#endif #endif
@ -634,6 +639,21 @@ InitDirs()
} }
#endif // !MOZ_WIDGET_GONK #endif // !MOZ_WIDGET_GONK
if (XRE_GetProcessType() == GeckoProcessType_Default) {
NS_GetSpecialDirectory("UAppData", getter_AddRefs(sDirs->crashes));
if (sDirs->crashes) {
sDirs->crashes->Append(NS_LITERAL_STRING("Crash Reports"));
}
} else {
// NS_GetSpecialDirectory("UAppData") fails in content processes because
// gAppData from toolkit/xre/nsAppRunner.cpp is not initialized.
#ifdef MOZ_WIDGET_GONK
NS_NewLocalFile(NS_LITERAL_STRING("/data/b2g/mozilla/Crash Reports"),
false,
getter_AddRefs(sDirs->crashes));
#endif
}
if (mozilla::Preferences::GetBool("device.storage.testing", false)) { if (mozilla::Preferences::GetBool("device.storage.testing", false)) {
dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(sDirs->temp)); getter_AddRefs(sDirs->temp));
@ -731,6 +751,11 @@ DeviceStorageFile::GetRootDirectoryForType(const nsAString& aStorageType,
#endif #endif
} }
// crash reports directory.
else if (aStorageType.EqualsLiteral(DEVICESTORAGE_CRASHES)) {
f = sDirs->crashes;
}
// in testing, we default all device storage types to a temp directory // in testing, we default all device storage types to a temp directory
if (f && mozilla::Preferences::GetBool("device.storage.testing", false)) { if (f && mozilla::Preferences::GetBool("device.storage.testing", false)) {
f = sDirs->temp; f = sDirs->temp;