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..ac21c6aec742f7256e1526651c4fd44ffbcc0975 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; |
|
Finnur
2011/12/05 16:15:16
The underscore in appData_ denotes private, you sh
asargent_no_longer_on_chrome
2011/12/05 17:42:39
Done.
|
| + if (typeof notificationsDisabled != 'undefined') { |
| + this.disableNotifications_.hidden = false; |
| + this.disableNotifications_.checked = notificationsDisabled; |
| + } |
| }, |
| /** |
| @@ -155,6 +166,17 @@ 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; |
| + if (!currentlyDisabled && app.currentBubbleShowing_) { |
|
Finnur
2011/12/05 16:15:16
same problem here, _ means private.
asargent_no_longer_on_chrome
2011/12/05 17:42:39
Done.
Finnur
2011/12/05 17:50:00
I was referring to currentBubbleShowing_ ...
On
asargent_no_longer_on_chrome
2011/12/05 18:21:05
Oops, fixed. I added a method called removeBubble
|
| + app.currentBubbleShowing_.hide(); |
| + app.currentBubbleShowing_ = null; |
| + } |
| + 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 +244,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); |
| @@ -791,7 +814,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); |
| }; |