Chromium Code Reviews| 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..af6578743f99c24520d127cd67e223e28398708e 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,14 @@ cr.define('ntp4', function() { |
| onShowOptions_: function(e) { |
| window.location = this.app_.appData.options_url; |
| }, |
| + onDisableNotifications_: function(e) { |
| + var app = this.app_; |
| + var disabled = this.disableNotifications_.checked; |
| + app.removeBubble(); |
| + app.appData.notifications_disabled = !disabled; |
|
Evan Stade
2011/12/05 23:19:32
as it stands, isn't this backwards
asargent_no_longer_on_chrome
2011/12/06 00:14:55
Nope, this event handler toggles the sense of the
Evan Stade
2011/12/06 01:27:08
ah, I think the confusion is about whether checked
|
| + chrome.send('setNotificationsDisabled', |
| + [app.appData.id, app.appData.notifications_disabled]); |
|
Evan Stade
2011/12/05 23:19:32
nit: s/app.appData.notifications_disabled/disabled
asargent_no_longer_on_chrome
2011/12/06 00:14:55
fixed by refactor
|
| + }, |
| onUninstall_: function(e) { |
| chrome.send('uninstallApp', [this.app_.appData.id]); |
| }, |
| @@ -222,7 +241,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 +376,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 +821,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); |
| }; |