Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Unified Diff: remoting/webapp/survey.js

Issue 12566035: Added survey butter-bar to web-app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« remoting/webapp/remoting.js ('K') | « remoting/webapp/remoting.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/survey.js
diff --git a/remoting/webapp/survey.js b/remoting/webapp/survey.js
new file mode 100644
index 0000000000000000000000000000000000000000..13954e338aa3c8463392240d48230cbbc1dffabf
--- /dev/null
+++ b/remoting/webapp/survey.js
@@ -0,0 +1,59 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * Functions and event handlers to invite the user to participate in a survey
+ * to help improve the product.
+ */
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+var kStorageKey = 'feedback-survey-dismissed';
+var kSurveyDivId = 'survey-opt-in';
+var kSurveyAcceptId = 'survey-accept';
+var kSurveyDeclineId = 'survey-decline';
+
+/**
+ * Hide the survey request and record some basic information about the current
+ * state of the world in synced storage. This may be useful in the future if we
+ * want to show the request again. At the moment, the data itself is ignored;
+ * only its presence or absence is important.
+ *
+ * @param {boolean} optIn True if the user clicked the "Take the survey" link;
+ * false if they clicked the close icon.
+ */
+remoting.dismissSurvey = function(optIn) {
+ var value = {};
+ value[kStorageKey] = {
+ optIn: optIn,
+ date: new Date(),
+ version: chrome.runtime.getManifest().version
+ };
Jamie 2013/03/20 00:32:52 Is there anything else you'd like to see saved her
+ chrome.storage.sync.set(value);
+ document.getElementById(kSurveyDivId).hidden = true;
+};
+
+/**
+ * Show or hide the survey request, depending on whether or not the user has
+ * already seen it.
+ */
+remoting.initSurvey = function() {
+ /** @param {Object} value */
+ var onFeedbackSurveyInfo = function(value) {
+ /** @type {*} */
+ var dismissed = value[kStorageKey];
+ document.getElementById(kSurveyDivId).hidden = !!dismissed;
+ };
+ chrome.storage.sync.get(kStorageKey, onFeedbackSurveyInfo);
+ var accept = document.getElementById(kSurveyAcceptId);
+ var decline = document.getElementById(kSurveyDeclineId);
+ accept.addEventListener(
+ 'click', remoting.dismissSurvey.bind(null, true), false);
+ decline.addEventListener(
+ 'click', remoting.dismissSurvey.bind(null, false), false);
+};
« remoting/webapp/remoting.js ('K') | « remoting/webapp/remoting.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698