Add expiration date to GERRIT_UI cookie

Adds an expiration date to the GERRIT_UI cookie so that it does not
default to a session cookie. Calculates two years from now, and uses
that because that is the same length as the cookie set by the link in
the footer of the gerrit site.

Bug: Issue 4999
Change-Id: I40e47f12c8e7a90593c9ca927582ad4d0ef5ad9c
diff --git a/background.js b/background.js
index 3b0652f..0f8cfdf 100644
--- a/background.js
+++ b/background.js
@@ -216,7 +216,11 @@
       });
     } else {
       ga('send', 'event', 'Page Action', 'Switch to PolyGerrit');
+      var curYear = new Date().getFullYear();
+      var twoYearsFromNow =
+          Math.round(new Date().setFullYear(curYear + 2) / 1000);
       chrome.cookies.set({
+        expirationDate: twoYearsFromNow,
         url: tab.url,
         name: 'GERRIT_UI',
         value: 'polygerrit',