| OLD | NEW | 
|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 /** | 5 /** | 
| 6  * @fileoverview 'settings-channel-switcher-dialog' is a component allowing the | 6  * @fileoverview 'settings-channel-switcher-dialog' is a component allowing the | 
| 7  * user to switch between release channels (dev, beta, stable). A | 7  * user to switch between release channels (dev, beta, stable). A | 
| 8  * |target-channel-changed| event is fired if the user does select a different | 8  * |target-channel-changed| event is fired if the user does select a different | 
| 9  * release channel to notify parents of this dialog. | 9  * release channel to notify parents of this dialog. | 
| 10  */ | 10  */ | 
| 11 Polymer({ | 11 Polymer({ | 
| 12   is: 'settings-channel-switcher-dialog', | 12   is: 'settings-channel-switcher-dialog', | 
| 13 | 13 | 
| 14   behaviors: [I18nBehavior], | 14   behaviors: [I18nBehavior], | 
| 15 | 15 | 
| 16   properties: { | 16   properties: { | 
| 17     /** @private */ | 17     /** @private */ | 
| 18     browserChannelEnum_: { | 18     browserChannelEnum_: { | 
| 19       type: Object, | 19       type: Object, | 
| 20       value: BrowserChannel, | 20       value: BrowserChannel, | 
| 21     }, | 21     }, | 
| 22 | 22 | 
| 23     /** @private {!BrowserChannel} */ | 23     /** @private {!BrowserChannel} */ | 
| 24     currentChannel_: String, | 24     currentChannel_: String, | 
| 25 | 25 | 
|  | 26     /** @private {!BrowserChannel} */ | 
|  | 27     targetChannel_: String, | 
|  | 28 | 
| 26     /** | 29     /** | 
| 27      * Controls which of the two action buttons is visible. | 30      * Controls which of the two action buttons is visible. | 
| 28      * @private {?{changeChannel: boolean, changeChannelAndPowerwash: boolean}} | 31      * @private {?{changeChannel: boolean, changeChannelAndPowerwash: boolean}} | 
| 29      */ | 32      */ | 
| 30     shouldShowButtons_: { | 33     shouldShowButtons_: { | 
| 31       type: Object, | 34       type: Object, | 
| 32       value: null, | 35       value: null, | 
| 33     }, | 36     }, | 
| 34 | 37 | 
| 35     /** @private {?{title: string, description: string}} */ | 38     /** @private {?{title: string, description: string}} */ | 
| 36     warning_: { | 39     warning_: { | 
| 37       type: Object, | 40       type: Object, | 
| 38       value: null, | 41       value: null, | 
| 39     }, | 42     }, | 
| 40   }, | 43   }, | 
| 41 | 44 | 
| 42   /** @private {?settings.AboutPageBrowserProxy} */ | 45   /** @private {?settings.AboutPageBrowserProxy} */ | 
| 43   browserProxy_: null, | 46   browserProxy_: null, | 
| 44 | 47 | 
| 45   /** @override */ | 48   /** @override */ | 
| 46   ready: function() { | 49   ready: function() { | 
| 47     this.browserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); | 50     this.browserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); | 
| 48 | 51     this.browserProxy_.getChannelInfo().then(function(info) { | 
| 49     this.browserProxy_.getCurrentChannel().then(function(channel) { | 52       this.currentChannel_ = info.currentChannel; | 
| 50       this.currentChannel_ = channel; | 53       this.targetChannel_ = info.targetChannel; | 
| 51       // Pre-populate radio group with current channel. | 54       // Pre-populate radio group with target channel. | 
| 52       this.$$('paper-radio-group').select(channel); | 55       this.$$('paper-radio-group').select(this.targetChannel_); | 
| 53     }.bind(this)); | 56     }.bind(this)); | 
| 54   }, | 57   }, | 
| 55 | 58 | 
| 56   /** @override */ | 59   /** @override */ | 
| 57   attached: function() { | 60   attached: function() { | 
| 58     this.$.dialog.showModal(); | 61     this.$.dialog.showModal(); | 
| 59   }, | 62   }, | 
| 60 | 63 | 
| 61   /** @private */ | 64   /** @private */ | 
| 62   onCancelTap_: function() { | 65   onCancelTap_: function() { | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 111     this.shouldShowButtons_ = { | 114     this.shouldShowButtons_ = { | 
| 112       changeChannel: changeChannel, | 115       changeChannel: changeChannel, | 
| 113       changeChannelAndPowerwash: changeChannelAndPowerwash, | 116       changeChannelAndPowerwash: changeChannelAndPowerwash, | 
| 114     }; | 117     }; | 
| 115   }, | 118   }, | 
| 116 | 119 | 
| 117   /** @private */ | 120   /** @private */ | 
| 118   onChannelSelectionChanged_: function() { | 121   onChannelSelectionChanged_: function() { | 
| 119     var selectedChannel = this.$$('paper-radio-group').selected; | 122     var selectedChannel = this.$$('paper-radio-group').selected; | 
| 120 | 123 | 
|  | 124     // Selected channel is the same as the target channel so only show 'cancel'. | 
|  | 125     if (selectedChannel == this.targetChannel_) { | 
|  | 126       this.shouldShowButtons_ = null; | 
|  | 127       this.warning_ = null; | 
|  | 128       return; | 
|  | 129     } | 
|  | 130 | 
|  | 131     // Selected channel is the same as the current channel, allow the user to | 
|  | 132     // change without warnings. | 
| 121     if (selectedChannel == this.currentChannel_) { | 133     if (selectedChannel == this.currentChannel_) { | 
| 122       this.shouldShowButtons_ = null; | 134       this.updateButtons_(true, false); | 
| 123       this.warning_ = null; | 135       this.warning_ = null; | 
| 124       return; | 136       return; | 
| 125     } | 137     } | 
| 126 | 138 | 
| 127     if (settings.isTargetChannelMoreStable( | 139     if (settings.isTargetChannelMoreStable( | 
| 128         this.currentChannel_, selectedChannel)) { | 140         this.currentChannel_, selectedChannel)) { | 
|  | 141       // More stable channel selected. For non managed devices, notify the user | 
|  | 142       // about powerwash. | 
| 129       if (loadTimeData.getBoolean('aboutEnterpriseManaged')) { | 143       if (loadTimeData.getBoolean('aboutEnterpriseManaged')) { | 
| 130         this.updateWarning_( | 144         this.updateWarning_( | 
| 131             'aboutDelayedWarningTitle', | 145             'aboutDelayedWarningTitle', 'aboutDelayedWarningMessage', | 
| 132             'aboutDelayedWarningMessage', |  | 
| 133             'aboutProductTitle'); | 146             'aboutProductTitle'); | 
| 134         this.updateButtons_(true, false); | 147         this.updateButtons_(true, false); | 
| 135       } else { | 148       } else { | 
| 136         this.updateWarning_( | 149         this.updateWarning_( | 
| 137           'aboutPowerwashWarningTitle', 'aboutPowerwashWarningMessage'); | 150             'aboutPowerwashWarningTitle', 'aboutPowerwashWarningMessage'); | 
| 138         this.updateButtons_(false, true); | 151         this.updateButtons_(false, true); | 
| 139       } | 152       } | 
| 140     } else { | 153     } else { | 
| 141       this.updateWarning_( | 154       if (selectedChannel == BrowserChannel.DEV) { | 
| 142         'aboutUnstableWarningTitle', | 155         // Dev channel selected, warn the user. | 
| 143         'aboutUnstableWarningMessage', | 156         this.updateWarning_( | 
| 144         'aboutProductTitle'); | 157             'aboutUnstableWarningTitle', 'aboutUnstableWarningMessage', | 
|  | 158             'aboutProductTitle'); | 
|  | 159       } else { | 
|  | 160         this.warning_ = null; | 
|  | 161       } | 
| 145       this.updateButtons_(true, false); | 162       this.updateButtons_(true, false); | 
| 146     } | 163     } | 
| 147   }, | 164   }, | 
| 148 | 165 | 
| 149   /** | 166   /** | 
| 150    * @return {boolean} | 167    * @return {boolean} | 
| 151    * @private | 168    * @private | 
| 152    */ | 169    */ | 
| 153   shouldShowWarning_: function() { | 170   shouldShowWarning_: function() { | 
| 154     return this.warning_ !== null; | 171     return this.warning_ !== null; | 
| 155   }, | 172   }, | 
| 156 }); | 173 }); | 
| OLD | NEW | 
|---|