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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/notifications.js

Issue 2054473003: Implement update notifications for ChromeVox Next. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 4 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
OLDNEW
(Empty)
1 // Copyright 2016 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 Provides notification support for ChromeVox.
7 */
8
9 goog.provide('Notifications');
10
11 /**
12 * ChromeVox update notification.
13 * @constructor
14 */
15 function UpdateNotification() {
16 this.data = {};
17 this.data.type = 'basic';
18 this.data.iconUrl = '/images/chromevox-16.png';
19 this.data.title = Msgs.getMsg('update_title');
20 this.data.message = Msgs.getMsg('update_message_next');
21 }
22
23 UpdateNotification.prototype = {
24 /** @return {boolean} */
25 shouldShow: function() {
26 return !localStorage['notifications_update_notification_shown'] &&
27 chrome.runtime.getManifest().version >= '53';
28 },
29
30 /** Shows the notification. */
31 show: function() {
32 if (!this.shouldShow())
33 return;
34 chrome.notifications.create('update', this.data);
35 chrome.notifications.onClicked.addListener(
36 this.onClicked.bind(this));
37 chrome.notifications.onClosed.addListener(
38 this.onClosed.bind(this));
39 },
40
41 /**
42 * Handles the chrome.notifications event.
43 * @param {string} notificationId
44 */
45 onClicked: function(notificationId) {
46 var nextUpdatePage = {url: 'cvox2/background/next_update.html'};
47 chrome.tabs.create(nextUpdatePage);
48 },
49
50 /**
51 * Handles the chrome.notifications event.
52 * @param {string} id
53 */
54 onClosed: function(id) {
55 localStorage['notifications_update_notification_shown'] = true;
56 }
57 };
58
59 /**
60 * Runs notifications that should be shown for startup.
61 */
62 Notifications.onStartup = function() {
63 // Only run on background page.
64 if (document.location.href.indexOf('background.html') == -1)
65 return;
66
67 new UpdateNotification().show();
68 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698