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

Unified 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 side-by-side diff with in-line comments
Download patch
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();
+};

Powered by Google App Engine
This is Rietveld 408576698