Bug 1549828 - Export Screenshots 39.0.0 (code excluding translations) r=_6a68
authorIan Bicking <ibicking@mozilla.com>
Wed, 08 May 2019 00:22:53 +0000
changeset 532437 d48bf099053b59dc5598e6c96a614eeed3e94282
parent 532436 7e851ac3cb03c9c1c1224d5a4da9c7e0f3c5c280
child 532438 c957bff02df08481f0d632033db6578a88a6f6c1
push id11268
push usercsabou@mozilla.com
push dateTue, 14 May 2019 15:24:22 +0000
treeherdermozilla-beta@5fb7fcd568d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewers_6a68
bugs1549828
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549828 - Export Screenshots 39.0.0 (code excluding translations) r=_6a68 Depends on D30261 Differential Revision: https://phabricator.services.mozilla.com/D30262
browser/extensions/screenshots/background/main.js
browser/extensions/screenshots/background/startBackground.js
browser/extensions/screenshots/manifest.json
--- a/browser/extensions/screenshots/background/main.js
+++ b/browser/extensions/screenshots/background/main.js
@@ -5,26 +5,19 @@
 this.main = (function() {
   const exports = {};
 
   const pasteSymbol = (window.navigator.platform.match(/Mac/i)) ? "\u2318" : "Ctrl";
   const { sendEvent, incrementCount } = analytics;
 
   const manifest = browser.runtime.getManifest();
   let backend;
-  let _hasAnyShots = false;
-
-  startBackground.serverStatus.then((status) => {
-    _hasAnyShots = status.hasAny;
-  }).catch((e) => {
-    log.warn("Cannot see server status", e);
-  });
 
   exports.hasAnyShots = function() {
-    return _hasAnyShots;
+    return false;
   };
 
   let hasSeenOnboarding = browser.storage.local.get(["hasSeenOnboarding"]).then((result) => {
     const onboarded = !!result.hasSeenOnboarding;
     hasSeenOnboarding = Promise.resolve(onboarded);
     return hasSeenOnboarding;
   }).catch((error) => {
     log.error("Error getting hasSeenOnboarding:", error);
--- a/browser/extensions/screenshots/background/startBackground.js
+++ b/browser/extensions/screenshots/background/startBackground.js
@@ -5,26 +5,16 @@
      browser.runtime.onMessage
    and loads the rest of the background page in response to those events, forwarding
    the events to main.onClicked, main.onClickedContextMenu, or communication.onMessage
 */
 const startTime = Date.now();
 
 this.startBackground = (function() {
   const exports = {startTime};
-  // Wait until this many milliseconds to check the server for shots (for the purpose of migration warning):
-  const CHECK_SERVER_TIME = 5000; // 5 seconds
-  // If we want to pop open the tab showing the server status, wait this many milliseconds to open it:
-  const OPEN_SERVER_TAB_TIME = 5000; // 5 seconds
-  let hasSeenServerStatus = false;
-  let _resolveServerStatus;
-  exports.serverStatus = new Promise((resolve, reject) => {
-    _resolveServerStatus = {resolve, reject};
-  });
-  let backend;
 
   const backgroundScripts = [
     "log.js",
     "makeUuid.js",
     "catcher.js",
     "blobConverters.js",
     "background/selectorLoader.js",
     "background/communication.js",
@@ -109,89 +99,10 @@ this.startBackground = (function() {
           };
           document.head.appendChild(tag);
         });
       });
     });
     return loadedPromise;
   }
 
-  async function checkExpiration() {
-    const manifest = await browser.runtime.getManifest();
-    for (const permission of manifest.permissions) {
-      if (/^https?:\/\//.test(permission)) {
-        backend = permission.replace(/\/*$/, "");
-        break;
-      }
-    }
-    const result = await browser.storage.local.get(["registrationInfo", "hasSeenServerStatus", "hasShotsResponse"]);
-    hasSeenServerStatus = result.hasSeenServerStatus;
-    const { registrationInfo } = result;
-    if (!backend || !registrationInfo || !registrationInfo.registered) {
-      // The add-on hasn't been used, or at least no upload has occurred
-      _resolveServerStatus.resolve({hasIndefinite: false, hasAny: false});
-      return;
-    }
-    if (result.hasShotsResponse) {
-      // We've already retrieved information from the server
-      _resolveServerStatus.resolve(result.hasShotsResponse);
-      return;
-    }
-    const loginUrl = `${backend}/api/login`;
-    const hasShotsUrl = `${backend}/api/has-shots`;
-    try {
-      let resp = await fetch(loginUrl, {
-        method: "POST",
-        headers: {
-          "Content-Type": "application/json",
-        },
-        body: JSON.stringify({
-          deviceId: registrationInfo.deviceId,
-          secret: registrationInfo.secret,
-        }),
-      });
-      if (!resp.ok) {
-        throw new Error(`Bad login response: ${resp.status}`);
-      }
-      const { authHeader } = await resp.json();
-      resp = await fetch(hasShotsUrl, {
-        method: "GET",
-        credentials: "include",
-        headers: Object.assign({}, authHeader, {
-          "Content-Type": "application/json",
-        }),
-      });
-      if (!resp.ok) {
-        throw new Error(`Bad response from server: ${resp.status}`);
-      }
-      const body = await resp.json();
-      browser.storage.local.set({hasShotsResponse: body});
-      _resolveServerStatus.resolve(body);
-    } catch (e) {
-      _resolveServerStatus.reject(e);
-    }
-  }
-
-  exports.serverStatus.then((status) => {
-    if (status.hasAny) {
-      browser.experiments.screenshots.initLibraryButton();
-    }
-    if (status.hasIndefinite && !hasSeenServerStatus) {
-      setTimeout(async () => {
-        await browser.tabs.create({
-          url: `${backend}/hosting-shutdown`,
-        });
-        hasSeenServerStatus = true;
-        await browser.storage.local.set({hasSeenServerStatus});
-      }, OPEN_SERVER_TAB_TIME);
-    }
-  }).catch((e) => {
-    console.error("Error finding Screenshots server status:", String(e), e.stack);
-  });
-
-  setTimeout(() => {
-    window.requestIdleCallback(() => {
-      checkExpiration();
-    });
-  }, CHECK_SERVER_TIME);
-
   return exports;
 })();
--- a/browser/extensions/screenshots/manifest.json
+++ b/browser/extensions/screenshots/manifest.json
@@ -1,12 +1,12 @@
 {
   "manifest_version": 2,
   "name": "Firefox Screenshots",
-  "version": "37.1.0",
+  "version": "39.0.0",
   "description": "__MSG_addonDescription__",
   "author": "__MSG_addonAuthorsList__",
   "homepage_url": "https://github.com/mozilla-services/screenshots",
   "incognito": "spanning",
   "applications": {
     "gecko": {
       "id": "screenshots@mozilla.org",
       "strict_min_version": "57.0a1"