Bug 1380817 - Export Screenshots 10.5.0 to Firefox; r?Mossop draft
authorIan Bicking <ianb@colorstudy.com>
Fri, 14 Jul 2017 13:05:56 -0400
changeset 609034 3688dec833831eb553030b9b65c9c93ba39267fe
parent 609005 7d92f47379da55adf4da6d0b16398f5c629cf949
child 609135 14e286338efbc2780546979534aedc4ca0641bff
push id68487
push userbmo:ianb@mozilla.com
push dateFri, 14 Jul 2017 17:06:22 +0000
reviewersMossop
bugs1380817
milestone56.0a1
Bug 1380817 - Export Screenshots 10.5.0 to Firefox; r?Mossop MozReview-Commit-ID: 69IGWL0YZhk
browser/extensions/screenshots/install.rdf
browser/extensions/screenshots/moz.build
browser/extensions/screenshots/webextension/_locales/en_US/messages.json
browser/extensions/screenshots/webextension/background/main.js
browser/extensions/screenshots/webextension/background/senderror.js
browser/extensions/screenshots/webextension/build/inlineSelectionCss.js
browser/extensions/screenshots/webextension/build/shot.js
browser/extensions/screenshots/webextension/icons/cloud.svg
browser/extensions/screenshots/webextension/icons/icon-16-v2.svg
browser/extensions/screenshots/webextension/icons/icon-16.svg
browser/extensions/screenshots/webextension/icons/icon-32-v2.svg
browser/extensions/screenshots/webextension/icons/icon-32.svg
browser/extensions/screenshots/webextension/icons/icon-highlight-32-v2.svg
browser/extensions/screenshots/webextension/icons/icon-highlight-32.svg
browser/extensions/screenshots/webextension/icons/icon-starred-32-v2.svg
browser/extensions/screenshots/webextension/icons/icon-starred-32.svg
browser/extensions/screenshots/webextension/manifest.json
--- a/browser/extensions/screenshots/install.rdf
+++ b/browser/extensions/screenshots/install.rdf
@@ -7,14 +7,14 @@
     <em:targetApplication>
       <Description>
         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!--Firefox-->
         <em:minVersion>51.0a1</em:minVersion>
         <em:maxVersion>*</em:maxVersion>
       </Description>
     </em:targetApplication>
     <em:type>2</em:type>
-    <em:version>10.3.0</em:version>
+    <em:version>10.5.0</em:version>
     <em:bootstrap>true</em:bootstrap>
     <em:homepageURL>https://pageshot.net/</em:homepageURL>
     <em:multiprocessCompatible>true</em:multiprocessCompatible>
   </Description>
 </RDF>
--- a/browser/extensions/screenshots/moz.build
+++ b/browser/extensions/screenshots/moz.build
@@ -308,23 +308,24 @@ FINAL_TARGET_FILES.features['screenshots
   'webextension/build/raven.js',
   'webextension/build/shot.js'
 ]
 
 FINAL_TARGET_FILES.features['screenshots@mozilla.org']["webextension"]["icons"] += [
   'webextension/icons/back-highlight.svg',
   'webextension/icons/back.svg',
   'webextension/icons/cancel.svg',
+  'webextension/icons/cloud.svg',
   'webextension/icons/copy.png',
   'webextension/icons/done.svg',
   'webextension/icons/download.svg',
-  'webextension/icons/icon-16.svg',
-  'webextension/icons/icon-32.svg',
-  'webextension/icons/icon-highlight-32.svg',
-  'webextension/icons/icon-starred-32.svg',
+  'webextension/icons/icon-16-v2.svg',
+  'webextension/icons/icon-32-v2.svg',
+  'webextension/icons/icon-highlight-32-v2.svg',
+  'webextension/icons/icon-starred-32-v2.svg',
   'webextension/icons/icon-welcome-face-without-eyes.svg',
   'webextension/icons/menu-fullpage.svg',
   'webextension/icons/menu-myshot.svg',
   'webextension/icons/menu-visible.svg',
   'webextension/icons/onboarding-1.png',
   'webextension/icons/onboarding-2.png',
   'webextension/icons/onboarding-3.png',
   'webextension/icons/onboarding-4.png'
--- a/browser/extensions/screenshots/webextension/_locales/en_US/messages.json
+++ b/browser/extensions/screenshots/webextension/_locales/en_US/messages.json
@@ -62,16 +62,22 @@
     "message": "This isn’t a standard Web page, so you can’t take a screenshot of it."
   },
   "selfScreenshotErrorTitle": {
     "message": "You can’t take a shot of a Firefox Screenshots page!"
   },
   "emptySelectionErrorTitle": {
     "message": "Your selection is too small"
   },
