blob: 13954e338aa3c8463392240d48230cbbc1dffabf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
};
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);
};
|