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

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

Issue 2103053006: Fix tests flakes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Not for review: testing on try bots; disable notifications 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
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index a28109f97644661db0c56e2f32857958900781ff..40383b22ccfca30fd5b0d1e122833a3608be55ae 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/notifications.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/notifications.js
@@ -33,10 +33,8 @@ UpdateNotification.prototype = {
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));
+ chrome.notifications.onClicked.addListener(this.onClicked);
+ chrome.notifications.onClosed.addListener(this.onClosed);
},
/**
@@ -54,24 +52,42 @@ UpdateNotification.prototype = {
*/
onClosed: function(id) {
localStorage['notifications_update_notification_shown'] = true;
+ },
+
+ /**
+ * Removes all listeners added by this object.
+ */
+ removeAllListeners: function() {
+ chrome.notifications.onClicked.removeListener(this.onClicked);
+ chrome.notifications.onClosed.removeListener(this.onClosed);
}
};
/**
+ * Set after an update is shown.
+ * @type {UpdateNotification}
+ */
+Notifications.currentUpdate;
+
+/**
* Runs notifications that should be shown for startup.
*/
Notifications.onStartup = function() {
+ return;
// Only run on background page.
if (document.location.href.indexOf('background.html') == -1)
return;
- new UpdateNotification().show();
+ Notifications.reset();
+ Notifications.currentUpdate = new UpdateNotification();
+ Notifications.currentUpdate.show();
};
/**
* Runs notifications that should be shown for mode changes.
*/
Notifications.onModeChange = function() {
+ return;
// Only run on background page.
if (document.location.href.indexOf('background.html') == -1)
return;
@@ -79,5 +95,16 @@ Notifications.onModeChange = function() {
if (ChromeVoxState.instance.mode !== ChromeVoxMode.FORCE_NEXT)
return;
- new UpdateNotification().show();
+ Notifications.reset();
+ Notifications.currentUpdate = new UpdateNotification();
+ Notifications.currentUpdate.show();
+};
+
+/**
+ * Resets to a clean state. Future events will trigger update notifications.
+ */
+Notifications.reset = function() {
+ if (Notifications.currentUpdate)
+ Notifications.currentUpdate.removeAllListeners();
+ delete localStorage['notifications_update_notification_shown'];
};
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698