+  "privateWindowErrorTitle": {
+    "message": "Screenshots is disabled in Private Browsing Mode"
+  },
+  "privateWindowErrorDetails": {
+    "message": "Sorry for the inconvenience. We are working on this feature for future releases."
+  },
   "genericErrorTitle": {
     "message": "Whoa! Firefox Screenshots went haywire."
   },
   "genericErrorDetails": {
     "message": "We’re not sure what just happened. Care to try again or take a shot of a different page?"
   },
   "tourBodyOne": {
     "message": "Take, save, and share screenshots without leaving Firefox."
--- a/browser/extensions/screenshots/webextension/background/main.js
+++ b/browser/extensions/screenshots/webextension/background/main.js
@@ -46,19 +46,19 @@ this.main = (function() {
   for (let permission of manifest.permissions) {
     if (/^https?:\/\//.test(permission)) {
       exports.setBackend(permission);
       break;
     }
   }
 
   function setIconActive(active, tabId) {
-    let path = active ? "icons/icon-highlight-32.svg" : "icons/icon-32.svg";
+    let path = active ? "icons/icon-highlight-32-v2.svg" : "icons/icon-32-v2.svg";
     if ((!hasSeenOnboarding) && !active) {
-      path = "icons/icon-starred-32.svg";
+      path = "icons/icon-starred-32-v2.svg";
     }
     browser.browserAction.setIcon({path, tabId}).catch((error) => {
       // FIXME: use errorCode
       if (error.message && /Invalid tab ID/.test(error.message)) {
         // This is a normal exception that we can ignore
       } else {
         catcher.unhandled(error);
       }
@@ -94,16 +94,22 @@ this.main = (function() {
   }
 
   function shouldOpenMyShots(url) {
     return /^about:(?:newtab|blank)/i.test(url) || /^resource:\/\/activity-streams\//i.test(url);
   }
 
   // This is called by startBackground.js, directly in response to browser.browserAction.onClicked
   exports.onClicked = catcher.watchFunction((tab) => {
+    if (tab.incognito) {
+      senderror.showError({
+        popupMessage: "PRIVATE_WINDOW"
+      });
+      return;
+    }
     if (shouldOpenMyShots(tab.url)) {
       if (!hasSeenOnboarding) {
         catcher.watchPromise(analytics.refreshTelemetryPref().then(() => {
           sendEvent("goto-onboarding", "selection-button");
           return forceOnboarding();
         }));
         return;
       }
@@ -133,16 +139,22 @@ this.main = (function() {
     return browser.tabs.create({url: getOnboardingUrl()});
   }
 
   exports.onClickedContextMenu = catcher.watchFunction((info, tab) => {
     if (!tab) {
       // Not in a page/tab context, ignore
       return;
     }
+    if (tab.incognito) {
+      senderror.showError({
+        popupMessage: "PRIVATE_WINDOW"
+      });
+      return;
+    }
     if (!urlEnabled(tab.url)) {
       senderror.showError({
         popupMessage: "UNSHOOTABLE_PAGE"
       });
       return;
     }
     catcher.watchPromise(
       toggleSelector(tab)
--- a/browser/extensions/screenshots/webextension/background/senderror.js
+++ b/browser/extensions/screenshots/webextension/background/senderror.js
@@ -37,16 +37,20 @@ this.senderror = (function() {
       title: browser.i18n.getMessage("selfScreenshotErrorTitle")
     },
     MY_SHOTS: {
       title: browser.i18n.getMessage("selfScreenshotErrorTitle")
     },
     EMPTY_SELECTION: {
       title: browser.i18n.getMessage("emptySelectionErrorTitle")
     },
+    PRIVATE_WINDOW: {
+      title: browser.i18n.getMessage("privateWindowErrorTitle"),
+      info: browser.i18n.getMessage("privateWindowErrorDetails")
+    },
     generic: {
       title: browser.i18n.getMessage("genericErrorTitle"),
       info: browser.i18n.getMessage("genericErrorDetails"),
       showMessage: true
     }
   };
 
   communication.register("reportError", (sender, error) => {
--- a/browser/extensions/screenshots/webextension/build/inlineSelectionCss.js
+++ b/browser/extensions/screenshots/webextension/build/inlineSelectionCss.js
@@ -323,29 +323,36 @@ window.inlineSelectionCss = `
     right: auto;
     left: 5px; }
 
 .highlight-button-cancel {
   background-image: url("MOZ_EXTENSION/icons/cancel.svg");
   background-position: center center;
   background-repeat: no-repeat;
   background-size: 18px 18px;
+  border: 1px solid #dedede;
   margin: 5px;
   width: 40px; }
 
 .highlight-button-save {
+  background-image: url("MOZ_EXTENSION/icons/cloud.svg");
+  background-position: 8px center;
+  background-repeat: no-repeat;
+  background-size: 20px 18px;
   font-size: 18px;
   margin: 5px;
-  min-width: 80px; }
+  min-width: 80px;
+  padding-left: 34px; }
 
 .highlight-button-download {
   background-image: url("MOZ_EXTENSION/icons/download.svg");
   background-position: center center;
   background-repeat: no-repeat;
   background-size: 18px 18px;
+  border: 1px solid #dedede;
   display: block;
   margin: 5px;
   width: 40px; }
 
 .pixel-dimensions {
   position: absolute;
   pointer-events: none;
   font-weight: bold;
--- a/browser/extensions/screenshots/webextension/build/shot.js
+++ b/browser/extensions/screenshots/webextension/build/shot.js
@@ -346,17 +346,17 @@ class AbstractShot {
       assertOrigin(val);
     }
     this._origin = val || undefined;
   }
 
   get filename() {
     let filenameTitle = this.title;
     let date = new Date(this.createdDate);
-    filenameTitle = filenameTitle.replace(/[\/!@&*.|\n\r\t]/g, " ");
+    filenameTitle = filenameTitle.replace(/[:\\<>\/!@&*.|\n\r\t]/g, " ");
     filenameTitle = filenameTitle.replace(/\s{1,4000}/g, " ");
     let clipFilename = `Screenshot-${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${filenameTitle}`;
     const clipFilenameBytesSize = clipFilename.length * 2; // JS STrings are UTF-16
     if (clipFilenameBytesSize > 251) { // 255 bytes (Usual filesystems max) - 4 for the ".png" file extension string
       const excedingchars = (clipFilenameBytesSize - 246) / 2; // 251 - 5 for ellipsis "[...]"
       clipFilename = clipFilename.substring(0, clipFilename.length - excedingchars);
       clipFilename = clipFilename + '[...]';
     }
new file mode 100644
--- /dev/null
+++ b/browser/extensions/screenshots/webextension/icons/cloud.svg
@@ -0,0 +1,1 @@
+<svg width="20" height="18" viewBox="0 0 20 18" xmlns="http://www.w3.org/2000/svg"><title>cloud</title><g fill="#FFF" fill-rule="evenodd"><path d="M15 5.6h-.3C14.5 2.7 12 .5 9.2.5c-3 0-5.4 2.4-5.5 5.3C1.5 6.4 0 8.3 0 10.6c0 2.8 2.2 5 5 5a1 1 0 0 0 1-1v-.1a1 1 0 0 0-1-1c-1.7 0-3-1.3-3-3 0-1.3.8-2.5 2.2-2.9l1.4-.4.1-1.4c.1-1.9 1.6-3.3 3.5-3.3 1.8 0 3.4 1.4 3.5 3.2l.1 1.8h2.1c1.7 0 3 1.3 3 3s-1.3 3-3 3h-1.85a1.05 1.05 0 1 0 0 2.1H15c2.8 0 5-2.2 5-5s-2.2-5-5-5z" fill-rule="nonzero"/><path d="M10 11.414V17c0 .667-.333 1-1 1s-1-.333-1-1v-5.586l-.293.293a1 1 0 1 1-1.414-1.414L9 7.586l2.707 2.707a1 1 0 0 1-1.414 1.414L10 11.414z"/></g></svg>
new file mode 100644
--- /dev/null
+++ b/browser/extensions/screenshots/webextension/icons/icon-16-v2.svg
@@ -0,0 +1,1 @@
+<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="context-fill"><title>icon-16</title><path d="M8 2a4 4 0 0 0-4 4h4V2zm12 0h-4v4h4V2zm8 0v4h4a4 4 0 0 0-4-4zM14 2h-4v4h4V2zm12 0h-4v4h4V2zm2 10h4V8h-4v4zm0 12a4 4 0 0 0 4-4h-4v4zm0-6h4v-4h-4v4zm-.882-4.334a4 4 0 0 0-5.57-.984l-7.67 5.662-3.936-2.76c.031-.193.05-.388.058-.584a4.976 4.976 0 0 0-2-3.978V8H4v2.1a5 5 0 1 0 3.916 8.948l2.484 1.738-2.8 1.964a4.988 4.988 0 1 0 2.3 3.266l17.218-12.35zM5 17.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm0 12a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm10.8-4.858l6.034 4.6a4 4 0 0 0 5.57-.984L19.28 22.2l-3.48 2.442z"/></svg>
deleted file mode 100644
--- a/browser/extensions/screenshots/webextension/icons/icon-16.svg
+++ /dev/null
@@ -1,1 +0,0 @@
-<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title>icon-16</title><path d="M8 2a4 4 0 0 0-4 4h4V2zm12 0h-4v4h4V2zm8 0v4h4a4 4 0 0 0-4-4zM14 2h-4v4h4V2zm12 0h-4v4h4V2zm2 10h4V8h-4v4zm0 12a4 4 0 0 0 4-4h-4v4zm0-6h4v-4h-4v4zm-.882-4.334a4 4 0 0 0-5.57-.984l-7.67 5.662-3.936-2.76c.031-.193.05-.388.058-.584a4.976 4.976 0 0 0-2-3.978V8H4v2.1a5 5 0 1 0 3.916 8.948l2.484 1.738-2.8 1.964a4.988 4.988 0 1 0 2.3 3.266l17.218-12.35zM5 17.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm0 12a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm10.8-4.858l6.034 4.6a4 4 0 0 0 5.57-.984L19.28 22.2l-3.48 2.442z" fill-rule="nonzero" fill="#4C4C4C"/></svg>
new file mode 100644
--- /dev/null
+++ b/browser/extensions/screenshots/webextension/icons/icon-32-v2.svg
@@ -0,0 +1,1 @@
+<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="context-fill"><title>icon-32</title><path d="M8 2a4 4 0 0 0-4 4h4V2zm12 0h-4v4h4V2zm8 0v4h4a4 4 0 0 0-4-4zM14 2h-4v4h4V2zm12 0h-4v4h4V2zm2 10h4V8h-4v4zm0 12a4 4 0 0 0 4-4h-4v4zm0-6h4v-4h-4v4zm-.882-4.334a4 4 0 0 0-5.57-.984l-7.67 5.662-3.936-2.76c.031-.193.05-.388.058-.584a4.976 4.976 0 0 0-2-3.978V8H4v2.1a5 5 0 1 0 3.916 8.948l2.484 1.738-2.8 1.964a4.988 4.988 0 1 0 2.3 3.266l17.218-12.35zM5 17.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm0 12a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm10.8-4.858l6.034 4.6a4 4 0 0 0 5.57-.984L19.28 22.2l-3.48 2.442z"/></svg>
deleted file mode 100644
--- a/browser/extensions/screenshots/webextension/icons/icon-32.svg
+++ /dev/null
@@ -1,1 +0,0 @@
-<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title>icon-32</title><path d="M8 2a4 4 0 0 0-4 4h4V2zm12 0h-4v4h4V2zm8 0v4h4a4 4 0 0 0-4-4zM14 2h-4v4h4V2zm12 0h-4v4h4V2zm2 10h4V8h-4v4zm0 12a4 4 0 0 0 4-4h-4v4zm0-6h4v-4h-4v4zm-.882-4.334a4 4 0 0 0-5.57-.984l-7.67 5.662-3.936-2.76c.031-.193.05-.388.058-.584a4.976 4.976 0 0 0-2-3.978V8H4v2.1a5 5 0 1 0 3.916 8.948l2.484 1.738-2.8 1.964a4.988 4.988 0 1 0 2.3 3.266l17.218-12.35zM5 17.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm0 12a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm10.8-4.858l6.034 4.6a4 4 0 0 0 5.57-.984L19.28 22.2l-3.48 2.442z" fill-rule="nonzero" fill="#4C4C4C"/></svg>
rename from browser/extensions/screenshots/webextension/icons/icon-highlight-32.svg
rename to browser/extensions/screenshots/webextension/icons/icon-highlight-32-v2.svg
new file mode 100644
--- /dev/null
+++ b/browser/extensions/screenshots/webextension/icons/icon-starred-32-v2.svg
@@ -0,0 +1,1 @@
+<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title>icon copy 2-32</title><g fill="none" fill-rule="evenodd"><g fill="context-fill"><path d="M8 2a4 4 0 0 0-4 4h4V2zm6 0h-4v4h4V2zm14 22a4 4 0 0 0 4-4h-4v4zm-12.2.642l6.034 4.6a4 4 0 0 0 5.57-.984L19.28 22.2l-3.48 2.442z" fill-rule="nonzero"/><path d="M21.86 17.437L9.9 26.016a4.988 4.988 0 1 1-2.3-3.266l2.8-1.964-2.484-1.738A5 5 0 1 1 4 10.1V8h4v3.022A4.976 4.976 0 0 1 10 15c-.008.196-.027.39-.058.584l3.936 2.76 4.46-3.292a9.014 9.014 0 0 0 3.522 2.385zM5 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zm0 12a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zM16.512 6H16V2h3.343a9.018 9.018 0 0 0-2.83 4zM28 17.488V18h4v-3.343a9.018 9.018 0 0 1-4 2.83z"/></g><g transform="translate(18 2)"><circle fill="#00FEFF" cx="7" cy="7" r="7"/><path d="M7 2c.332 0 .765.182.89.694l.401 1.653.075.31.308-.09 1.645-.482a.906.906 0 0 1 1.113.542.868.868 0 0 1-.223.985L9.965 6.783l-.232.22.232.218 1.244 1.172a.869.869 0 0 1 .223.984.906.906 0 0 1-1.113.542l-1.645-.481-.308-.09-.075.31-.402 1.652c-.124.513-.557.694-.889.694-.332 0-.765-.181-.89-.694L5.71 9.657l-.075-.31-.308.091-1.645.481a.906.906 0 0 1-1.113-.542.869.869 0 0 1 .223-.984L4.035 7.22l.232-.219-.232-.219L2.79 5.612a.868.868 0 0 1-.223-.985.906.906 0 0 1 1.113-.542l1.645.481.308.09.075-.309.402-1.653C6.235 2.182 6.668 2 7 2" fill="#005A71"/></g></g></svg>
deleted file mode 100644
--- a/browser/extensions/screenshots/webextension/icons/icon-starred-32.svg
+++ /dev/null
@@ -1,1 +0,0 @@
-<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title>icon copy 2-32</title><g fill="none" fill-rule="evenodd"><g fill="#4D4D4D"><path d="M8 2a4 4 0 0 0-4 4h4V2zm6 0h-4v4h4V2zm14 22a4 4 0 0 0 4-4h-4v4zm-12.2.642l6.034 4.6a4 4 0 0 0 5.57-.984L19.28 22.2l-3.48 2.442z" fill-rule="nonzero"/><path d="M21.86 17.437L9.9 26.016a4.988 4.988 0 1 1-2.3-3.266l2.8-1.964-2.484-1.738A5 5 0 1 1 4 10.1V8h4v3.022A4.976 4.976 0 0 1 10 15c-.008.196-.027.39-.058.584l3.936 2.76 4.46-3.292a9.014 9.014 0 0 0 3.522 2.385zM5 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zm0 12a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zM16.512 6H16V2h3.343a9.018 9.018 0 0 0-2.83 4zM28 17.488V18h4v-3.343a9.018 9.018 0 0 1-4 2.83z"/></g><g transform="translate(18 2)"><circle fill="#00FEFF" cx="7" cy="7" r="7"/><path d="M7 2c.332 0 .765.182.89.694l.401 1.653.075.31.308-.09 1.645-.482a.906.906 0 0 1 1.113.542.868.868 0 0 1-.223.985L9.965 6.783l-.232.22.232.218 1.244 1.172a.869.869 0 0 1 .223.984.906.906 0 0 1-1.113.542l-1.645-.481-.308-.09-.075.31-.402 1.652c-.124.513-.557.694-.889.694-.332 0-.765-.181-.89-.694L5.71 9.657l-.075-.31-.308.091-1.645.481a.906.906 0 0 1-1.113-.542.869.869 0 0 1 .223-.984L4.035 7.22l.232-.219-.232-.219L2.79 5.612a.868.868 0 0 1-.223-.985.906.906 0 0 1 1.113-.542l1.645.481.308.09.075-.309.402-1.653C6.235 2.182 6.668 2 7 2" fill="#005A71"/></g></g></svg>
--- a/browser/extensions/screenshots/webextension/manifest.json
+++ b/browser/extensions/screenshots/webextension/manifest.json
@@ -1,25 +1,25 @@
 {
   "manifest_version": 2,
   "name": "Firefox Screenshots",
-  "version": "10.3.0",
+  "version": "10.5.0",
   "description": "__MSG_addonDescription__",
   "author": "__MSG_addonAuthorsList__",
   "homepage_url": "https://github.com/mozilla-services/screenshots",
   "applications": {
     "gecko": {
       "id": "screenshots@mozilla.org"
     }
   },
   "default_locale": "en_US",
   "browser_action": {
     "default_icon": {
-      "16": "icons/icon-16.svg",
-      "32": "icons/icon-32.svg"
+      "16": "icons/icon-16-v2.svg",
+      "32": "icons/icon-32-v2.svg"
     },
     "default_title": "Firefox Screenshots",
     "browser_style": false
   },
   "background": {
     "scripts": [
       "build/buildSettings.js",
       "background/startBackground.js"