| 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 * Chrome window that hosts UI. Only one window is allowed. | 6 * Chrome window that hosts UI. Only one window is allowed. |
| 7 * @type {chrome.app.window.AppWindow} | 7 * @type {chrome.app.window.AppWindow} |
| 8 */ | 8 */ |
| 9 var appWindow = null; | 9 var appWindow = null; |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 */ | 23 */ |
| 24 var port = null; | 24 var port = null; |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Stores current device id. | 27 * Stores current device id. |
| 28 * @type {string} | 28 * @type {string} |
| 29 */ | 29 */ |
| 30 var currentDeviceId = null; | 30 var currentDeviceId = null; |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Indicates that terms were accepted by user. | |
| 34 * @type {boolean} | |
| 35 * TODO: This should be a part of TermsOfServicePage. | |
| 36 */ | |
| 37 var termsAccepted = false; | |
| 38 | |
| 39 /** | |
| 40 * Host window inner default width. | 33 * Host window inner default width. |
| 41 * @const {number} | 34 * @const {number} |
| 42 */ | 35 */ |
| 43 var INNER_WIDTH = 960; | 36 var INNER_WIDTH = 960; |
| 44 | 37 |
| 45 /** | 38 /** |
| 46 * Host window inner default height. | 39 * Host window inner default height. |
| 47 * @const {number} | 40 * @const {number} |
| 48 */ | 41 */ |
| 49 var INNER_HEIGHT = 688; | 42 var INNER_HEIGHT = 688; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 266 |
| 274 // Set event handler for buttons. | 267 // Set event handler for buttons. |
| 275 container.querySelector('#button-agree') | 268 container.querySelector('#button-agree') |
| 276 .addEventListener('click', () => this.onAgree()); | 269 .addEventListener('click', () => this.onAgree()); |
| 277 container.querySelector('#button-cancel') | 270 container.querySelector('#button-cancel') |
| 278 .addEventListener('click', () => this.onCancel_()); | 271 .addEventListener('click', () => this.onCancel_()); |
| 279 } | 272 } |
| 280 | 273 |
| 281 /** Called when the TermsOfService page is shown. */ | 274 /** Called when the TermsOfService page is shown. */ |
| 282 onShow() { | 275 onShow() { |
| 283 termsAccepted = false; | |
| 284 | |
| 285 if (this.isManaged_ || this.state_ == LoadState.LOADED) { | 276 if (this.isManaged_ || this.state_ == LoadState.LOADED) { |
| 286 // Note: in managed case, because it does not show the contents of terms | 277 // Note: in managed case, because it does not show the contents of terms |
| 287 // of service, it is ok to show the content container immediately. | 278 // of service, it is ok to show the content container immediately. |
| 288 this.showContent_(); | 279 this.showContent_(); |
| 289 } else { | 280 } else { |
| 290 this.startTermsViewLoading_(); | 281 this.startTermsViewLoading_(); |
| 291 } | 282 } |
| 292 } | 283 } |
| 293 | 284 |
| 294 /** Shows the loaded terms-of-service content. */ | 285 /** Shows the loaded terms-of-service content. */ |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 onTermsViewLoadAborted_(reason) { | 351 onTermsViewLoadAborted_(reason) { |
| 361 console.error('TermsView loading is aborted: ' + reason); | 352 console.error('TermsView loading is aborted: ' + reason); |
| 362 // Mark ABORTED so that onTermsViewLoaded_() won't show the content view. | 353 // Mark ABORTED so that onTermsViewLoaded_() won't show the content view. |
| 363 this.state_ = LoadState.ABORTED; | 354 this.state_ = LoadState.ABORTED; |
| 364 showErrorPage( | 355 showErrorPage( |
| 365 appWindow.contentWindow.loadTimeData.getString('serverError')); | 356 appWindow.contentWindow.loadTimeData.getString('serverError')); |
| 366 } | 357 } |
| 367 | 358 |
| 368 /** Called when "AGREE" button is clicked. */ | 359 /** Called when "AGREE" button is clicked. */ |
| 369 onAgree() { | 360 onAgree() { |
| 370 termsAccepted = true; | |
| 371 | |
| 372 sendNativeMessage('onAgreed', { | 361 sendNativeMessage('onAgreed', { |
| 373 isMetricsEnabled: this.metricsCheckbox_.isChecked(), | 362 isMetricsEnabled: this.metricsCheckbox_.isChecked(), |
| 374 isBackupRestoreEnabled: this.backupRestoreCheckbox_.isChecked(), | 363 isBackupRestoreEnabled: this.backupRestoreCheckbox_.isChecked(), |
| 375 isLocationServiceEnabled: this.locationServiceCheckbox_.isChecked() | 364 isLocationServiceEnabled: this.locationServiceCheckbox_.isChecked() |
| 376 }); | 365 }); |
| 377 } | 366 } |
| 378 | 367 |
| 379 /** Called when "CANCEL" button is clicked. */ | 368 /** Called when "CANCEL" button is clicked. */ |
| 380 onCancel_() { | 369 onCancel_() { |
| 381 if (appWindow) { | 370 if (appWindow) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 termsPage.onBackupRestorePreferenceChanged( | 451 termsPage.onBackupRestorePreferenceChanged( |
| 463 message.enabled, message.managed); | 452 message.enabled, message.managed); |
| 464 } else if (message.action == 'setLocationServiceMode') { | 453 } else if (message.action == 'setLocationServiceMode') { |
| 465 termsPage.onLocationServicePreferenceChanged( | 454 termsPage.onLocationServicePreferenceChanged( |
| 466 message.enabled, message.managed); | 455 message.enabled, message.managed); |
| 467 } else if (message.action == 'closeWindow') { | 456 } else if (message.action == 'closeWindow') { |
| 468 if (appWindow) { | 457 if (appWindow) { |
| 469 appWindow.close(); | 458 appWindow.close(); |
| 470 } | 459 } |
| 471 } else if (message.action == 'showPage') { | 460 } else if (message.action == 'showPage') { |
| 472 if (message.page != 'terms') { | |
| 473 // Explicit request to start not from start page. Assume terms are | |
| 474 // accepted in this case. | |
| 475 // TODO: this is only for controling "RETRY" button. Remove this. | |
| 476 termsAccepted = true; | |
| 477 } | |
| 478 showPage(message.page); | 461 showPage(message.page); |
| 479 } else if (message.action == 'showErrorPage') { | 462 } else if (message.action == 'showErrorPage') { |
| 480 // TODO: this is only for controling "RETRY" button. Remove this. | |
| 481 termsAccepted = true; | |
| 482 showErrorPage(message.errorMessage, message.shouldShowSendFeedback); | 463 showErrorPage(message.errorMessage, message.shouldShowSendFeedback); |
| 483 } else if (message.action == 'setWindowBounds') { | 464 } else if (message.action == 'setWindowBounds') { |
| 484 setWindowBounds(); | 465 setWindowBounds(); |
| 485 } | 466 } |
| 486 } | 467 } |
| 487 | 468 |
| 488 /** | 469 /** |
| 489 * Connects to ArcSupportHost. | 470 * Connects to ArcSupportHost. |
| 490 */ | 471 */ |
| 491 function connectPort() { | 472 function connectPort() { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 types: ['main_frame'] | 680 types: ['main_frame'] |
| 700 }; | 681 }; |
| 701 | 682 |
| 702 lsoView.request.onResponseStarted.addListener( | 683 lsoView.request.onResponseStarted.addListener( |
| 703 onLsoViewRequestResponseStarted, requestFilter); | 684 onLsoViewRequestResponseStarted, requestFilter); |
| 704 lsoView.request.onErrorOccurred.addListener( | 685 lsoView.request.onErrorOccurred.addListener( |
| 705 onLsoViewErrorOccurred, requestFilter); | 686 onLsoViewErrorOccurred, requestFilter); |
| 706 lsoView.addEventListener('contentload', onLsoViewContentLoad); | 687 lsoView.addEventListener('contentload', onLsoViewContentLoad); |
| 707 | 688 |
| 708 var onRetry = function() { | 689 var onRetry = function() { |
| 709 if (termsAccepted) { | 690 sendNativeMessage('onRetryClicked'); |
| 710 // Reuse the onAgree() in case that the user has already accepted | |
| 711 // the ToS. | |
| 712 termsPage.onAgree(); | |
| 713 } else { | |
| 714 // Here 'error' page should be visible. So switch to 'terms' page | |
| 715 // to show the progress page, which triggers reloading. | |
| 716 showPage('terms'); | |
| 717 } | |
| 718 }; | 691 }; |
| 719 | 692 |
| 720 var onSendFeedback = function() { | 693 var onSendFeedback = function() { |
| 721 sendNativeMessage('onSendFeedbackClicked'); | 694 sendNativeMessage('onSendFeedbackClicked'); |
| 722 }; | 695 }; |
| 723 | 696 |
| 724 doc.getElementById('button-retry').addEventListener('click', onRetry); | 697 doc.getElementById('button-retry').addEventListener('click', onRetry); |
| 725 doc.getElementById('button-send-feedback') | 698 doc.getElementById('button-send-feedback') |
| 726 .addEventListener('click', onSendFeedback); | 699 .addEventListener('click', onSendFeedback); |
| 727 doc.getElementById('overlay-close').addEventListener('click', hideOverlay); | 700 doc.getElementById('overlay-close').addEventListener('click', hideOverlay); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 type: 'chrome', | 738 type: 'chrome', |
| 766 color: '#ffffff' | 739 color: '#ffffff' |
| 767 }, | 740 }, |
| 768 'innerBounds': { | 741 'innerBounds': { |
| 769 'width': INNER_WIDTH, | 742 'width': INNER_WIDTH, |
| 770 'height': INNER_HEIGHT | 743 'height': INNER_HEIGHT |
| 771 } | 744 } |
| 772 }; | 745 }; |
| 773 chrome.app.window.create('main.html', options, onWindowCreated); | 746 chrome.app.window.create('main.html', options, onWindowCreated); |
| 774 }); | 747 }); |
| OLD | NEW |