diff options
Diffstat (limited to 'toolkit/mozapps')
25 files changed, 151 insertions, 890 deletions
diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index 3913c2088..d4c3a6967 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -2671,6 +2671,8 @@ this.AddonManager = { ERROR_CORRUPT_FILE: -3, // An error occured trying to write to the filesystem. ERROR_FILE_ACCESS: -4, + // The downloaded file seems to be Jetpack. + ERROR_JETPACKSDK_FILE: -8, // The downloaded file seems to be WebExtension. ERROR_WEBEXT_FILE: -9, diff --git a/toolkit/mozapps/extensions/AddonPathService.cpp b/toolkit/mozapps/extensions/AddonPathService.cpp index 006149100..ddfdbe817 100644 --- a/toolkit/mozapps/extensions/AddonPathService.cpp +++ b/toolkit/mozapps/extensions/AddonPathService.cpp @@ -128,6 +128,16 @@ AddonPathService::InsertPath(const nsAString& path, const nsAString& addonIdStri return NS_OK; } +NS_IMETHODIMP +AddonPathService::MapURIToAddonId(nsIURI* aURI, nsAString& addonIdString) +{ + if (JSAddonId* id = MapURIToAddonID(aURI)) { + JSFlatString* flat = JS_ASSERT_STRING_IS_FLAT(JS::StringOfAddonId(id)); + AssignJSFlatString(addonIdString, flat); + } + return NS_OK; +} + static nsresult ResolveURI(nsIURI* aURI, nsAString& out) { diff --git a/toolkit/mozapps/extensions/amIAddonPathService.idl b/toolkit/mozapps/extensions/amIAddonPathService.idl index 863689858..9c9197a61 100644 --- a/toolkit/mozapps/extensions/amIAddonPathService.idl +++ b/toolkit/mozapps/extensions/amIAddonPathService.idl @@ -5,6 +5,8 @@ #include "nsISupports.idl" +interface nsIURI; + /** * This service maps file system paths where add-ons reside to the ID * of the add-on. Paths are added by the add-on manager. They can @@ -26,4 +28,10 @@ interface amIAddonPathService : nsISupports * associated with the given add-on ID. */ void insertPath(in AString path, in AString addonId); + + /** + * Given a URI to a file, return the ID of the add-on that the file belongs + * to. Returns an empty string if there is no add-on there. + */ + AString mapURIToAddonId(in nsIURI aURI); }; diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 8d9c132e6..fc4392231 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -18,10 +18,12 @@ Cu.import("resource://gre/modules/addons/AddonRepository.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm"); +#ifdef MOZ_DEVTOOLS XPCOMUtils.defineLazyGetter(this, "BrowserToolboxProcess", function () { return Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm", {}). BrowserToolboxProcess; }); +#endif const PREF_DISCOVERURL = "extensions.webservice.discoverURL"; const PREF_DISCOVER_ENABLED = "extensions.getAddons.showPane"; @@ -1002,6 +1004,7 @@ var gViewController = { } }, +#ifdef MOZ_DEVTOOLS cmd_debugItem: { doCommand: function cmd_debugItem_doCommand(aAddon) { BrowserToolboxProcess.init({ addonID: aAddon.id }); @@ -1015,6 +1018,7 @@ var gViewController = { return aAddon && aAddon.isDebuggable && debuggerEnabled && remoteEnabled; } }, +#endif cmd_showItemPreferences: { isEnabled: function cmd_showItemPreferences_isEnabled(aAddon) { diff --git a/toolkit/mozapps/extensions/content/extensions.xml b/toolkit/mozapps/extensions/content/extensions.xml index fab340540..cbd05bfa9 100644 --- a/toolkit/mozapps/extensions/content/extensions.xml +++ b/toolkit/mozapps/extensions/content/extensions.xml @@ -9,6 +9,8 @@ %extensionsDTD; <!ENTITY % aboutDTD SYSTEM "chrome://mozapps/locale/extensions/about.dtd"> %aboutDTD; +<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" > +%brandDTD; ]> <bindings id="addonBindings" @@ -855,8 +857,10 @@ <xul:label anonid="name" class="name" crop="end" flex="1" xbl:inherits="value=name,tooltiptext=name"/> <xul:label anonid="version" class="version"/> +#ifdef MOZ_PHOENIX_EXTENSIONS <xul:label class="nativeIndicator nativeAddon" value="●" tooltiptext="&addon.nativeAddon;"/> <xul:label class="nativeIndicator compatAddon" value="●" tooltiptext="&addon.compatAddon;"/> +#endif <xul:label class="disabled-postfix" value="&addon.disabled.postfix;"/> <xul:label class="update-postfix" value="&addon.update.postfix;"/> <xul:spacer flex="5000"/> <!-- Necessary to make the name crop --> @@ -1362,8 +1366,10 @@ [this.mAddon.name], 1); } else { this.removeAttribute("notification"); +#ifdef MOZ_PHOENIX_EXTENSIONS if (this.mAddon.type == "extension") this.setAttribute("native", this.mAddon.native); +#endif } } @@ -1622,11 +1628,13 @@ ]]></body> </method> +#ifdef MOZ_DEVTOOLS <method name="debug"> <body><![CDATA[ gViewController.doCommand("cmd_debugItem", this.mAddon); ]]></body> </method> +#endif <method name="showPreferences"> <body><![CDATA[ diff --git a/toolkit/mozapps/extensions/content/extensions.xul b/toolkit/mozapps/extensions/content/extensions.xul index c1a8edc86..c5eeb534f 100644 --- a/toolkit/mozapps/extensions/content/extensions.xul +++ b/toolkit/mozapps/extensions/content/extensions.xul @@ -53,8 +53,10 @@ <menuitem id="menuitem_uninstallItem" command="cmd_uninstallItem" label="&cmd.uninstallAddon.label;" accesskey="&cmd.uninstallAddon.accesskey;"/> +#ifdef MOZ_DEVTOOLS <menuitem id="menuitem_debugItem" command="cmd_debugItem" label="&cmd.debugAddon.label;"/> +#endif <menuseparator id="addonitem-menuseparator" /> <menuitem id="menuitem_preferences" command="cmd_showItemPreferences" #ifdef XP_WIN @@ -101,7 +103,9 @@ <command id="cmd_findItemUpdates"/> <command id="cmd_showItemPreferences"/> <command id="cmd_showItemAbout"/> +#ifdef MOZ_DEVTOOLS <command id="cmd_debugItem"/> +#endif <command id="cmd_enableItem"/> <command id="cmd_disableItem"/> <command id="cmd_installItem"/> @@ -631,9 +635,11 @@ #endif command="cmd_showItemPreferences"/> <spacer flex="1"/> +#ifdef MOZ_DEVTOOLS <button id="detail-debug-btn" class="addon-control debug" label="Debug" command="cmd_debugItem" /> +#endif <button id="detail-enable-btn" class="addon-control enable" label="&cmd.enableAddon.label;" accesskey="&cmd.enableAddon.accesskey;" diff --git a/toolkit/mozapps/extensions/extensions.manifest b/toolkit/mozapps/extensions/extensions.manifest index f0f00545f..14aca3ff6 100644 --- a/toolkit/mozapps/extensions/extensions.manifest +++ b/toolkit/mozapps/extensions/extensions.manifest @@ -1,7 +1,6 @@ component {66354bc9-7ed1-4692-ae1d-8da97d6b205e} nsBlocklistService.js contract @mozilla.org/extensions/blocklist;1 {66354bc9-7ed1-4692-ae1d-8da97d6b205e} category profile-after-change nsBlocklistService @mozilla.org/extensions/blocklist;1 -#ifndef MOZ_WIDGET_GONK category update-timer nsBlocklistService @mozilla.org/extensions/blocklist;1,getService,blocklist-background-update-timer,extensions.blocklist.interval,86400 component {4399533d-08d1-458c-a87a-235f74451cfa} addonManager.js contract @mozilla.org/addons/integration;1 {4399533d-08d1-458c-a87a-235f74451cfa} @@ -17,4 +16,3 @@ category JavaScript-global-property InstallTrigger @mozilla.org/addons/installtr category addon-provider-module PluginProvider resource://gre/modules/addons/PluginProvider.jsm #endif category addon-provider-module GMPProvider resource://gre/modules/addons/GMPProvider.jsm -#endif diff --git a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm index 939e2e269..8d742ea42 100644 --- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm +++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm @@ -766,8 +766,17 @@ this.AddonUpdateChecker = { * down in-progress update requests */ checkForUpdates: function AUC_checkForUpdates(aId, aUpdateKey, aUrl, aObserver) { - // Exclude default theme - if (aId != "{972ce4c6-7e08-4474-a285-3208198ce6fd}") + // Define an array of internally used IDs to NOT send to AUS such as the + // Default Theme. Please keep this list in sync with: + // toolkit/mozapps/webextensions/AddonUpdateChecker.jsm + let internalIDS = [ + '{972ce4c6-7e08-4474-a285-3208198ce6fd}', + 'modern@themes.mozilla.org' + ]; + + // If the ID is not in the array then go ahead and query AUS + if (internalIDS.indexOf(aId) == -1) { return new UpdateParser(aId, aUpdateKey, aUrl, aObserver); + } } }; diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index c43811ba8..5b3585cd8 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -36,8 +36,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task", "resource://gre/modules/Task.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); +#ifdef MOZ_DEVTOOLS XPCOMUtils.defineLazyModuleGetter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm"); +#endif XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPI", "resource://gre/modules/Console.jsm"); @@ -52,6 +54,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "ResProtocolHandler", "@mozilla.org/network/protocol;1?name=resource", "nsIResProtocolHandler"); +XPCOMUtils.defineLazyServiceGetter(this, + "AddonPathService", + "@mozilla.org/addon-path-service;1", + "amIAddonPathService"); const nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile", "initWithPath"); @@ -106,6 +112,10 @@ const DIR_TRASH = "trash"; const FILE_DATABASE = "extensions.json"; const FILE_OLD_CACHE = "extensions.cache"; const FILE_INSTALL_MANIFEST = "install.rdf"; +#ifndef MOZ_JETPACK +const FILE_JETPACK_MANIFEST_1 = "harness-options.json"; +const FILE_JETPACK_MANIFEST_2 = "package.json"; +#endif const FILE_WEBEXT_MANIFEST = "manifest.json"; const FILE_XPI_ADDONS_LIST = "extensions.ini"; @@ -134,7 +144,9 @@ const FIREFOX_APPCOMPATVERSION = "56.9" // The value for this is in Makefile.in #expand const DB_SCHEMA = __MOZ_EXTENSIONS_DB_SCHEMA__; +#ifdef MOZ_DEVTOOLS const NOTIFICATION_TOOLBOXPROCESS_LOADED = "ToolboxProcessLoaded"; +#endif // Properties that exist in the install manifest const PROP_METADATA = ["id", "version", "type", "internalName", "updateURL", @@ -1059,37 +1071,36 @@ function loadManifestFromDir(aDir) { * @throws if the XPI file does not contain a valid install manifest. * Throws with |webext:true| if a WebExtension manifest was found * to distinguish between WebExtensions and corrupt files. + * Throws with |jetpacksdk:true| if a Jetpack files were found + * if Jetpack its self isn't built. */ function loadManifestFromZipReader(aZipReader) { - let zis; - try { - zis = aZipReader.getInputStream(FILE_INSTALL_MANIFEST); - } catch (e) { - // We're going to throw here, but depending on whether we have a - // WebExtension manifest in the XPI, we'll throw with the webext flag. - try { - let zws = aZipReader.getInputStream(FILE_WEBEXT_MANIFEST); - zws.close(); - } catch(e2) { - // We have neither an install manifest nor a WebExtension manifest; - // this means the extension file has a structural problem. - // Just pass the original error up the chain in that case. + // If WebExtension but not install.rdf throw an error + if (aZipReader.hasEntry(FILE_WEBEXT_MANIFEST)) { + if (!aZipReader.hasEntry(FILE_INSTALL_MANIFEST)) { throw { - name: e.name, - message: e.message + name: "UnsupportedExtension", + message: Services.appinfo.name + " does not support WebExtensions", + webext: true }; } - // If we get here, we have a WebExtension manifest but no install - // manifest. Pass the error up the chain with the webext flag. + } + +#ifndef MOZ_JETPACK + // If Jetpack is not built throw an error + if (aZipReader.hasEntry(FILE_JETPACK_MANIFEST_1) || + aZipReader.hasEntry(FILE_JETPACK_MANIFEST_2)) { throw { - name: e.name, - message: e.message, - webext: true + name: "UnsupportedExtension", + message: Services.appinfo.name + " does not support Jetpack Extensions", + jetpacksdk: true }; } - - // We found an install manifest, so it's either a regular or hybrid - // extension. Continue processing. +#endif + + // Attempt to open install.rdf else throw normally + let zis = aZipReader.getInputStream(FILE_INSTALL_MANIFEST); + // Create a buffered input stream for install.rdf let bis = Cc["@mozilla.org/network/buffered-input-stream;1"]. createInstance(Ci.nsIBufferedInputStream); bis.init(zis, 4096); @@ -1118,7 +1129,9 @@ function loadManifestFromZipReader(aZipReader) { return addon; } finally { + // Close the buffered input stream bis.close(); + // Close the input stream to install.rdf zis.close(); } } @@ -1842,8 +1855,10 @@ this.XPIProvider = { _enabledExperiments: null, // A Map from an add-on install to its ID _addonFileMap: new Map(), +#ifdef MOZ_DEVTOOLS // Flag to know if ToolboxProcess.jsm has already been loaded by someone or not _toolboxProcessLoaded: false, +#endif // Have we started shutting down bootstrap add-ons? _closing: false, @@ -1887,8 +1902,7 @@ this.XPIProvider = { logger.info("Mapping " + aID + " to " + aFile.path); this._addonFileMap.set(aID, aFile.path); - let service = Cc["@mozilla.org/addon-path-service;1"].getService(Ci.amIAddonPathService); - service.insertPath(aFile.path, aID); + AddonPathService.insertPath(aFile.path, aID); }, /** @@ -2080,6 +2094,8 @@ this.XPIProvider = { Services.prefs.addObserver(PREF_EM_MIN_COMPAT_APP_VERSION, this, false); Services.prefs.addObserver(PREF_EM_MIN_COMPAT_PLATFORM_VERSION, this, false); Services.obs.addObserver(this, NOTIFICATION_FLUSH_PERMISSIONS, false); + +#ifdef MOZ_DEVTOOLS if (Cu.isModuleLoaded("resource://devtools/client/framework/ToolboxProcess.jsm")) { // If BrowserToolboxProcess is already loaded, set the boolean to true // and do whatever is needed @@ -2091,6 +2107,7 @@ this.XPIProvider = { // Else, wait for it to load Services.obs.addObserver(this, NOTIFICATION_TOOLBOXPROCESS_LOADED, false); } +#endif let flushCaches = this.checkForChanges(aAppChanged, aOldAppVersion, aOldPlatformVersion); @@ -3916,16 +3933,8 @@ this.XPIProvider = { * @see amIAddonManager.mapURIToAddonID */ mapURIToAddonID: function XPI_mapURIToAddonID(aURI) { - let resolved = this._resolveURIToFile(aURI); - if (!resolved || !(resolved instanceof Ci.nsIFileURL)) - return null; - - for (let [id, path] of this._addonFileMap) { - if (resolved.file.path.startsWith(path)) - return id; - } - - return null; + // Returns `null` instead of empty string if the URI can't be mapped. + return AddonPathService.mapURIToAddonId(aURI) || null; }, /** @@ -4093,12 +4102,14 @@ this.XPIProvider = { } return; } +#ifdef MOZ_DEVTOOLS else if (aTopic == NOTIFICATION_TOOLBOXPROCESS_LOADED) { Services.obs.removeObserver(this, NOTIFICATION_TOOLBOXPROCESS_LOADED, false); this._toolboxProcessLoaded = true; BrowserToolboxProcess.on("connectionchange", this.onDebugConnectionChange.bind(this)); } +#endif if (aTopic == "nsPref:changed") { switch (aData) { @@ -4363,12 +4374,14 @@ this.XPIProvider = { logger.warn("Error loading bootstrap.js for " + aId, e); } +#ifdef MOZ_DEVTOOLS // Only access BrowserToolboxProcess if ToolboxProcess.jsm has been // initialized as otherwise, when it will be initialized, all addons' // globals will be added anyways if (this._toolboxProcessLoaded) { BrowserToolboxProcess.setAddonOptions(aId, { global: this.bootstrapScopes[aId] }); } +#endif }, /** @@ -4388,11 +4401,13 @@ this.XPIProvider = { this.persistBootstrappedAddons(); this.addAddonsToCrashReporter(); +#ifdef MOZ_DEVTOOLS // Only access BrowserToolboxProcess if ToolboxProcess.jsm has been // initialized as otherwise, there won't be any addon globals added to it if (this._toolboxProcessLoaded) { BrowserToolboxProcess.setAddonOptions(aId, { global: null }); } +#endif }, /** @@ -5010,6 +5025,11 @@ AddonInstall.prototype = { if (e.webext) { logger.warn("WebExtension XPI", e); this.error = AddonManager.ERROR_WEBEXT_FILE; +#ifndef MOZ_JETPACK + } else if (e.jetpacksdk) { + logger.warn("Jetpack XPI", e); + this.error = AddonManager.ERROR_JETPACKSDK_FILE; +#endif } else { logger.warn("Invalid XPI", e); this.error = AddonManager.ERROR_CORRUPT_FILE; @@ -5651,6 +5671,10 @@ AddonInstall.prototype = { catch (e) { if (e.webext) { this.downloadFailed(AddonManager.ERROR_WEBEXT_FILE, e); +#ifndef MOZ_JETPACK + } else if (e.jetpacksdk) { + this.downloadFailed(AddonManager.ERROR_JETPACKSDK_FILE, e); +#endif } else { this.downloadFailed(AddonManager.ERROR_CORRUPT_FILE, e); } @@ -6447,21 +6471,23 @@ AddonInternal.prototype = { if (!aPlatformVersion) aPlatformVersion = Services.appinfo.platformVersion; +#ifdef MOZ_PHOENIX_EXTENSIONS this.native = false; - +#endif + let version; if (app.id == Services.appinfo.ID) { version = aAppVersion; +#ifdef MOZ_PHOENIX_EXTENSIONS this.native = true; } -#ifdef MOZ_PHOENIX_EXTENSIONS else if (app.id == FIREFOX_ID) { version = FIREFOX_APPCOMPATVERSION; if (this.type == "locale") //Never allow language packs in Firefox compatibility mode return false; - } #endif + } else if (app.id == TOOLKIT_ID) version = aPlatformVersion diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js index d26029455..6b37ed640 100644 --- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js @@ -70,7 +70,11 @@ const PROP_JSON_FIELDS = ["id", "syncGUID", "location", "version", "type", "skinnable", "size", "sourceURI", "releaseNotesURI", "softDisabled", "foreignInstall", "hasBinaryComponents", "strictCompatibility", "locales", "targetApplications", - "targetPlatforms", "multiprocessCompatible", "native"]; + "targetPlatforms", "multiprocessCompatible", +#ifdef MOZ_PHOENIX_EXTENSIONS + "native" +#endif + ]; // Time to wait before async save of XPI JSON database, in milliseconds const ASYNC_SAVE_DELAY_MS = 20; diff --git a/toolkit/mozapps/extensions/nsBlocklistService.js b/toolkit/mozapps/extensions/nsBlocklistService.js index 936c9d1b5..487dae8e5 100644 --- a/toolkit/mozapps/extensions/nsBlocklistService.js +++ b/toolkit/mozapps/extensions/nsBlocklistService.js @@ -910,7 +910,7 @@ Blocklist.prototype = { let issuer = blocklistElement.getAttribute("issuerName"); for (let snElement of blocklistElement.children) { try { - gCertBlocklistService.addRevokedCert(issuer, snElement.textContent); + gCertBlocklistService.revokeCertByIssuerAndSerial(issuer, snElement.textContent); } catch (e) { // we want to keep trying other elements since missing all items // is worse than missing one diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js index a6f9c8052..a153256dc 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js @@ -95,8 +95,10 @@ function run_test_early() { "resource://gre/modules/addons/XPIProvider.jsm", {}); // Make the early API call. - do_check_null(s.XPIProvider.mapURIToAddonID(uri)); + // AddonManager still misses its provider and so doesn't work yet. do_check_null(AddonManager.mapURIToAddonID(uri)); + // But calling XPIProvider directly works immediately + do_check_eq(s.XPIProvider.mapURIToAddonID(uri), id); // Actually start up the manager. startupManager(false); diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini index 2a12f147a..51419a6e3 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini @@ -1,6 +1,6 @@ # The file is shared between the two main xpcshell manifest files. [DEFAULT] -skip-if = toolkit == 'android' || toolkit == 'gonk' +skip-if = toolkit == 'android' [test_AddonRepository.js] # Bug 676992: test consistently hangs on Android diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini index 51520f888..1f4fd692e 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini @@ -2,7 +2,7 @@ head = head_addons.js head_unpack.js tail = firefox-appdir = browser -skip-if = toolkit == 'android' || toolkit == 'gonk' +skip-if = toolkit == 'android' dupe-manifest = [include:xpcshell-shared.ini] diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini index 83ab77c74..afe13895d 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini @@ -1,5 +1,5 @@ [DEFAULT] -skip-if = buildapp == 'mulet' || toolkit == 'android' || toolkit == 'gonk' +skip-if = buildapp == 'mulet' || toolkit == 'android' head = head_addons.js tail = firefox-appdir = browser diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js b/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js index 917f2465d..b24bce4b5 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js @@ -13,6 +13,13 @@ function setup_redirect(aSettings) { } function test() { + waitForExplicitFinish(); + SpecialPowers.pushPrefEnv({ + "set": [["security.data_uri.block_toplevel_data_uri_navigations", false]] + }, runTest); +} + +function runTest() { Harness.installOriginBlockedCallback = install_blocked; Harness.installsCompletedCallback = finish_test; Harness.setup(); @@ -33,4 +40,5 @@ function finish_test(count) { gBrowser.removeCurrentTab(); Harness.finish(); + finish(); } diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js index e23ab3f40..0cf7b8938 100644 --- a/toolkit/mozapps/update/nsUpdateService.js +++ b/toolkit/mozapps/update/nsUpdateService.js @@ -55,8 +55,6 @@ const URI_UPDATES_PROPERTIES = "chrome://mozapps/locale/update/updates.proper const KEY_UPDROOT = "UpdRootD"; const KEY_EXECUTABLE = "XREExeF"; -// Gonk only -const KEY_UPDATE_ARCHIVE_DIR = "UpdArchD"; const DIR_UPDATES = "updates"; @@ -198,17 +196,6 @@ const APPID_TO_TOPIC = { var gUpdateMutexHandle = null; -// Gonk only -var gSDCardMountLock = null; - -// Gonk only -XPCOMUtils.defineLazyGetter(this, "gExtStorage", function aus_gExtStorage() { - if (AppConstants.platform != "gonk") { - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - } - return Services.env.get("EXTERNAL_STORAGE"); -}); - XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils", "resource://gre/modules/UpdateUtils.jsm"); @@ -564,13 +551,6 @@ function getCanStageUpdates() { return true; } - // For Gonk, the updater will remount the /system partition to move staged - // files into place. - if (AppConstants.platform == "gonk") { - LOG("getCanStageUpdates - able to stage updates because this is gonk"); - return true; - } - if (!hasUpdateMutex()) { LOG("getCanStageUpdates - unable to apply updates because another " + "instance of the application is already handling updates for this " + @@ -798,105 +778,6 @@ function writeVersionFile(dir, version) { } /** - * Gonk only function that reads the link file specified in the update.link file - * in the specified directory and returns the nsIFile for the corresponding - * file. - * @param dir - * The dir to look for an update.link file in - * @return A nsIFile for the file path specified in the - * update.link file or null if the update.link file - * doesn't exist. - */ -function getFileFromUpdateLink(dir) { - if (AppConstants.platform != "gonk") { - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - } - let linkFile = dir.clone(); - linkFile.append(FILE_UPDATE_LINK); - let link = readStringFromFile(linkFile); - LOG("getFileFromUpdateLink linkFile.path: " + linkFile.path + ", link: " + link); - if (!link) { - return null; - } - let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile); - file.initWithPath(link); - return file; -} - -/** - * Gonk only function to create a link file. This allows the actual patch to - * live in a directory different from the update directory. - * @param dir - * The patch directory where the update.link file - * should be written. - * @param patchFile - * The fully qualified filename of the patchfile. - */ -function writeLinkFile(dir, patchFile) { - if (AppConstants.platform != "gonk") { - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - } - let linkFile = dir.clone(); - linkFile.append(FILE_UPDATE_LINK); - writeStringToFile(linkFile, patchFile.path); - if (patchFile.path.indexOf(gExtStorage) == 0) { - // The patchfile is being stored on external storage. Try to lock it - // so that it doesn't get shared with the PC while we're downloading - // to it. - acquireSDCardMountLock(); - } -} - -/** - * Gonk only function to acquire a VolumeMountLock for the sdcard volume. - * - * This prevents the SDCard from being shared with the PC while - * we're downloading the update. - */ -function acquireSDCardMountLock() { - if (AppConstants.platform != "gonk") { - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - } - let volsvc = Cc["@mozilla.org/telephony/volume-service;1"]. - getService(Ci.nsIVolumeService); - if (volsvc) { - gSDCardMountLock = volsvc.createMountLock("sdcard"); - } -} - -/** - * Gonk only function that determines if the state corresponds to an - * interrupted update. This could either be because the download was - * interrupted, or because staging the update was interrupted. - * - * @return true if the state corresponds to an interrupted - * update. - */ -function isInterruptedUpdate(status) { - if (AppConstants.platform != "gonk") { - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - } - return (status == STATE_DOWNLOADING) || - (status == STATE_PENDING) || - (status == STATE_APPLYING); -} - -/** - * Releases any SDCard mount lock that we might have. - * - * This once again allows the SDCard to be shared with the PC. - */ -function releaseSDCardMountLock() { - if (AppConstants.platform != "gonk") { - throw Cr.NS_ERROR_UNEXPECTED; - } - if (gSDCardMountLock) { - gSDCardMountLock.unlock(); - gSDCardMountLock = null; - } -} - -/** * Determines if the service should be used to attempt an update * or not. * @@ -1058,14 +939,6 @@ function cleanUpUpdatesDir(aRemovePatchFiles = true) { let dirEntries = updateDir.directoryEntries; while (dirEntries.hasMoreElements()) { let file = dirEntries.getNext().QueryInterface(Ci.nsIFile); - if (AppConstants.platform == "gonk") { - if (file.leafName == FILE_UPDATE_LINK) { - let linkedFile = getFileFromUpdateLink(updateDir); - if (linkedFile && linkedFile.exists()) { - linkedFile.remove(false); - } - } - } // Now, recursively remove this file. The recursive removal is needed for // Mac OSX because this directory will contain a copy of updater.app, @@ -1078,9 +951,6 @@ function cleanUpUpdatesDir(aRemovePatchFiles = true) { } } } - if (AppConstants.platform == "gonk") { - releaseSDCardMountLock(); - } } /** @@ -1809,12 +1679,6 @@ function UpdateService() { LOG("Creating UpdateService"); Services.obs.addObserver(this, "xpcom-shutdown", false); Services.prefs.addObserver(PREF_APP_UPDATE_LOG, this, false); - if (AppConstants.platform == "gonk") { - // PowerManagerService::SyncProfile (which is called for Reboot, PowerOff - // and Restart) sends the profile-change-net-teardown event. We can then - // pause the download in a similar manner to xpcom-shutdown. - Services.obs.addObserver(this, "profile-change-net-teardown", false); - } } UpdateService.prototype = { @@ -1980,23 +1844,6 @@ UpdateService.prototype = { } } - if (AppConstants.platform == "gonk") { - // This code is called very early in the boot process, before we've even - // had a chance to setup the UI so we can give feedback to the user. - // - // Since the download may be occuring over a link which has associated - // cost, we want to require user-consent before resuming the download. - // Also, applying an already downloaded update now is undesireable, - // since the phone will look dead while the update is being applied. - // Applying the update can take several minutes. Instead we wait until - // the UI is initialized so it is possible to give feedback to and get - // consent to update from the user. - if (isInterruptedUpdate(status)) { - LOG("UpdateService:_postUpdateProcessing - interrupted update detected - wait for user consent"); - return; - } - } - if (status == STATE_DOWNLOADING) { LOG("UpdateService:_postUpdateProcessing - patch found in downloading " + "state"); @@ -2038,34 +1885,6 @@ UpdateService.prototype = { return; } - if (AppConstants.platform == "gonk") { - // The update is only applied but not selected to be installed - if (status == STATE_APPLIED && update && update.isOSUpdate) { - LOG("UpdateService:_postUpdateProcessing - update staged as applied found"); - return; - } - - if (status == STATE_APPLIED_OS && update && update.isOSUpdate) { - // In gonk, we need to check for OS update status after startup, since - // the recovery partition won't write to update.status for us - let recoveryService = Cc["@mozilla.org/recovery-service;1"]. - getService(Ci.nsIRecoveryService); - let fotaStatus = recoveryService.getFotaUpdateStatus(); - switch (fotaStatus) { - case Ci.nsIRecoveryService.FOTA_UPDATE_SUCCESS: - status = STATE_SUCCEEDED; - break; - case Ci.nsIRecoveryService.FOTA_UPDATE_FAIL: - status = STATE_FAILED + ": " + FOTA_GENERAL_ERROR; - break; - case Ci.nsIRecoveryService.FOTA_UPDATE_UNKNOWN: - default: - status = STATE_FAILED + ": " + FOTA_UNKNOWN_ERROR; - break; - } - } - } - if (!update) { if (status != STATE_SUCCEEDED) { LOG("UpdateService:_postUpdateProcessing - previous patch failed " + @@ -2519,11 +2338,6 @@ UpdateService.prototype = { var um = Cc["@mozilla.org/updates/update-manager;1"]. getService(Ci.nsIUpdateManager); if (um.activeUpdate) { - if (AppConstants.platform == "gonk") { - // For gonk, the user isn't necessarily aware of the update, so we need - // to show the prompt to make sure. - this._showPrompt(um.activeUpdate); - } AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_HAS_ACTIVEUPDATE); return; } @@ -2714,21 +2528,6 @@ UpdateService.prototype = { } this._downloader.cancel(); } - if (AppConstants.platform == "gonk") { - let um = Cc["@mozilla.org/updates/update-manager;1"]. - getService(Ci.nsIUpdateManager); - let activeUpdate = um.activeUpdate; - if (activeUpdate && - (activeUpdate.appVersion != update.appVersion || - activeUpdate.buildID != update.buildID)) { - // We have an activeUpdate (which presumably was interrupted), and are - // about start downloading a new one. Make sure we remove all traces - // of the active one (otherwise we'll start appending the new update.mar - // the the one that's been partially downloaded). - LOG("UpdateService:downloadUpdate - removing stale active update."); - cleanupActiveUpdate(); - } - } // Set the previous application version prior to downloading the update. update.previousAppVersion = Services.appinfo.version; this._downloader = new Downloader(background, this); @@ -3142,21 +2941,6 @@ UpdateManager.prototype = { "the update was staged. state: " + update.state + ", status: " + status); Services.obs.notifyObservers(null, "update-staged", update.state); - if (AppConstants.platform == "gonk") { - // Do this after everything else, since it will likely cause the app to - // shut down. - if (update.state == STATE_APPLIED) { - // Notify the user that an update has been staged and is ready for - // installation (i.e. that they should restart the application). We do - // not notify on failed update attempts. - let prompter = Cc["@mozilla.org/updates/update-prompt;1"]. - createInstance(Ci.nsIUpdatePrompt); - prompter.showUpdateDownloaded(update, true); - } else { - releaseSDCardMountLock(); - } - return; - } // Only prompt when the UI isn't already open. let windowType = getPref("getCharPref", PREF_APP_UPDATE_ALTWINDOWTYPE, null); if (Services.wm.getMostRecentWindow(UPDATE_WINDOW_NAME) || @@ -3515,9 +3299,6 @@ Downloader.prototype = { if (this._request && this._request instanceof Ci.nsIRequest) { this._request.cancel(cancelError); } - if (AppConstants.platform == "gonk") { - releaseSDCardMountLock(); - } }, /** @@ -3647,17 +3428,8 @@ Downloader.prototype = { return selectedPatch; } - if (AppConstants.platform == "gonk") { - if (state == STATE_PENDING || state == STATE_APPLYING) { - LOG("Downloader:_selectPatch - resuming interrupted apply"); - return selectedPatch; - } - if (state == STATE_APPLIED) { - LOG("Downloader:_selectPatch - already downloaded and staged"); - return null; - } - } else if (state == STATE_PENDING || state == STATE_PENDING_SERVICE || - state == STATE_PENDING_ELEVATE) { + if (state == STATE_PENDING || state == STATE_PENDING_SERVICE || + state == STATE_PENDING_ELEVATE) { LOG("Downloader:_selectPatch - already downloaded and staged"); return null; } @@ -3719,15 +3491,7 @@ Downloader.prototype = { */ _getUpdateArchiveFile: function Downloader__getUpdateArchiveFile() { var updateArchive; - if (AppConstants.platform == "gonk") { - try { - updateArchive = FileUtils.getDir(KEY_UPDATE_ARCHIVE_DIR, [], true); - } catch (e) { - return null; - } - } else { - updateArchive = getUpdatesDir().clone(); - } + updateArchive = getUpdatesDir().clone(); updateArchive.append(FILE_UPDATE_MAR); return updateArchive; @@ -3761,71 +3525,6 @@ Downloader.prototype = { let patchFile = null; - // Only used by gonk - let status = STATE_NONE; - if (AppConstants.platform == "gonk") { - status = readStatusFile(updateDir); - if (isInterruptedUpdate(status)) { - LOG("Downloader:downloadUpdate - interruptted update"); - // The update was interrupted. Try to locate the existing patch file. - // For an interrupted download, this allows a resume rather than a - // re-download. - patchFile = getFileFromUpdateLink(updateDir); - if (!patchFile) { - // No link file. We'll just assume that the update.mar is in the - // update directory. - patchFile = updateDir.clone(); - patchFile.append(FILE_UPDATE_MAR); - } - if (patchFile.exists()) { - LOG("Downloader:downloadUpdate - resuming with patchFile " + patchFile.path); - if (patchFile.fileSize == this._patch.size) { - LOG("Downloader:downloadUpdate - patchFile appears to be fully downloaded"); - // Bump the status along so that we don't try to redownload again. - if (getElevationRequired()) { - status = STATE_PENDING_ELEVATE; - } else { - status = STATE_PENDING; - } - } - } else { - LOG("Downloader:downloadUpdate - patchFile " + patchFile.path + - " doesn't exist - performing full download"); - // The patchfile doesn't exist, we might as well treat this like - // a new download. - patchFile = null; - } - if (patchFile && status != STATE_DOWNLOADING) { - // It looks like the patch was downloaded, but got interrupted while it - // was being verified or applied. So we'll fake the downloading portion. - - if (getElevationRequired()) { - writeStatusFile(updateDir, STATE_PENDING_ELEVATE); - } else { - writeStatusFile(updateDir, STATE_PENDING); - } - - // Since the code expects the onStopRequest callback to happen - // asynchronously (And you have to call AUS_addDownloadListener - // after calling AUS_downloadUpdate) we need to defer this. - - this._downloadTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); - this._downloadTimer.initWithCallback(function() { - this._downloadTimer = null; - // Send a fake onStopRequest. Filling in the destination allows - // _verifyDownload to work, and then the update will be applied. - this._request = {destination: patchFile}; - this.onStopRequest(this._request, null, Cr.NS_OK); - }.bind(this), 0, Ci.nsITimer.TYPE_ONE_SHOT); - - // Returning STATE_DOWNLOADING makes UpdatePrompt think we're - // downloading. The onStopRequest that we spoofed above will make it - // look like the download finished. - return STATE_DOWNLOADING; - } - } - } - if (!patchFile) { // Find a place to put the patchfile that we're going to download. patchFile = this._getUpdateArchiveFile(); @@ -3836,19 +3535,6 @@ Downloader.prototype = { return STATE_NONE; } - if (AppConstants.platform == "gonk") { - if (patchFile.path.indexOf(updateDir.path) != 0) { - // The patchFile is in a directory which is different from the - // updateDir, create a link file. - writeLinkFile(updateDir, patchFile); - - if (!isInterruptedUpdate(status) && patchFile.exists()) { - // Remove stale patchFile - patchFile.remove(false); - } - } - } - update.QueryInterface(Ci.nsIPropertyBag); let interval = this.background ? update.getProperty("backgroundInterval") : DOWNLOAD_FOREGROUND_INTERVAL; @@ -4119,13 +3805,6 @@ Downloader.prototype = { this._update.statusText = getStatusTextFromCode(status, Cr.NS_BINDING_FAILED); - if (AppConstants.platform == "gonk") { - // bug891009: On FirefoxOS, manaully retry OTA download will reuse - // the Update object. We need to remove selected patch so that download - // can be triggered again successfully. - this._update.selectedPatch.selected = false; - } - // Destroy the updates directory, since we're done with it. cleanUpUpdatesDir(); @@ -4187,13 +3866,6 @@ Downloader.prototype = { } } - if (AppConstants.platform == "gonk") { - // We always forward errors in B2G, since Gaia controls the update UI - let prompter = Cc["@mozilla.org/updates/update-prompt;1"]. - createInstance(Ci.nsIUpdatePrompt); - prompter.showUpdateError(this._update); - } - // Prevent leaking the update object (bug 454964). this._update = null; } diff --git a/toolkit/mozapps/update/updater/automounter_gonk.cpp b/toolkit/mozapps/update/updater/automounter_gonk.cpp deleted file mode 100644 index 3dff2a133..000000000 --- a/toolkit/mozapps/update/updater/automounter_gonk.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include <android/log.h> -#include <cutils/android_reboot.h> -#include <errno.h> -#include <stdlib.h> -#include <sys/mount.h> -#include <sys/reboot.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> - -#include "automounter_gonk.h" -#include "updatedefines.h" -#include "updatelogging.h" - -#define LOG_TAG "GonkAutoMounter" - -#define GONK_LOG(level, format, ...) \ - LOG((LOG_TAG ": " format "\n", ##__VA_ARGS__)); \ - __android_log_print(level, LOG_TAG, format, ##__VA_ARGS__) - -#define LOGI(format, ...) GONK_LOG(ANDROID_LOG_INFO, format, ##__VA_ARGS__) -#define LOGE(format, ...) GONK_LOG(ANDROID_LOG_ERROR, format, ##__VA_ARGS__) - -const char *kGonkMountsPath = "/proc/mounts"; -const char *kGonkSystemPath = "/system"; - -GonkAutoMounter::GonkAutoMounter() : mDevice(nullptr), mAccess(Unknown) -{ - if (!RemountSystem(ReadWrite)) { - LOGE("Could not remount %s as read-write.", kGonkSystemPath); - } -} - -GonkAutoMounter::~GonkAutoMounter() -{ - bool result = RemountSystem(ReadOnly); - free(mDevice); - - if (!result) { - // Don't take any chances when remounting as read-only fails, just reboot. - Reboot(); - } -} - -void -GonkAutoMounter::Reboot() -{ - // The android_reboot wrapper provides more safety, doing fancier read-only - // remounting and attempting to sync() the filesystem first. If this fails - // our only hope is to force a reboot directly without these protections. - // For more, see system/core/libcutils/android_reboot.c - LOGE("Could not remount %s as read-only, forcing a system reboot.", - kGonkSystemPath); - LogFlush(); - - if (android_reboot(ANDROID_RB_RESTART, 0, nullptr) != 0) { - LOGE("Safe system reboot failed, attempting to force"); - LogFlush(); - - if (reboot(RB_AUTOBOOT) != 0) { - LOGE("CRITICAL: Failed to force restart"); - } - } -} - -static const char * -MountAccessToString(MountAccess access) -{ - switch (access) { - case ReadOnly: return "read-only"; - case ReadWrite: return "read-write"; - default: return "unknown"; - } -} - -bool -GonkAutoMounter::RemountSystem(MountAccess access) -{ - if (!UpdateMountStatus()) { - return false; - } - - if (mAccess == access) { - return true; - } - - unsigned long flags = MS_REMOUNT; - if (access == ReadOnly) { - flags |= MS_RDONLY; - // Give the system a chance to flush file buffers - sync(); - } - - if (!MountSystem(flags)) { - return false; - } - - // Check status again to verify /system has been properly remounted - if (!UpdateMountStatus()) { - return false; - } - - if (mAccess != access) { - LOGE("Updated mount status %s should be %s", - MountAccessToString(mAccess), - MountAccessToString(access)); - return false; - } - - return true; -} - -bool -GonkAutoMounter::UpdateMountStatus() -{ - FILE *mountsFile = NS_tfopen(kGonkMountsPath, "r"); - - if (mountsFile == nullptr) { - LOGE("Error opening %s: %s", kGonkMountsPath, strerror(errno)); - return false; - } - - // /proc/mounts returns a 0 size from fstat, so we use the same - // pre-allocated buffer size that ADB does here - const int mountsMaxSize = 4096; - char mountData[mountsMaxSize]; - size_t read = fread(mountData, 1, mountsMaxSize - 1, mountsFile); - mountData[read + 1] = '\0'; - - if (ferror(mountsFile)) { - LOGE("Error reading %s, %s", kGonkMountsPath, strerror(errno)); - fclose(mountsFile); - return false; - } - - char *token, *tokenContext; - bool foundSystem = false; - - for (token = strtok_r(mountData, "\n", &tokenContext); - token; - token = strtok_r(nullptr, "\n", &tokenContext)) - { - if (ProcessMount(token)) { - foundSystem = true; - break; - } - } - - fclose(mountsFile); - - if (!foundSystem) { - LOGE("Couldn't find %s mount in %s", kGonkSystemPath, kGonkMountsPath); - } - return foundSystem; -} - -bool -GonkAutoMounter::ProcessMount(const char *mount) -{ - const int strSize = 256; - char mountDev[strSize]; - char mountDir[strSize]; - char mountAccess[strSize]; - - int rv = sscanf(mount, "%255s %255s %*s %255s %*d %*d\n", - mountDev, mountDir, mountAccess); - mountDev[strSize - 1] = '\0'; - mountDir[strSize - 1] = '\0'; - mountAccess[strSize - 1] = '\0'; - - if (rv != 3) { - return false; - } - - if (strcmp(kGonkSystemPath, mountDir) != 0) { - return false; - } - - free(mDevice); - mDevice = strdup(mountDev); - mAccess = Unknown; - - char *option, *optionContext; - for (option = strtok_r(mountAccess, ",", &optionContext); - option; - option = strtok_r(nullptr, ",", &optionContext)) - { - if (strcmp("ro", option) == 0) { - mAccess = ReadOnly; - break; - } else if (strcmp("rw", option) == 0) { - mAccess = ReadWrite; - break; - } - } - - return true; -} - -/* - * Mark the given block device as read-write or read-only, using the BLKROSET - * ioctl. - */ -static void SetBlockReadWriteStatus(const char *blockdev, bool setReadOnly) { - int fd; - int roMode = setReadOnly ? 1 : 0; - - fd = open(blockdev, O_RDONLY); - if (fd < 0) { - return; - } - - if (ioctl(fd, BLKROSET, &roMode) == -1) { - LOGE("Error setting read-only mode on %s to %s: %s", blockdev, - setReadOnly ? "true": "false", strerror(errno)); - } - close(fd); -} - - -bool -GonkAutoMounter::MountSystem(unsigned long flags) -{ - if (!mDevice) { - LOGE("No device was found for %s", kGonkSystemPath); - return false; - } - - // Without setting the block device ro mode to false, we get a permission - // denied error while trying to remount it in read-write. - SetBlockReadWriteStatus(mDevice, (flags & MS_RDONLY)); - - const char *readOnly = flags & MS_RDONLY ? "read-only" : "read-write"; - int result = mount(mDevice, kGonkSystemPath, "none", flags, nullptr); - - if (result != 0) { - LOGE("Error mounting %s as %s: %s", kGonkSystemPath, readOnly, - strerror(errno)); - return false; - } - - LOGI("Mounted %s partition as %s", kGonkSystemPath, readOnly); - return true; -} diff --git a/toolkit/mozapps/update/updater/automounter_gonk.h b/toolkit/mozapps/update/updater/automounter_gonk.h deleted file mode 100644 index e40cacbc2..000000000 --- a/toolkit/mozapps/update/updater/automounter_gonk.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef AUTOMOUNTER_GONK_H__ -#define AUTOMOUNTER_GONK_H__ - -typedef enum { - ReadOnly, - ReadWrite, - Unknown -} MountAccess; - -/** - * This class will remount the /system partition as read-write in Gonk to allow - * the updater write access. Upon destruction, /system will be remounted back to - * read-only. If something causes /system to remain read-write, this class will - * reboot the device and allow the system to mount as read-only. - * - * Code inspired from AOSP system/core/adb/remount_service.c - */ -class GonkAutoMounter -{ -public: - GonkAutoMounter(); - ~GonkAutoMounter(); - - MountAccess GetAccess() const - { - return mAccess; - } - -private: - bool RemountSystem(MountAccess access); - bool ForceRemountReadOnly(); - bool UpdateMountStatus(); - bool ProcessMount(const char *mount); - bool MountSystem(unsigned long flags); - void Reboot(); - -private: - char *mDevice; - MountAccess mAccess; -}; - -#endif // AUTOMOUNTER_GONK_H__ diff --git a/toolkit/mozapps/update/updater/progressui_gonk.cpp b/toolkit/mozapps/update/updater/progressui_gonk.cpp deleted file mode 100644 index f77d0af63..000000000 --- a/toolkit/mozapps/update/updater/progressui_gonk.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=8 et : - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include <assert.h> -#include <stdio.h> - -#include <string> - -#include "android/log.h" - -#include "progressui.h" - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoUpdater" , ## args) - -using namespace std; - -int InitProgressUI(int *argc, char ***argv) -{ - return 0; -} - -int ShowProgressUI() -{ - LOG("Starting to apply update ...\n"); - return 0; -} - -void QuitProgressUI() -{ - LOG("Finished applying update\n"); -} - -void UpdateProgressUI(float progress) -{ - assert(0.0f <= progress && progress <= 100.0f); - - static const size_t kProgressBarLength = 50; - static size_t sLastNumBars; - size_t numBars = size_t(float(kProgressBarLength) * progress / 100.0f); - if (numBars == sLastNumBars) { - return; - } - sLastNumBars = numBars; - - size_t numSpaces = kProgressBarLength - numBars; - string bars(numBars, '='); - string spaces(numSpaces, ' '); - LOG("Progress [ %s%s ]\n", bars.c_str(), spaces.c_str()); -} diff --git a/toolkit/mozapps/update/updater/updater-common.build b/toolkit/mozapps/update/updater/updater-common.build index 02b7338bc..6444df8d9 100644 --- a/toolkit/mozapps/update/updater/updater-common.build +++ b/toolkit/mozapps/update/updater/updater-common.build @@ -90,17 +90,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ '/toolkit/xre', ] -elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': - have_progressui = 1 - srcs += [ - 'automounter_gonk.cpp', - 'progressui_gonk.cpp', - ] - DISABLE_STL_WRAPPING = True - OS_LIBS += [ - 'cutils', - 'sysutils', - ] if have_progressui == 0: srcs += [ diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp index 63a92c084..dbf50329c 100644 --- a/toolkit/mozapps/update/updater/updater.cpp +++ b/toolkit/mozapps/update/updater/updater.cpp @@ -110,33 +110,10 @@ struct UpdateServerThreadArgs #define USE_EXECV #endif -#if defined(MOZ_WIDGET_GONK) -# include "automounter_gonk.h" -# include <unistd.h> -# include <android/log.h> -# include <linux/ioprio.h> -# include <sys/resource.h> - -#if ANDROID_VERSION < 21 -// The only header file in bionic which has a function prototype for ioprio_set -// is libc/include/sys/linux-unistd.h. However, linux-unistd.h conflicts -// badly with unistd.h, so we declare the prototype for ioprio_set directly. -extern "C" MOZ_EXPORT int ioprio_set(int which, int who, int ioprio); -#else -# include <sys/syscall.h> -static int ioprio_set(int which, int who, int ioprio) { - return syscall(__NR_ioprio_set, which, who, ioprio); -} -#endif - -# define MAYBE_USE_HARD_LINKS 1 -static bool sUseHardLinks = true; -#else # define MAYBE_USE_HARD_LINKS 0 -#endif #if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \ - !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK) + !defined(XP_MACOSX) #include "nss.h" #include "prerror.h" #endif @@ -2495,44 +2472,9 @@ ReadMARChannelIDs(const NS_tchar *path, MARChannelStringTable *results) static int GetUpdateFileName(NS_tchar *fileName, int maxChars) { -#if defined(MOZ_WIDGET_GONK) - // If an update.link file exists, then it will contain the name - // of the update file (terminated by a newline). - - NS_tchar linkFileName[MAXPATHLEN]; - NS_tsnprintf(linkFileName, sizeof(linkFileName)/sizeof(linkFileName[0]), - NS_T("%s/update.link"), gPatchDirPath); - AutoFile linkFile(NS_tfopen(linkFileName, NS_T("rb"))); - if (linkFile == nullptr) { - NS_tsnprintf(fileName, maxChars, - NS_T("%s/update.mar"), gPatchDirPath); - return OK; - } - - char dataFileName[MAXPATHLEN]; - size_t bytesRead; - - if ((bytesRead = fread(dataFileName, 1, sizeof(dataFileName)-1, linkFile)) <= 0) { - *fileName = NS_T('\0'); - return READ_ERROR; - } - if (dataFileName[bytesRead-1] == '\n') { - // Strip trailing newline (for \n and \r\n) - bytesRead--; - } - if (dataFileName[bytesRead-1] == '\r') { - // Strip trailing CR (for \r, \r\n) - bytesRead--; - } - dataFileName[bytesRead] = '\0'; - - strncpy(fileName, dataFileName, maxChars-1); - fileName[maxChars-1] = '\0'; -#else - // We currently only support update.link files under GONK + // We currently don't support update.link files NS_tsnprintf(fileName, maxChars, NS_T("%s/update.mar"), gPatchDirPath); -#endif return OK; } @@ -2776,26 +2718,8 @@ int NS_main(int argc, NS_tchar **argv) } #endif -#if defined(MOZ_WIDGET_GONK) - if (EnvHasValue("LD_PRELOAD")) { - // If the updater is launched with LD_PRELOAD set, then we wind up - // preloading libmozglue.so. Under some circumstances, this can cause - // the remount of /system to fail when going from rw to ro, so if we - // detect LD_PRELOAD we unsetenv it and relaunch ourselves without it. - // This will cause the offending preloaded library to be closed. - // - // For a variety of reasons, this is really hard to do in a safe manner - // in the parent process, so we do it here. - unsetenv("LD_PRELOAD"); - execv(argv[0], argv); - __android_log_print(ANDROID_LOG_INFO, "updater", - "execve failed: errno: %d. Exiting...", errno); - _exit(1); - } -#endif - #if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \ - !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK) + !defined(XP_MACOSX) // On Windows and Mac we rely on native APIs to do verifications so we don't // need to initialize NSS at all there. // Otherwise, minimize the amount of NSS we depend on by avoiding all the NSS @@ -3085,36 +3009,6 @@ int NS_main(int argc, NS_tchar **argv) } #endif -#ifdef MOZ_WIDGET_GONK - const char *prioEnv = getenv("MOZ_UPDATER_PRIO"); - if (prioEnv) { - int32_t prioVal; - int32_t oomScoreAdj; - int32_t ioprioClass; - int32_t ioprioLevel; - if (sscanf(prioEnv, "%d/%d/%d/%d", - &prioVal, &oomScoreAdj, &ioprioClass, &ioprioLevel) == 4) { - LOG(("MOZ_UPDATER_PRIO=%s", prioEnv)); - if (setpriority(PRIO_PROCESS, 0, prioVal)) { - LOG(("setpriority(%d) failed, errno = %d", prioVal, errno)); - } - if (ioprio_set(IOPRIO_WHO_PROCESS, 0, - IOPRIO_PRIO_VALUE(ioprioClass, ioprioLevel))) { - LOG(("ioprio_set(%d,%d) failed: errno = %d", - ioprioClass, ioprioLevel, errno)); - } - FILE *fs = fopen("/proc/self/oom_score_adj", "w"); - if (fs) { - fprintf(fs, "%d", oomScoreAdj); - fclose(fs); - } else { - LOG(("Unable to open /proc/self/oom_score_adj for writing, errno = %d", - errno)); - } - } - } -#endif - #ifdef XP_WIN if (pid > 0) { HANDLE parent = OpenProcess(SYNCHRONIZE, false, (DWORD) pid); @@ -3439,27 +3333,6 @@ int NS_main(int argc, NS_tchar **argv) } #endif -#if defined(MOZ_WIDGET_GONK) - // In gonk, the master b2g process sets its umask to 0027 because - // there's no reason for it to ever create world-readable files. - // The updater binary, however, needs to do this, and it inherits - // the master process's cautious umask. So we drop down a bit here. - umask(0022); - - // Remount the /system partition as read-write for gonk. The destructor will - // remount /system as read-only. We add an extra level of scope here to avoid - // calling LogFinish() before the GonkAutoMounter destructor has a chance - // to be called - { -#if !defined(TEST_UPDATER) - GonkAutoMounter mounter; - if (mounter.GetAccess() != MountAccess::ReadWrite) { - WriteStatusFile(FILESYSTEM_MOUNT_READWRITE_ERROR); - return 1; - } -#endif -#endif - if (sStagedUpdate) { // When staging updates, blow away the old installation directory and create // it from scratch. @@ -3759,10 +3632,6 @@ int NS_main(int argc, NS_tchar **argv) } #endif /* XP_WIN */ -#if defined(MOZ_WIDGET_GONK) - } // end the extra level of scope for the GonkAutoMounter -#endif - #ifdef XP_MACOSX // When the update is successful remove the precomplete file in the root of // the application bundle and move the distribution directory from diff --git a/toolkit/mozapps/webextensions/extensions.manifest b/toolkit/mozapps/webextensions/extensions.manifest index c7d2ee386..7ce20c3ec 100644 --- a/toolkit/mozapps/webextensions/extensions.manifest +++ b/toolkit/mozapps/webextensions/extensions.manifest @@ -5,7 +5,6 @@ component {e0a106ed-6ad4-47a4-b6af-2f1c8aa4712d} nsBlocklistServiceContent.js pr contract @mozilla.org/extensions/blocklist;1 {e0a106ed-6ad4-47a4-b6af-2f1c8aa4712d} process=content category update-timer nsBlocklistService @mozilla.org/extensions/blocklist;1,getService,blocklist-background-update-timer,extensions.blocklist.interval,86400 -#ifndef MOZ_WIDGET_GONK component {4399533d-08d1-458c-a87a-235f74451cfa} addonManager.js contract @mozilla.org/addons/integration;1 {4399533d-08d1-458c-a87a-235f74451cfa} #ifndef MOZ_WIDGET_ANDROID @@ -22,6 +21,5 @@ category JavaScript-global-property InstallTrigger @mozilla.org/addons/installtr category addon-provider-module PluginProvider resource://gre/modules/addons/PluginProvider.jsm #endif category addon-provider-module GMPProvider resource://gre/modules/addons/GMPProvider.jsm -#endif component {8866d8e3-4ea5-48b7-a891-13ba0ac15235} amWebAPI.js contract @mozilla.org/addon-web-api/manager;1 {8866d8e3-4ea5-48b7-a891-13ba0ac15235} diff --git a/toolkit/mozapps/webextensions/internal/AddonUpdateChecker.jsm b/toolkit/mozapps/webextensions/internal/AddonUpdateChecker.jsm index 918ba5328..bdd3a81e7 100644 --- a/toolkit/mozapps/webextensions/internal/AddonUpdateChecker.jsm +++ b/toolkit/mozapps/webextensions/internal/AddonUpdateChecker.jsm @@ -929,8 +929,17 @@ this.AddonUpdateChecker = { * down in-progress update requests */ checkForUpdates: function(aId, aUpdateKey, aUrl, aObserver) { - // Exclude default theme - if (aId != "{972ce4c6-7e08-4474-a285-3208198ce6fd}") + // Define an array of internally used IDs to NOT send to AUS such as the + // Default Theme. Please keep this list in sync with: + // toolkit/mozapps/extensions/AddonUpdateChecker.jsm + let internalIDS = [ + '{972ce4c6-7e08-4474-a285-3208198ce6fd}', + 'modern@themes.mozilla.org' + ]; + + // If the ID is not in the array then go ahead and query AUS + if (internalIDS.indexOf(aId) == -1) { return new UpdateParser(aId, aUpdateKey, aUrl, aObserver); + } } }; diff --git a/toolkit/mozapps/webextensions/nsBlocklistService.js b/toolkit/mozapps/webextensions/nsBlocklistService.js index 0af90430c..268c197fc 100644 --- a/toolkit/mozapps/webextensions/nsBlocklistService.js +++ b/toolkit/mozapps/webextensions/nsBlocklistService.js @@ -907,10 +907,6 @@ Blocklist.prototype = { this._handleEmItemNode); break; case "pluginItems": - // We don't support plugins on b2g. - if (AppConstants.MOZ_B2G) { - return; - } this._pluginEntries = this._processItemNodes(element.childNodes, "pluginItem", this._handlePluginItemNode); break; @@ -1151,8 +1147,7 @@ Blocklist.prototype = { /* See nsIBlocklistService */ getPluginBlocklistState: function(plugin, appVersion, toolkitVersion) { - if (AppConstants.platform == "android" || - AppConstants.MOZ_B2G) { + if (AppConstants.platform == "android") { return Ci.nsIBlocklistService.STATE_NOT_BLOCKED; } if (!this._isBlocklistLoaded()) @@ -1314,10 +1309,6 @@ Blocklist.prototype = { }, _blocklistUpdated: function(oldAddonEntries, oldPluginEntries) { - if (AppConstants.MOZ_B2G) { - return; - } - var addonList = []; // A helper function that reverts the prefs passed to default values. |