| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/notifications.js
|
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/notifications.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/notifications.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d5f3f30d5702c75b489f752abb03212b92a05921
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/notifications.js
|
| @@ -0,0 +1,68 @@
|
| +// Copyright 2016 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 Provides notification support for ChromeVox.
|
| + */
|
| +
|
| +goog.provide('Notifications');
|
| +
|
| +/**
|
| + * ChromeVox update notification.
|
| + * @constructor
|
| + */
|
| +function UpdateNotification() {
|
| + this.data = {};
|
| + this.data.type = 'basic';
|
| + this.data.iconUrl = '/images/chromevox-16.png';
|
| + this.data.title = Msgs.getMsg('update_title');
|
| + this.data.message = Msgs.getMsg('update_message_next');
|
| +}
|
| +
|
| +UpdateNotification.prototype = {
|
| + /** @return {boolean} */
|
| + shouldShow: function() {
|
| + return !localStorage['notifications_update_notification_shown'] &&
|
| + chrome.runtime.getManifest().version >= '53';
|
| + },
|
| +
|
| +/** Shows the notification. */
|
| + show: function() {
|
| + if (!this.shouldShow())
|
| + return;
|
| + chrome.notifications.create('update', this.data);
|
| + chrome.notifications.onClicked.addListener(
|
| + this.onClicked.bind(this));
|
| + chrome.notifications.onClosed.addListener(
|
| + this.onClosed.bind(this));
|
| + },
|
| +
|
| + /**
|
| + * Handles the chrome.notifications event.
|
| + * @param {string} notificationId
|
| + */
|
| + onClicked: function(notificationId) {
|
| + var nextUpdatePage = {url: 'cvox2/background/next_update.html'};
|
| + chrome.tabs.create(nextUpdatePage);
|
| + },
|
| +
|
| + /**
|
| + * Handles the chrome.notifications event.
|
| + * @param {string} id
|
| + */
|
| + onClosed: function(id) {
|
| + localStorage['notifications_update_notification_shown'] = true;
|
| + }
|
| +};
|
| +
|
| +/**
|
| + * Runs notifications that should be shown for startup.
|
| + */
|
| +Notifications.onStartup = function() {
|
| + // Only run on background page.
|
| + if (document.location.href.indexOf('background.html') == -1)
|
| + return;
|
| +
|
| + new UpdateNotification().show();
|
| +};
|
|
|