OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 cr.define('help', function() { | 5 cr.define('help', function() { |
6 var Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
8 | 8 |
9 /** | 9 /** |
10 * Encapsulated handling of the About page. Called 'help' internally to avoid | 10 * Encapsulated handling of the About page. Called 'help' internally to avoid |
11 * confusion with generic AboutUI (about:version, about:sandbox, etc.). | 11 * confusion with generic AboutUI (about:version, about:sandbox, etc.). |
12 */ | 12 */ |
13 function HelpPage() { | 13 function HelpPage() { |
14 var id = loadTimeData.valueExists('aboutOverlayTabTitle') ? | 14 var id = loadTimeData.valueExists('aboutOverlayTabTitle') ? |
15 'aboutOverlayTabTitle' : 'aboutTitle'; | 15 'aboutOverlayTabTitle' : |
| 16 'aboutTitle'; |
16 Page.call(this, 'help', loadTimeData.getString(id), 'help-page'); | 17 Page.call(this, 'help', loadTimeData.getString(id), 'help-page'); |
17 } | 18 } |
18 | 19 |
19 cr.addSingletonGetter(HelpPage); | 20 cr.addSingletonGetter(HelpPage); |
20 | 21 |
21 HelpPage.prototype = { | 22 HelpPage.prototype = { |
22 __proto__: Page.prototype, | 23 __proto__: Page.prototype, |
23 | 24 |
24 /** | 25 /** |
25 * List of the channel names. Should be ordered in increasing level of | 26 * List of the channel names. Should be ordered in increasing level of |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 $('eol-learnMore').innerHTML = loadTimeData.getString('eolLearnMore'); | 88 $('eol-learnMore').innerHTML = loadTimeData.getString('eolLearnMore'); |
88 } | 89 } |
89 | 90 |
90 var productTOS = $('product-tos'); | 91 var productTOS = $('product-tos'); |
91 if (productTOS) | 92 if (productTOS) |
92 productTOS.innerHTML = loadTimeData.getString('productTOS'); | 93 productTOS.innerHTML = loadTimeData.getString('productTOS'); |
93 | 94 |
94 $('get-help').onclick = function() { | 95 $('get-help').onclick = function() { |
95 chrome.send('openHelpPage'); | 96 chrome.send('openHelpPage'); |
96 }; | 97 }; |
97 <if expr="_google_chrome"> | 98 // <if expr="_google_chrome"> |
98 $('report-issue').onclick = function() { | 99 $('report-issue').onclick = function() { |
99 chrome.send('openFeedbackDialog'); | 100 chrome.send('openFeedbackDialog'); |
100 }; | 101 }; |
101 </if> | 102 // </if> |
102 | 103 |
103 this.maybeSetOnClick_($('more-info-expander'), | 104 this.maybeSetOnClick_( |
104 this.toggleMoreInfo_.bind(this)); | 105 $('more-info-expander'), this.toggleMoreInfo_.bind(this)); |
105 | 106 |
106 this.maybeSetOnClick_($('promote'), function() { | 107 this.maybeSetOnClick_($('promote'), function() { |
107 chrome.send('promoteUpdater'); | 108 chrome.send('promoteUpdater'); |
108 }); | 109 }); |
109 this.maybeSetOnClick_($('relaunch'), function() { | 110 this.maybeSetOnClick_($('relaunch'), function() { |
110 chrome.send('relaunchNow'); | 111 chrome.send('relaunchNow'); |
111 }); | 112 }); |
112 if (cr.isChromeOS) { | 113 if (cr.isChromeOS) { |
113 this.maybeSetOnClick_($('relaunch-and-powerwash'), function() { | 114 this.maybeSetOnClick_($('relaunch-and-powerwash'), function() { |
114 chrome.send('relaunchAndPowerwash'); | 115 chrome.send('relaunchAndPowerwash'); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 'help-page-icon channel-change-error-icon'; | 163 'help-page-icon channel-change-error-icon'; |
163 channelChangeDisallowedError.appendChild(channelChangeDisallowedIcon); | 164 channelChangeDisallowedError.appendChild(channelChangeDisallowedIcon); |
164 | 165 |
165 var channelChangeDisallowedText = document.createElement('div'); | 166 var channelChangeDisallowedText = document.createElement('div'); |
166 channelChangeDisallowedText.className = 'channel-change-error-text'; | 167 channelChangeDisallowedText.className = 'channel-change-error-text'; |
167 channelChangeDisallowedText.textContent = | 168 channelChangeDisallowedText.textContent = |
168 loadTimeData.getString('channelChangeDisallowedMessage'); | 169 loadTimeData.getString('channelChangeDisallowedMessage'); |
169 channelChangeDisallowedError.appendChild(channelChangeDisallowedText); | 170 channelChangeDisallowedError.appendChild(channelChangeDisallowedText); |
170 | 171 |
171 $('channel-change-disallowed-icon').onclick = function() { | 172 $('channel-change-disallowed-icon').onclick = function() { |
172 PageManager.showBubble(channelChangeDisallowedError, | 173 PageManager.showBubble( |
173 $('channel-change-disallowed-icon'), | 174 channelChangeDisallowedError, $('channel-change-disallowed-icon'), |
174 $('help-container'), | 175 $('help-container'), cr.ui.ArrowLocation.TOP_END); |
175 cr.ui.ArrowLocation.TOP_END); | |
176 }; | 176 }; |
177 | 177 |
178 // Unhide the regulatory label if/when the image loads. | 178 // Unhide the regulatory label if/when the image loads. |
179 $('regulatory-label').onload = function() { | 179 $('regulatory-label').onload = function() { |
180 $('regulatory-label-container').hidden = false; | 180 $('regulatory-label-container').hidden = false; |
181 }; | 181 }; |
182 | 182 |
183 $('controlled-feature-icon').onclick = function(e) { | 183 $('controlled-feature-icon').onclick = function(e) { |
184 var content = /** @type {HTMLElement} */( | 184 var content = |
185 document.createElement('div')); | 185 /** @type {HTMLElement} */ (document.createElement('div')); |
186 content.textContent = | 186 content.textContent = |
187 loadTimeData.getString('updateDisabledByPolicy'); | 187 loadTimeData.getString('updateDisabledByPolicy'); |
188 var bubble = new cr.ui.AutoCloseBubble; | 188 var bubble = new cr.ui.AutoCloseBubble; |
189 bubble.id = 'controlled-feature-bubble'; | 189 bubble.id = 'controlled-feature-bubble'; |
190 bubble.anchorNode = $('controlled-feature-icon'); | 190 bubble.anchorNode = $('controlled-feature-icon'); |
191 bubble.domSibling = $('controlled-feature-icon'); | 191 bubble.domSibling = $('controlled-feature-icon'); |
192 bubble.arrowLocation = cr.ui.ArrowLocation.TOP_END; | 192 bubble.arrowLocation = cr.ui.ArrowLocation.TOP_END; |
193 bubble.content = content; | 193 bubble.content = content; |
194 bubble.show(); | 194 bubble.show(); |
195 }; | 195 }; |
196 } | 196 } |
197 | 197 |
198 var logo = $('product-logo'); | 198 var logo = $('product-logo'); |
199 logo.onclick = function(e) { | 199 logo.onclick = function(e) { |
200 logo.animate({ | 200 logo.animate( |
201 transform: ['none', 'rotate(-10turn)'], | 201 { |
202 }, /** @type {!KeyframeEffectOptions} */({ | 202 transform: ['none', 'rotate(-10turn)'], |
203 duration: 500, | 203 }, |
204 easing: 'cubic-bezier(1, 0, 0, 1)', | 204 /** @type {!KeyframeEffectOptions} */ ({ |
205 })); | 205 duration: 500, |
| 206 easing: 'cubic-bezier(1, 0, 0, 1)', |
| 207 })); |
206 }; | 208 }; |
207 | 209 |
208 // Attempt to update. | 210 // Attempt to update. |
209 chrome.send('onPageLoaded'); | 211 chrome.send('onPageLoaded'); |
210 }, | 212 }, |
211 | 213 |
212 /** @override */ | 214 /** @override */ |
213 didClosePage: function() { | 215 didClosePage: function() { |
214 this.setMoreInfoVisible_(false); | 216 this.setMoreInfoVisible_(false); |
215 }, | 217 }, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 $('current-channel').textContent = loadTimeData.getStringF( | 349 $('current-channel').textContent = loadTimeData.getStringF( |
348 'currentChannel', this.channelTable_[channel].label); | 350 'currentChannel', this.channelTable_[channel].label); |
349 this.updateChannelChangePageContainerVisibility_(); | 351 this.updateChannelChangePageContainerVisibility_(); |
350 if (cr.isChromeOS) | 352 if (cr.isChromeOS) |
351 $('dev-channel-disclaimer').hidden = (channel != 'dev-channel'); | 353 $('dev-channel-disclaimer').hidden = (channel != 'dev-channel'); |
352 } | 354 } |
353 | 355 |
354 if (status == null) | 356 if (status == null) |
355 return; | 357 return; |
356 | 358 |
357 if (cr.isMac && | 359 if (cr.isMac && $('update-status-message') && |
358 $('update-status-message') && | |
359 $('update-status-message').hidden) { | 360 $('update-status-message').hidden) { |
360 // Chrome has reached the end of the line on this system. The | 361 // Chrome has reached the end of the line on this system. The |
361 // update-obsolete-system message is displayed. No other auto-update | 362 // update-obsolete-system message is displayed. No other auto-update |
362 // status should be displayed. | 363 // status should be displayed. |
363 return; | 364 return; |
364 } | 365 } |
365 | 366 |
366 if (status == 'checking') { | 367 if (status == 'checking') { |
367 this.setUpdateImage_('working'); | 368 this.setUpdateImage_('working'); |
368 $('update-status-message').innerHTML = | 369 $('update-status-message').innerHTML = |
369 loadTimeData.getString('updateCheckStarted'); | 370 loadTimeData.getString('updateCheckStarted'); |
370 } else if (status == 'updating') { | 371 } else if (status == 'updating') { |
371 this.setUpdateImage_('working'); | 372 this.setUpdateImage_('working'); |
372 if (this.channelsDiffer_()) { | 373 if (this.channelsDiffer_()) { |
373 $('update-status-message').innerHTML = | 374 $('update-status-message').innerHTML = loadTimeData.getStringF( |
374 loadTimeData.getStringF('updatingChannelSwitch', | 375 'updatingChannelSwitch', this.channelTable_[channel].label); |
375 this.channelTable_[channel].label); | |
376 } else { | 376 } else { |
377 $('update-status-message').innerHTML = | 377 $('update-status-message').innerHTML = |
378 loadTimeData.getStringF('updating'); | 378 loadTimeData.getStringF('updating'); |
379 } | 379 } |
380 } else if (status == 'nearly_updated') { | 380 } else if (status == 'nearly_updated') { |
381 this.setUpdateImage_('up-to-date'); | 381 this.setUpdateImage_('up-to-date'); |
382 if (this.channelsDiffer_()) { | 382 if (this.channelsDiffer_()) { |
383 $('update-status-message').innerHTML = | 383 $('update-status-message').innerHTML = |
384 loadTimeData.getString('successfulChannelSwitch'); | 384 loadTimeData.getString('successfulChannelSwitch'); |
385 } else { | 385 } else { |
386 $('update-status-message').innerHTML = | 386 $('update-status-message').innerHTML = |
387 loadTimeData.getString('updateAlmostDone'); | 387 loadTimeData.getString('updateAlmostDone'); |
388 } | 388 } |
389 } else if (status == 'updated') { | 389 } else if (status == 'updated') { |
390 this.setUpdateImage_('up-to-date'); | 390 this.setUpdateImage_('up-to-date'); |
391 $('update-status-message').innerHTML = | 391 $('update-status-message').innerHTML = |
392 loadTimeData.getString('upToDate'); | 392 loadTimeData.getString('upToDate'); |
393 } else if (status == 'failed') { | 393 } else if (status == 'failed') { |
394 this.setUpdateImage_('failed'); | 394 this.setUpdateImage_('failed'); |
395 $('update-status-message').innerHTML = message; | 395 $('update-status-message').innerHTML = message; |
396 } else if (status == 'disabled_by_admin') { | 396 } else if (status == 'disabled_by_admin') { |
397 // This is the general behavior for non-chromeos. | 397 // This is the general behavior for non-chromeos. |
398 this.setUpdateImage_('disabled-by-admin'); | 398 this.setUpdateImage_('disabled-by-admin'); |
399 $('update-status-message').innerHTML = message; | 399 $('update-status-message').innerHTML = message; |
400 } | 400 } |
401 | 401 |
402 // Show EndofLife Strings if applicable | 402 // Show EndofLife Strings if applicable |
403 if (eolStatus == 'device_supported') { | 403 if (eolStatus == 'device_supported') { |
404 $('eol-status-container').hidden = true; | 404 $('eol-status-container').hidden = true; |
405 } else if (eolStatus == 'device_endoflife') { | 405 } else if (eolStatus == 'device_endoflife') { |
406 $('eol-message').innerHTML = eolMessage; | 406 $('eol-message').innerHTML = eolMessage; |
407 $('eol-status-container').hidden = false; | 407 $('eol-status-container').hidden = false; |
408 } | 408 } |
409 | 409 |
410 | 410 |
411 if (cr.isChromeOS) { | 411 if (cr.isChromeOS) { |
412 $('change-channel').disabled = !this.canChangeChannel_ || | 412 $('change-channel').disabled = |
413 status == 'nearly_updated'; | 413 !this.canChangeChannel_ || status == 'nearly_updated'; |
414 $('channel-change-disallowed-icon').hidden = this.canChangeChannel_; | 414 $('channel-change-disallowed-icon').hidden = this.canChangeChannel_; |
415 } | 415 } |
416 | 416 |
417 // Following invariant must be established at the end of this function: | 417 // Following invariant must be established at the end of this function: |
418 // { ~$('relaunch_and_powerwash').hidden -> $('relaunch').hidden } | 418 // { ~$('relaunch_and_powerwash').hidden -> $('relaunch').hidden } |
419 var relaunchAndPowerwashHidden = true; | 419 var relaunchAndPowerwashHidden = true; |
420 if ($('relaunch-and-powerwash')) { | 420 if ($('relaunch-and-powerwash')) { |
421 // It's allowed to do powerwash only for customer devices, | 421 // It's allowed to do powerwash only for customer devices, |
422 // when user explicitly decides to update to a more stable | 422 // when user explicitly decides to update to a more stable |
423 // channel. | 423 // channel. |
424 relaunchAndPowerwashHidden = | 424 relaunchAndPowerwashHidden = |
425 !this.targetChannelIsMoreStable_() || status != 'nearly_updated'; | 425 !this.targetChannelIsMoreStable_() || status != 'nearly_updated'; |
426 $('relaunch-and-powerwash').hidden = relaunchAndPowerwashHidden; | 426 $('relaunch-and-powerwash').hidden = relaunchAndPowerwashHidden; |
427 } | 427 } |
428 | 428 |
429 if (cr.isChromeOS) { | 429 if (cr.isChromeOS) { |
430 // Re-enable the update button if we are in a stale 'updated' status or | 430 // Re-enable the update button if we are in a stale 'updated' status or |
431 // update has failed, and disable it if there's an update in progress or | 431 // update has failed, and disable it if there's an update in progress or |
432 // updates are disabled by policy. | 432 // updates are disabled by policy. |
433 // In addition, Update button will be disabled when device is in eol | 433 // In addition, Update button will be disabled when device is in eol |
434 // status | 434 // status |
435 $('request-update').disabled = | 435 $('request-update').disabled = |
436 !((this.haveNeverCheckedForUpdates_ && status == 'updated') || | 436 !((this.haveNeverCheckedForUpdates_ && status == 'updated') || |
437 status == 'failed') || (eolStatus == 'device_endoflife'); | 437 status == 'failed') || |
| 438 (eolStatus == 'device_endoflife'); |
438 // If updates are disabled by policy, unhide the | 439 // If updates are disabled by policy, unhide the |
439 // controlled-feature-icon. | 440 // controlled-feature-icon. |
440 $('controlled-feature-icon').hidden = (status != 'disabled_by_admin'); | 441 $('controlled-feature-icon').hidden = (status != 'disabled_by_admin'); |
441 // If updates are no longer disabled by policy and the tooltip bubble | 442 // If updates are no longer disabled by policy and the tooltip bubble |
442 // is present, we hide it. | 443 // is present, we hide it. |
443 if (status != 'disabled_by_admin' && $('controlled-feature-bubble')) | 444 if (status != 'disabled_by_admin' && $('controlled-feature-bubble')) |
444 $('controlled-feature-bubble').hide(); | 445 $('controlled-feature-bubble').hide(); |
445 } | 446 } |
446 | 447 |
447 var container = $('update-status-container'); | 448 var container = $('update-status-container'); |
448 if (container) { | 449 if (container) { |
449 container.hidden = status == 'disabled'; | 450 container.hidden = status == 'disabled'; |
450 $('relaunch').hidden = | 451 $('relaunch').hidden = |
451 (status != 'nearly_updated') || !relaunchAndPowerwashHidden; | 452 (status != 'nearly_updated') || !relaunchAndPowerwashHidden; |
452 | 453 |
453 if (cr.isChromeOS) { | 454 if (cr.isChromeOS) { |
454 // Assume the "updated" status is stale if we haven't checked yet. | 455 // Assume the "updated" status is stale if we haven't checked yet. |
455 if (status == 'updated' && this.haveNeverCheckedForUpdates_ || | 456 if (status == 'updated' && this.haveNeverCheckedForUpdates_ || |
456 status == 'disabled_by_admin' || | 457 status == 'disabled_by_admin' || |
457 eolStatus == 'device_endoflife') { | 458 eolStatus == 'device_endoflife') { |
458 container.hidden = true; | 459 container.hidden = true; |
459 } | 460 } |
460 | 461 |
461 // Hide the request update button if auto-updating is disabled or | 462 // Hide the request update button if auto-updating is disabled or |
462 // a relaunch button is showing. | 463 // a relaunch button is showing. |
463 $('request-update').hidden = status == 'disabled' || | 464 $('request-update').hidden = status == 'disabled' || |
464 !$('relaunch').hidden || !relaunchAndPowerwashHidden; | 465 !$('relaunch').hidden || !relaunchAndPowerwashHidden; |
465 } | 466 } |
466 | 467 |
467 if (!cr.isMac) | 468 if (!cr.isMac) |
468 $('update-percentage').hidden = status != 'updating'; | 469 $('update-percentage').hidden = status != 'updating'; |
469 } | 470 } |
470 }, | 471 }, |
471 | 472 |
472 /** | 473 /** |
473 * @param {number} progress The percent completion. | 474 * @param {number} progress The percent completion. |
474 * @private | 475 * @private |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 assert(cr.isChromeOS); | 773 assert(cr.isChromeOS); |
773 HelpPage.getInstance().setRegulatoryLabelText_(text); | 774 HelpPage.getInstance().setRegulatoryLabelText_(text); |
774 }; | 775 }; |
775 | 776 |
776 HelpPage.updateEolMessage = function(eolStatus, eolMessage) { | 777 HelpPage.updateEolMessage = function(eolStatus, eolMessage) { |
777 assert(cr.isChromeOS); | 778 assert(cr.isChromeOS); |
778 HelpPage.getInstance().updateEolMessage_(eolStatus, eolMessage); | 779 HelpPage.getInstance().updateEolMessage_(eolStatus, eolMessage); |
779 }; | 780 }; |
780 | 781 |
781 // Export | 782 // Export |
782 return { | 783 return {HelpPage: HelpPage}; |
783 HelpPage: HelpPage | |
784 }; | |
785 }); | 784 }); |
OLD | NEW |