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

Side by Side Diff: remoting/webapp/crd/js/butter_bar.js

Issue 964723003: Remove HRD butterbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * ButterBar class that is used to show the butter bar with various 7 * ButterBar class that is used to show the butter bar with various
8 * notifications. 8 * notifications.
9 */ 9 */
10 10
11 'use strict'; 11 'use strict';
12 12
13 /** @suppress {duplicate} */ 13 /** @suppress {duplicate} */
14 var remoting = remoting || {}; 14 var remoting = remoting || {};
15 15
16 /** 16 /**
17 * @constructor 17 * @constructor
18 */ 18 */
19 remoting.ButterBar = function() { 19 remoting.ButterBar = function() {
20 this.storageKey_ = ''; 20 this.storageKey_ = '';
21 21
22 /** @type{remoting.ButterBar} */
23 var that = this;
24
25 /** @param {Object} syncValues */
26 var onSyncDataLoaded = function(syncValues) {
27 chrome.storage.local.get(
28 remoting.kIT2MeVisitedStorageKey,
29 that.onStateLoaded_.bind(that, syncValues));
30 };
31
32 chrome.storage.sync.get( 22 chrome.storage.sync.get(
33 [remoting.ButterBar.kSurveyStorageKey_, 23 [remoting.ButterBar.kSurveyStorageKey_],
34 remoting.ButterBar.kHangoutsStorageKey_], 24 this.onStateLoaded_.bind(this));
35 onSyncDataLoaded);
36 } 25 }
37 26
38 /** 27 /**
39 * Shows butter bar with the specified |message| and updates |storageKey| after 28 * Shows butter bar with the specified |message| and updates |storageKey| after
40 * the bar is dismissed. 29 * the bar is dismissed.
41 * 30 *
42 * @param {string} messageId 31 * @param {string} messageId
43 * @param {string|Array} substitutions 32 * @param {string|Array} substitutions
44 * @param {string} storageKey 33 * @param {string} storageKey
45 * @private 34 * @private
(...skipping 10 matching lines...) Expand all
56 'click', this.dismiss.bind(this, true), false); 45 'click', this.dismiss.bind(this, true), false);
57 46
58 document.getElementById(remoting.ButterBar.kDismissId_).addEventListener( 47 document.getElementById(remoting.ButterBar.kDismissId_).addEventListener(
59 'click', this.dismiss.bind(this, false), false); 48 'click', this.dismiss.bind(this, false), false);
60 49
61 document.getElementById(remoting.ButterBar.kId_).hidden = false; 50 document.getElementById(remoting.ButterBar.kId_).hidden = false;
62 } 51 }
63 52
64 /** 53 /**
65 * @param {Object} syncValues 54 * @param {Object} syncValues
66 * @param {Object} localValues
67 * @private 55 * @private
68 */ 56 */
69 remoting.ButterBar.prototype.onStateLoaded_ = 57 remoting.ButterBar.prototype.onStateLoaded_ = function(syncValues) {
70 function(syncValues, localValues) {
71 /** @type {boolean} */ 58 /** @type {boolean} */
72 var surveyDismissed = !!syncValues[remoting.ButterBar.kSurveyStorageKey_]; 59 var surveyDismissed = !!syncValues[remoting.ButterBar.kSurveyStorageKey_];
73 /** @type {boolean} */
74 var hangoutsDismissed =
75 !!syncValues[remoting.ButterBar.kHangoutsStorageKey_];
76 /** @type {boolean} */
77 var it2meExpanded = !!localValues[remoting.kIT2MeVisitedStorageKey];
78 60
79 var showSurvey = !surveyDismissed; 61 if (!surveyDismissed) {
80 var showHangouts = it2meExpanded && !hangoutsDismissed;
81
82 // If both messages can be shown choose only one randomly.
83 if (showSurvey && showHangouts) {
84 if (Math.random() > 0.5) {
85 showSurvey = false;
86 } else {
87 showHangouts = false;
88 }
89 }
90
91 if (showSurvey) {
92 this.show_(/*i18n-content*/'SURVEY_INVITATION', 62 this.show_(/*i18n-content*/'SURVEY_INVITATION',
93 ['<a href="http://goo.gl/njH2q" target="_blank">', '</a>'], 63 ['<a href="http://goo.gl/njH2q" target="_blank">', '</a>'],
94 remoting.ButterBar.kSurveyStorageKey_); 64 remoting.ButterBar.kSurveyStorageKey_);
95 } else if (showHangouts) {
96 this.show_(/*i18n-content*/'HANGOUTS_INVITATION',
97 ['<a id="hangouts-accept" ' +
98 'href="https://plus.google.com/hangouts/_?gid=818572447316" ' +
99 'target="_blank">',
100 '</a>'],
101 remoting.ButterBar.kHangoutsStorageKey_);
102 } 65 }
103 }; 66 };
104 67
105 /** @const @private */ 68 /** @const @private */
106 remoting.ButterBar.kId_ = 'butter-bar'; 69 remoting.ButterBar.kId_ = 'butter-bar';
107 70
108 /** @const @private */ 71 /** @const @private */
109 remoting.ButterBar.kMessageId_ = 'butter-bar-message'; 72 remoting.ButterBar.kMessageId_ = 'butter-bar-message';
110 /** @const @private */ 73 /** @const @private */
111 remoting.ButterBar.kDismissId_ = 'butter-bar-dismiss'; 74 remoting.ButterBar.kDismissId_ = 'butter-bar-dismiss';
112 75
113 /** @const @private */ 76 /** @const @private */
114 remoting.ButterBar.kSurveyStorageKey_ = 'feedback-survey-dismissed'; 77 remoting.ButterBar.kSurveyStorageKey_ = 'feedback-survey-dismissed';
115 /** @const @private */
116 remoting.ButterBar.kHangoutsStorageKey_ = 'hangouts-notice-dismissed';
117 78
118 /** 79 /**
119 * Hide the butter bar request and record some basic information about the 80 * Hide the butter bar request and record some basic information about the
120 * current state of the world in synced storage. This may be useful in the 81 * current state of the world in synced storage. This may be useful in the
121 * future if we want to show the request again. At the moment, the data itself 82 * future if we want to show the request again. At the moment, the data itself
122 * is ignored; only its presence or absence is important. 83 * is ignored; only its presence or absence is important.
123 * 84 *
124 * @param {boolean} accepted True if the user clicked the "accept" link; 85 * @param {boolean} accepted True if the user clicked the "accept" link;
125 * false if they clicked the close icon. 86 * false if they clicked the close icon.
126 */ 87 */
127 remoting.ButterBar.prototype.dismiss = function(accepted) { 88 remoting.ButterBar.prototype.dismiss = function(accepted) {
128 var value = {}; 89 var value = {};
129 value[this.storageKey_] = { 90 value[this.storageKey_] = {
130 optIn: accepted, 91 optIn: accepted,
131 date: new Date(), 92 date: new Date(),
132 version: chrome.runtime.getManifest().version 93 version: chrome.runtime.getManifest().version
133 }; 94 };
134 chrome.storage.sync.set(value); 95 chrome.storage.sync.set(value);
135 96
136 document.getElementById(remoting.ButterBar.kId_).hidden = true; 97 document.getElementById(remoting.ButterBar.kId_).hidden = true;
137 }; 98 };
OLDNEW
« remoting/webapp/crd/js/background.js ('K') | « remoting/webapp/crd/js/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698