Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | Components.utils.import("resource://gre/modules/Services.jsm"); |
michael@0 | 6 | |
michael@0 | 7 | this.EXPORTED_SYMBOLS = [ |
michael@0 | 8 | "CrashReports" |
michael@0 | 9 | ]; |
michael@0 | 10 | |
michael@0 | 11 | this.CrashReports = { |
michael@0 | 12 | pendingDir: null, |
michael@0 | 13 | reportsDir: null, |
michael@0 | 14 | submittedDir: null, |
michael@0 | 15 | getReports: function CrashReports_getReports() |
michael@0 | 16 | { |
michael@0 | 17 | let reports = []; |
michael@0 | 18 | |
michael@0 | 19 | try { |
michael@0 | 20 | // Ignore any non http/https urls |
michael@0 | 21 | if (!/^https?:/i.test(Services.prefs.getCharPref("breakpad.reportURL"))) |
michael@0 | 22 | return reports; |
michael@0 | 23 | } |
michael@0 | 24 | catch (e) { } |
michael@0 | 25 | |
michael@0 | 26 | if (this.submittedDir.exists() && this.submittedDir.isDirectory()) { |
michael@0 | 27 | let entries = this.submittedDir.directoryEntries; |
michael@0 | 28 | while (entries.hasMoreElements()) { |
michael@0 | 29 | let file = entries.getNext().QueryInterface(Components.interfaces.nsIFile); |
michael@0 | 30 | let leaf = file.leafName; |
michael@0 | 31 | if (leaf.startsWith("bp-") && |
michael@0 | 32 | leaf.endsWith(".txt")) { |
michael@0 | 33 | let entry = { |
michael@0 | 34 | id: leaf.slice(0, -4), |
michael@0 | 35 | date: file.lastModifiedTime, |
michael@0 | 36 | pending: false |
michael@0 | 37 | }; |
michael@0 | 38 | reports.push(entry); |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | if (this.pendingDir.exists() && this.pendingDir.isDirectory()) { |
michael@0 | 44 | let uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; |
michael@0 | 45 | let entries = this.pendingDir.directoryEntries; |
michael@0 | 46 | while (entries.hasMoreElements()) { |
michael@0 | 47 | let file = entries.getNext().QueryInterface(Components.interfaces.nsIFile); |
michael@0 | 48 | let leaf = file.leafName; |
michael@0 | 49 | let id = leaf.slice(0, -4); |
michael@0 | 50 | if (leaf.endsWith(".dmp") && uuidRegex.test(id)) { |
michael@0 | 51 | let entry = { |
michael@0 | 52 | id: id, |
michael@0 | 53 | date: file.lastModifiedTime, |
michael@0 | 54 | pending: true |
michael@0 | 55 | }; |
michael@0 | 56 | reports.push(entry); |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | // Sort reports descending by date |
michael@0 | 62 | return reports.sort( (a, b) => b.date - a.date); |
michael@0 | 63 | } |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | function CrashReports_pendingDir() |
michael@0 | 67 | { |
michael@0 | 68 | let pendingDir = Services.dirsvc.get("UAppData", Components.interfaces.nsIFile); |
michael@0 | 69 | pendingDir.append("Crash Reports"); |
michael@0 | 70 | pendingDir.append("pending"); |
michael@0 | 71 | return pendingDir; |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | function CrashReports_reportsDir() |
michael@0 | 75 | { |
michael@0 | 76 | let reportsDir = Services.dirsvc.get("UAppData", Components.interfaces.nsIFile); |
michael@0 | 77 | reportsDir.append("Crash Reports"); |
michael@0 | 78 | return reportsDir; |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | function CrashReports_submittedDir() |
michael@0 | 82 | { |
michael@0 | 83 | let submittedDir = Services.dirsvc.get("UAppData", Components.interfaces.nsIFile); |
michael@0 | 84 | submittedDir.append("Crash Reports"); |
michael@0 | 85 | submittedDir.append("submitted"); |
michael@0 | 86 | return submittedDir; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | this.CrashReports.pendingDir = CrashReports_pendingDir(); |
michael@0 | 90 | this.CrashReports.reportsDir = CrashReports_reportsDir(); |
michael@0 | 91 | this.CrashReports.submittedDir = CrashReports_submittedDir(); |