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,
access: ["read"]
},
"device-storage:crashes": {
app: DENY_ACTION,
privileged: DENY_ACTION,
certified: ALLOW_ACTION,
access: ["read"]
},
"device-storage:pictures": {
app: DENY_ACTION,
privileged: PROMPT_ACTION,

View File

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

View File

@ -184,6 +184,7 @@ public:
nsCOMPtr<nsIFile> apps;
nsCOMPtr<nsIFile> sdcard;
#endif
nsCOMPtr<nsIFile> crashes;
nsCOMPtr<nsIFile> temp;
};
@ -268,8 +269,9 @@ DeviceStorageTypeChecker::Check(const nsAString& aType, nsIDOMBlob* aBlob)
}
if (aType.EqualsLiteral(DEVICESTORAGE_APPS) ||
aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) {
// Apps and sdcard have no restriction on mime types
aType.EqualsLiteral(DEVICESTORAGE_SDCARD) ||
aType.EqualsLiteral(DEVICESTORAGE_CRASHES)) {
// Apps, crashes and sdcard have no restriction on mime types
return true;
}
@ -282,8 +284,9 @@ DeviceStorageTypeChecker::Check(const nsAString& aType, nsIFile* aFile)
NS_ASSERTION(aFile, "Calling Check without a file");
if (aType.EqualsLiteral(DEVICESTORAGE_APPS) ||
aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) {
// apps have no restrictions on what file extensions used.
aType.EqualsLiteral(DEVICESTORAGE_SDCARD) ||
aType.EqualsLiteral(DEVICESTORAGE_CRASHES)) {
// Apps, crashes and sdcard have no restrictions on what file extensions used.
return true;
}
@ -362,7 +365,8 @@ DeviceStorageTypeChecker::GetPermissionForType(const nsAString& aType,
!aType.EqualsLiteral(DEVICESTORAGE_VIDEOS) &&
!aType.EqualsLiteral(DEVICESTORAGE_MUSIC) &&
!aType.EqualsLiteral(DEVICESTORAGE_APPS) &&
!aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) {
!aType.EqualsLiteral(DEVICESTORAGE_SDCARD) &&
!aType.EqualsLiteral(DEVICESTORAGE_CRASHES)) {
// unknown type
return NS_ERROR_FAILURE;
}
@ -402,11 +406,12 @@ bool
DeviceStorageTypeChecker::IsVolumeBased(const nsAString& aType)
{
#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
// with one per volume (as is the case for the remaining
// storage types).
return !aType.EqualsLiteral(DEVICESTORAGE_APPS);
return !aType.EqualsLiteral(DEVICESTORAGE_APPS) &&
!aType.EqualsLiteral(DEVICESTORAGE_CRASHES);
#else
return false;
#endif
@ -634,6 +639,21 @@ InitDirs()
}
#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)) {
dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(sDirs->temp));
@ -731,6 +751,11 @@ DeviceStorageFile::GetRootDirectoryForType(const nsAString& aStorageType,
#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
if (f && mozilla::Preferences::GetBool("device.storage.testing", false)) {
f = sDirs->temp;