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

Unified Diff: chrome/browser/resources/ntp4/apps_page.js

Issue 8785016: Add menu option for disabling app notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another fix from review comments Created 9 years 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/ntp4/apps_page.js
diff --git a/chrome/browser/resources/ntp4/apps_page.js b/chrome/browser/resources/ntp4/apps_page.js
index 7551b0dc48940d62d38eceafd3c8c967e9cdf1d7..d096229cd67ff2c6071093068df2cb1932db6bd5 100644
--- a/chrome/browser/resources/ntp4/apps_page.js
+++ b/chrome/browser/resources/ntp4/apps_page.js
@@ -63,9 +63,13 @@ cr.define('ntp4', function() {
menu.appendChild(cr.ui.MenuItem.createSeparator());
this.options_ = this.appendMenuItem_('appoptions');
+ this.disableNotifications_ =
+ this.appendMenuItem_('appdisablenotifications');
this.uninstall_ = this.appendMenuItem_('appuninstall');
this.options_.addEventListener('activate',
this.onShowOptions_.bind(this));
+ this.disableNotifications_.addEventListener(
+ 'activate', this.onDisableNotifications_.bind(this));
this.uninstall_.addEventListener('activate',
this.onUninstall_.bind(this));
@@ -115,7 +119,7 @@ cr.define('ntp4', function() {
},
/**
- * Does all the necessary setup to show the menu for the give app.
+ * Does all the necessary setup to show the menu for the given app.
* @param {App} app The App object that will be showing a context menu.
*/
setupForApp: function(app) {
@@ -130,6 +134,13 @@ cr.define('ntp4', function() {
this.options_.disabled = !app.appData.options_url || !app.appData.enabled;
this.uninstall_.disabled = !app.appData.can_uninstall;
+
+ this.disableNotifications_.hidden = true;
+ var notificationsDisabled = app.appData.notifications_disabled;
+ if (typeof notificationsDisabled != 'undefined') {
+ this.disableNotifications_.hidden = false;
+ this.disableNotifications_.checked = notificationsDisabled;
+ }
},
/**
@@ -155,6 +166,16 @@ cr.define('ntp4', function() {
onShowOptions_: function(e) {
window.location = this.app_.appData.options_url;
},
+ onDisableNotifications_: function(e) {
+ var app = this.app_;
+ var currentlyDisabled = app.appData.notifications_disabled;
Evan Stade 2011/12/05 22:04:16 could you instead do var disabled = this.disableN
asargent_no_longer_on_chrome 2011/12/05 23:09:14 Done.
+ if (!currentlyDisabled) {
Evan Stade 2011/12/05 22:04:16 no curlies. also, what is the advantage of this c
asargent_no_longer_on_chrome 2011/12/05 23:09:14 Good point - if we're toggling from disabled to en
+ app.removeBubble();
+ }
+ app.appData.notifications_disabled = !currentlyDisabled;
+ chrome.send('setNotificationsDisabled',
+ [app.appData.id, app.appData.notifications_disabled]);
+ },
onUninstall_: function(e) {
chrome.send('uninstallApp', [this.app_.appData.id]);
},
@@ -222,7 +243,8 @@ cr.define('ntp4', function() {
var notification = this.appData_.notification;
var hasNotification = typeof notification != 'undefined' &&
typeof notification['title'] != 'undefined' &&
- typeof notification['body'] != 'undefined';
+ typeof notification['body'] != 'undefined' &&
+ !this.appData_.notifications_disabled;
if (hasNotification)
this.setupNotification_(notification);
@@ -356,6 +378,16 @@ cr.define('ntp4', function() {
},
/**
+ * Removes the info bubble if there is one.
+ */
+ removeBubble: function() {
+ if (this.currentBubbleShowing_) {
+ this.currentBubbleShowing_.hide();
+ this.currentBubbleShowing_ = null;
+ }
+ },
+
+ /**
* Creates the apps-promo section of the app (should only be called for the
* webstore app).
* @private
@@ -791,7 +823,8 @@ cr.define('ntp4', function() {
function appNotificationChanged(id, notification) {
var app = $(id);
- if (app) // The app might have been uninstalled.
+ // The app might have been uninstalled, or notifications might be disabled.
+ if (app && !app.appData.notifications_disabled)
app.setupNotification_(notification);
};

Powered by Google App Engine
This is Rietveld 408576698