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

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

Issue 14803010: Add link to Hangouts Remote Desktop in the It2Me section of the remoting app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « remoting/webapp/all_js_load.gtestjs ('k') | remoting/webapp/main.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * ButterBar class that is used to show the butter bar with various
8 * notifications.
9 */
10
11 'use strict';
12
13 /** @suppress {duplicate} */
14 var remoting = remoting || {};
15
16 /**
17 * Shows butter bar with the specified |message| and updates |storageKey| after
18 * the bar is dismissed.
19 *
20 * @param {string} message
21 * @param {string} storageKey
22 * @constructor
23 */
24 remoting.ButterBar = function(message, storageKey) {
25 this.storageKey = storageKey;
26
27 var messageElement = document.getElementById(remoting.ButterBar.kMessageId);
28 messageElement.innerHTML = message;
Jamie 2013/05/30 01:10:17 innerHTML makes me nervous :( The only other place
Sergey Ulanov 2013/05/30 22:04:54 The alternative is what I had before - have each m
Jamie 2013/05/31 00:12:42 I like this approach more--the HTML is simpler thi
Sergey Ulanov 2013/06/03 19:11:48 Done.
29 var acceptLink =
30 /** @type{Element} */ messageElement.getElementsByTagName('a')[0];
31 acceptLink.addEventListener(
32 'click', this.dismiss.bind(this, true), false);
33
34 document.getElementById(remoting.ButterBar.kDismissId).addEventListener(
35 'click', this.dismiss.bind(this, false), false);
36
37 document.getElementById(remoting.ButterBar.kId).hidden = false;
38 }
39
40 /** @const */
Jamie 2013/05/30 01:10:17 I think these can all be made private (in which ca
Sergey Ulanov 2013/05/30 22:04:54 Done.
41 remoting.ButterBar.kId = 'butter-bar';
42
43 /** @const */
44 remoting.ButterBar.kMessageId = 'butter-bar-message';
45 /** @const */
46 remoting.ButterBar.kDismissId = 'butter-bar-dismiss';
47
48 /** @const */
49 remoting.kSurveyStorageKey = 'feedback-survey-dismissed';
50 /** @const */
51 remoting.kHangoutsStorageKey = 'hangouts-notice-dismissed';
52
53 /**
54 * Hide the butter bar request and record some basic information about the
55 * current state of the world in synced storage. This may be useful in the
56 * future if we want to show the request again. At the moment, the data itself
57 * is ignored; only its presence or absence is important.
58 *
59 * @param {boolean} accepted True if the user clicked the "accept" link;
60 * false if they clicked the close icon.
61 */
62 remoting.ButterBar.prototype.dismiss = function(accepted) {
63 var value = {};
64 value[this.storageKey] = {
65 accepted: accepted,
66 date: new Date(),
67 version: chrome.runtime.getManifest().version
68 };
69 chrome.storage.sync.set(value);
70
71 document.getElementById(remoting.ButterBar.kId).hidden = true;
72 };
73
74 /**
75 * Show the butter bar if there is a message to show.
76 */
77 remoting.initButterBar = function() {
78 /** @param {Object} syncValues
79 * @param {Object} localValues */
80 var onStateLoaded = function(syncValues, localValues) {
81 /** @type {boolean} */
82 var surveyDismissed = !!syncValues[remoting.kSurveyStorageKey];
83 /** @type {boolean} */
84 var hangoutsDismissed = !!syncValues[remoting.kHangoutsStorageKey];
85 /** @type {boolean} */
86 var it2meExpanded = !!localValues[remoting.kIT2MeVisitedStorageKey];
87
88 var showSurvey = !surveyDismissed;
89 var showHangouts = it2meExpanded && !hangoutsDismissed;
90
91 // If both messages can be shown choose only one randomly.
92 if (showSurvey && showHangouts) {
93 if (Math.random() > 0.5) {
94 showSurvey = false;
95 } else {
96 showHangouts = false;
97 }
98 }
99
100 if (showSurvey) {
101 new remoting.ButterBar(
Jamie 2013/05/30 01:10:17 I'm always skeptical of a 'new' statement that doe
Sergey Ulanov 2013/05/30 22:04:54 Done.
102 chrome.i18n.getMessage(
103 /*i18n-content*/'SURVEY_INVITATION',
104 ['<a href="http://goo.gl/njH2q" target="_blank">', '</a>']),
105 remoting.kSurveyStorageKey);
106 } else if (showHangouts) {
107 new remoting.ButterBar(
108 chrome.i18n.getMessage(
109 /*i18n-content*/'HANGOUTS_INVITATION',
110 ['<a id="hangouts-accept" ' +
111 'href="https://plus.google.com/hangouts/_?gid=818572447316">',
112 '</a>']),
113 remoting.kHangoutsStorageKey);
114 }
115 };
116
117 /** @param {Object} syncValues */
118 var onSyncDataLoaded = function(syncValues) {
119 chrome.storage.local.get(
120 remoting.kIT2MeVisitedStorageKey,
121 onStateLoaded.bind(null, syncValues));
122 };
123
124 chrome.storage.sync.get(
125 [remoting.kSurveyStorageKey, remoting.kHangoutsStorageKey],
126 onSyncDataLoaded);
127 }
OLDNEW
« no previous file with comments | « remoting/webapp/all_js_load.gtestjs ('k') | remoting/webapp/main.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698