| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 */ | 56 */ |
| 57 function sendNativeMessage(event, opt_props) { | 57 function sendNativeMessage(event, opt_props) { |
| 58 var message = Object.assign({'event': event}, opt_props); | 58 var message = Object.assign({'event': event}, opt_props); |
| 59 port.postMessage(message); | 59 port.postMessage(message); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Class to handle checkbox corresponding to a preference. | 63 * Class to handle checkbox corresponding to a preference. |
| 64 */ | 64 */ |
| 65 class PreferenceCheckbox { | 65 class PreferenceCheckbox { |
| 66 | |
| 67 /** | 66 /** |
| 68 * Creates a Checkbox which handles the corresponding preference update. | 67 * Creates a Checkbox which handles the corresponding preference update. |
| 69 * @param {Element} container The container this checkbox corresponds to. | 68 * @param {Element} container The container this checkbox corresponds to. |
| 70 * The element must have <input type="checkbox" class="checkbox-option"> | 69 * The element must have <input type="checkbox" class="checkbox-option"> |
| 71 * for the checkbox itself, and <p class="checkbox-text"> for its label. | 70 * for the checkbox itself, and <p class="checkbox-text"> for its label. |
| 72 * @param {string} learnMoreContent I18n content which is shown when "Learn | 71 * @param {string} learnMoreContent I18n content which is shown when "Learn |
| 73 * More" link is clicked. | 72 * More" link is clicked. |
| 74 * @param {string?} learnMoreLinkId The ID for the "Learn More" link element. | 73 * @param {string?} learnMoreLinkId The ID for the "Learn More" link element. |
| 75 * TODO: Get rid of this. The element can have class so that it can be | 74 * TODO: Get rid of this. The element can have class so that it can be |
| 76 * identified easily. Also, it'd be better to extract the link element | 75 * identified easily. Also, it'd be better to extract the link element |
| (...skipping 23 matching lines...) Expand all Loading... |
| 100 } else { | 99 } else { |
| 101 this.policyIndicator_ = null; | 100 this.policyIndicator_ = null; |
| 102 } | 101 } |
| 103 } | 102 } |
| 104 | 103 |
| 105 /** | 104 /** |
| 106 * Returns if the checkbox is checked or not. Note that this *may* be | 105 * Returns if the checkbox is checked or not. Note that this *may* be |
| 107 * different from the preference value, because the user's check is | 106 * different from the preference value, because the user's check is |
| 108 * not propagated to the preference until the user clicks "AGREE" button. | 107 * not propagated to the preference until the user clicks "AGREE" button. |
| 109 */ | 108 */ |
| 110 isChecked() { return this.checkbox_.checked; } | 109 isChecked() { |
| 110 return this.checkbox_.checked; |
| 111 } |
| 111 | 112 |
| 112 /** | 113 /** |
| 113 * Called when the preference value in native code is updated. | 114 * Called when the preference value in native code is updated. |
| 114 */ | 115 */ |
| 115 onPreferenceChanged(isEnabled, isManaged) { | 116 onPreferenceChanged(isEnabled, isManaged) { |
| 116 this.checkbox_.checked = isEnabled; | 117 this.checkbox_.checked = isEnabled; |
| 117 this.checkbox_.disabled = isManaged; | 118 this.checkbox_.disabled = isManaged; |
| 118 this.label_.disabled = isManaged; | 119 this.label_.disabled = isManaged; |
| 119 | 120 |
| 120 if (this.policyIndicator_) { | 121 if (this.policyIndicator_) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 | 137 |
| 137 /** | 138 /** |
| 138 * Handles the checkbox action of metrics preference. | 139 * Handles the checkbox action of metrics preference. |
| 139 * This has special customization e.g. show/hide the checkbox based on | 140 * This has special customization e.g. show/hide the checkbox based on |
| 140 * the native preference. | 141 * the native preference. |
| 141 */ | 142 */ |
| 142 class MetricsPreferenceCheckbox extends PreferenceCheckbox { | 143 class MetricsPreferenceCheckbox extends PreferenceCheckbox { |
| 143 constructor( | 144 constructor( |
| 144 container, learnMoreContent, learnMoreLinkId, isOwner, | 145 container, learnMoreContent, learnMoreLinkId, isOwner, textDisabled, |
| 145 textDisabled, textEnabled, textManagedDisabled, textManagedEnabled) { | 146 textEnabled, textManagedDisabled, textManagedEnabled) { |
| 146 // Do not use policy indicator. | 147 // Do not use policy indicator. |
| 147 // Learn More link handling is done by this class. | 148 // Learn More link handling is done by this class. |
| 148 // So pass |null| intentionally. | 149 // So pass |null| intentionally. |
| 149 super(container, learnMoreContent, null, null); | 150 super(container, learnMoreContent, null, null); |
| 150 | 151 |
| 151 this.learnMoreLinkId_ = learnMoreLinkId; | 152 this.learnMoreLinkId_ = learnMoreLinkId; |
| 152 this.isOwner_ = isOwner; | 153 this.isOwner_ = isOwner; |
| 153 | 154 |
| 154 // Two dimensional array. First dimension is whether it is managed or not, | 155 // Two dimensional array. First dimension is whether it is managed or not, |
| 155 // the second one is whether it is enabled or not. | 156 // the second one is whether it is enabled or not. |
| 156 this.texts_ = [ | 157 this.texts_ = [ |
| 157 [textDisabled, textEnabled], | 158 [textDisabled, textEnabled], [textManagedDisabled, textManagedEnabled] |
| 158 [textManagedDisabled, textManagedEnabled] | |
| 159 ]; | 159 ]; |
| 160 } | 160 } |
| 161 | 161 |
| 162 onPreferenceChanged(isEnabled, isManaged) { | 162 onPreferenceChanged(isEnabled, isManaged) { |
| 163 isManaged = isManaged || !this.isOwner_; | 163 isManaged = isManaged || !this.isOwner_; |
| 164 super.onPreferenceChanged(isEnabled, isManaged); | 164 super.onPreferenceChanged(isEnabled, isManaged); |
| 165 | 165 |
| 166 // Hide the checkbox if it is not allowed to (re-)enable. | 166 // Hide the checkbox if it is not allowed to (re-)enable. |
| 167 var canEnable = !isEnabled && !isManaged; | 167 var canEnable = !isEnabled && !isManaged; |
| 168 this.checkbox_.hidden = !canEnable; | 168 this.checkbox_.hidden = !canEnable; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 LOADING: 1, | 200 LOADING: 1, |
| 201 ABORTED: 2, | 201 ABORTED: 2, |
| 202 LOADED: 3, | 202 LOADED: 3, |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 /** | 205 /** |
| 206 * Handles events for Terms-Of-Service page. Also this implements the async | 206 * Handles events for Terms-Of-Service page. Also this implements the async |
| 207 * loading of Terms-Of-Service content. | 207 * loading of Terms-Of-Service content. |
| 208 */ | 208 */ |
| 209 class TermsOfServicePage { | 209 class TermsOfServicePage { |
| 210 | |
| 211 /** | 210 /** |
| 212 * @param {Element} container The container of the page. | 211 * @param {Element} container The container of the page. |
| 213 * @param {boolean} isManaged Set true if ARC is managed. | 212 * @param {boolean} isManaged Set true if ARC is managed. |
| 214 * @param {string} countryCode The country code for the terms of service. | 213 * @param {string} countryCode The country code for the terms of service. |
| 215 * @param {MetricsPreferenceCheckbox} metricsCheckbox. The checkbox for the | 214 * @param {MetricsPreferenceCheckbox} metricsCheckbox. The checkbox for the |
| 216 * metrics preference. | 215 * metrics preference. |
| 217 * @param {PreferenceCheckbox} backupRestoreCheckbox The checkbox for the | 216 * @param {PreferenceCheckbox} backupRestoreCheckbox The checkbox for the |
| 218 * backup-restore preference. | 217 * backup-restore preference. |
| 219 * @param {PreferenceCheckbox} locationServiceCheckbox The checkbox for the | 218 * @param {PreferenceCheckbox} locationServiceCheckbox The checkbox for the |
| 220 * location service. | 219 * location service. |
| 221 */ | 220 */ |
| 222 constructor( | 221 constructor( |
| 223 container, isManaged, countryCode, | 222 container, isManaged, countryCode, metricsCheckbox, backupRestoreCheckbox, |
| 224 metricsCheckbox, backupRestoreCheckbox, locationServiceCheckbox) { | 223 locationServiceCheckbox) { |
| 225 this.loadingContainer_ = | 224 this.loadingContainer_ = |
| 226 container.querySelector('#terms-of-service-loading'); | 225 container.querySelector('#terms-of-service-loading'); |
| 227 this.contentContainer_ = | 226 this.contentContainer_ = |
| 228 container.querySelector('#terms-of-service-content'); | 227 container.querySelector('#terms-of-service-content'); |
| 229 | 228 |
| 230 this.metricsCheckbox_ = metricsCheckbox; | 229 this.metricsCheckbox_ = metricsCheckbox; |
| 231 this.backupRestoreCheckbox_ = backupRestoreCheckbox; | 230 this.backupRestoreCheckbox_ = backupRestoreCheckbox; |
| 232 this.locationServiceCheckbox_ = locationServiceCheckbox; | 231 this.locationServiceCheckbox_ = locationServiceCheckbox; |
| 233 | 232 |
| 234 this.isManaged_ = isManaged; | 233 this.isManaged_ = isManaged; |
| 235 | 234 |
| 236 // Set event listener for webview loading. | 235 // Set event listener for webview loading. |
| 237 this.termsView_ = container.querySelector('#terms-view'); | 236 this.termsView_ = container.querySelector('#terms-view'); |
| 238 this.termsView_.addEventListener( | 237 this.termsView_.addEventListener( |
| 239 'loadstart', () => this.onTermsViewLoadStarted_()); | 238 'loadstart', () => this.onTermsViewLoadStarted_()); |
| 240 this.termsView_.addEventListener( | 239 this.termsView_.addEventListener( |
| 241 'contentload', () => this.onTermsViewLoaded_()); | 240 'contentload', () => this.onTermsViewLoaded_()); |
| 242 this.termsView_.addEventListener( | 241 this.termsView_.addEventListener( |
| 243 'loadabort', (event) => this.onTermsViewLoadAborted_(event.reason)); | 242 'loadabort', (event) => this.onTermsViewLoadAborted_(event.reason)); |
| 244 | 243 |
| 245 var scriptSetCountryCode = | 244 var scriptSetCountryCode = |
| 246 'document.countryCode = \'' + countryCode.toLowerCase() + '\';'; | 245 'document.countryCode = \'' + countryCode.toLowerCase() + '\';'; |
| 247 this.termsView_.addContentScripts([ | 246 this.termsView_.addContentScripts([ |
| 248 { name: 'preProcess', | 247 { |
| 248 name: 'preProcess', |
| 249 matches: ['https://play.google.com/*'], | 249 matches: ['https://play.google.com/*'], |
| 250 js: { code: scriptSetCountryCode }, | 250 js: {code: scriptSetCountryCode}, |
| 251 run_at: 'document_start' | 251 run_at: 'document_start' |
| 252 }, | 252 }, |
| 253 { name: 'postProcess', | 253 { |
| 254 name: 'postProcess', |
| 254 matches: ['https://play.google.com/*'], | 255 matches: ['https://play.google.com/*'], |
| 255 css: { files: ['playstore.css'] }, | 256 css: {files: ['playstore.css']}, |
| 256 js: { files: ['playstore.js'] }, | 257 js: {files: ['playstore.js']}, |
| 257 run_at: 'document_end' | 258 run_at: 'document_end' |
| 258 }]); | 259 } |
| 260 ]); |
| 259 | 261 |
| 260 // webview is not allowed to open links in the new window. Hook these | 262 // webview is not allowed to open links in the new window. Hook these |
| 261 // events and open links in overlay dialog. | 263 // events and open links in overlay dialog. |
| 262 this.termsView_.addEventListener('newwindow', function(event) { | 264 this.termsView_.addEventListener('newwindow', function(event) { |
| 263 event.preventDefault(); | 265 event.preventDefault(); |
| 264 showURLOverlay(event.targetUrl); | 266 showURLOverlay(event.targetUrl); |
| 265 }); | 267 }); |
| 266 this.state_ = LoadState.UNLOADED; | 268 this.state_ = LoadState.UNLOADED; |
| 267 | 269 |
| 268 // On managed case, do not show TermsOfService section. Note that the | 270 // On managed case, do not show TermsOfService section. Note that the |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 */ | 408 */ |
| 407 function initialize(data, deviceId) { | 409 function initialize(data, deviceId) { |
| 408 currentDeviceId = deviceId; | 410 currentDeviceId = deviceId; |
| 409 var doc = appWindow.contentWindow.document; | 411 var doc = appWindow.contentWindow.document; |
| 410 var loadTimeData = appWindow.contentWindow.loadTimeData; | 412 var loadTimeData = appWindow.contentWindow.loadTimeData; |
| 411 loadTimeData.data = data; | 413 loadTimeData.data = data; |
| 412 appWindow.contentWindow.i18nTemplate.process(doc, loadTimeData); | 414 appWindow.contentWindow.i18nTemplate.process(doc, loadTimeData); |
| 413 | 415 |
| 414 // Initialize preference connected checkboxes in terms of service page. | 416 // Initialize preference connected checkboxes in terms of service page. |
| 415 termsPage = new TermsOfServicePage( | 417 termsPage = new TermsOfServicePage( |
| 416 doc.getElementById('terms'), | 418 doc.getElementById('terms'), data.arcManaged, data.countryCode, |
| 417 data.arcManaged, | |
| 418 data.countryCode, | |
| 419 new MetricsPreferenceCheckbox( | 419 new MetricsPreferenceCheckbox( |
| 420 doc.getElementById('metrics-preference'), | 420 doc.getElementById('metrics-preference'), data.learnMoreStatistics, |
| 421 data.learnMoreStatistics, | 421 '#learn-more-link-metrics', data.isOwnerProfile, |
| 422 '#learn-more-link-metrics', | 422 data.textMetricsDisabled, data.textMetricsEnabled, |
| 423 data.isOwnerProfile, | 423 data.textMetricsManagedDisabled, data.textMetricsManagedEnabled), |
| 424 data.textMetricsDisabled, | |
| 425 data.textMetricsEnabled, | |
| 426 data.textMetricsManagedDisabled, | |
| 427 data.textMetricsManagedEnabled), | |
| 428 new PreferenceCheckbox( | 424 new PreferenceCheckbox( |
| 429 doc.getElementById('backup-restore-preference'), | 425 doc.getElementById('backup-restore-preference'), |
| 430 data.learnMoreBackupAndRestore, | 426 data.learnMoreBackupAndRestore, '#learn-more-link-backup-restore', |
| 431 '#learn-more-link-backup-restore', | |
| 432 data.controlledByPolicy), | 427 data.controlledByPolicy), |
| 433 new PreferenceCheckbox( | 428 new PreferenceCheckbox( |
| 434 doc.getElementById('location-service-preference'), | 429 doc.getElementById('location-service-preference'), |
| 435 data.learnMoreLocationServices, | 430 data.learnMoreLocationServices, '#learn-more-link-location-service', |
| 436 '#learn-more-link-location-service', | |
| 437 data.controlledByPolicy)); | 431 data.controlledByPolicy)); |
| 438 } | 432 } |
| 439 | 433 |
| 440 /** | 434 /** |
| 441 * Handles native messages received from ArcSupportHost. | 435 * Handles native messages received from ArcSupportHost. |
| 442 * @param {!Object} message The message received. | 436 * @param {!Object} message The message received. |
| 443 */ | 437 */ |
| 444 function onNativeMessage(message) { | 438 function onNativeMessage(message) { |
| 445 if (!message.action) { | 439 if (!message.action) { |
| 446 return; | 440 return; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // change from users' point of view. | 495 // change from users' point of view. |
| 502 if (pageDivId != 'lso-loading' || doc.getElementById('arc-loading').hidden) { | 496 if (pageDivId != 'lso-loading' || doc.getElementById('arc-loading').hidden) { |
| 503 var pages = doc.getElementsByClassName('section'); | 497 var pages = doc.getElementsByClassName('section'); |
| 504 for (var i = 0; i < pages.length; i++) { | 498 for (var i = 0; i < pages.length; i++) { |
| 505 pages[i].hidden = pages[i].id != pageDivId; | 499 pages[i].hidden = pages[i].id != pageDivId; |
| 506 } | 500 } |
| 507 } | 501 } |
| 508 | 502 |
| 509 if (pageDivId == 'lso-loading') { | 503 if (pageDivId == 'lso-loading') { |
| 510 lsoView.src = 'https://accounts.google.com/o/oauth2/v2/auth?client_id=' + | 504 lsoView.src = 'https://accounts.google.com/o/oauth2/v2/auth?client_id=' + |
| 511 '1070009224336-sdh77n7uot3oc99ais00jmuft6sk2fg9.apps.' + | 505 '1070009224336-sdh77n7uot3oc99ais00jmuft6sk2fg9.apps.' + |
| 512 'googleusercontent.com&response_type=code&redirect_uri=oob&' + | 506 'googleusercontent.com&response_type=code&redirect_uri=oob&' + |
| 513 'scope=https://www.google.com/accounts/OAuthLogin&' + | 507 'scope=https://www.google.com/accounts/OAuthLogin&' + |
| 514 'device_type=arc_plus_plus&device_id=' + currentDeviceId + | 508 'device_type=arc_plus_plus&device_id=' + currentDeviceId + |
| 515 '&hl=' + navigator.language; | 509 '&hl=' + navigator.language; |
| 516 } | 510 } |
| 517 appWindow.show(); | 511 appWindow.show(); |
| 518 if (pageDivId == 'terms') { | 512 if (pageDivId == 'terms') { |
| 519 termsPage.onShow(); | 513 termsPage.onShow(); |
| 520 } | 514 } |
| 521 } | 515 } |
| 522 | 516 |
| 523 /** | 517 /** |
| 524 * Shows an error page, with given errorMessage. | 518 * Shows an error page, with given errorMessage. |
| 525 * | 519 * |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 lastFocusedElement.focus(); | 605 lastFocusedElement.focus(); |
| 612 lastFocusedElement = null; | 606 lastFocusedElement = null; |
| 613 } | 607 } |
| 614 } | 608 } |
| 615 | 609 |
| 616 function setWindowBounds() { | 610 function setWindowBounds() { |
| 617 if (!appWindow) { | 611 if (!appWindow) { |
| 618 return; | 612 return; |
| 619 } | 613 } |
| 620 | 614 |
| 621 var decorationWidth = appWindow.outerBounds.width - | 615 var decorationWidth = |
| 622 appWindow.innerBounds.width; | 616 appWindow.outerBounds.width - appWindow.innerBounds.width; |
| 623 var decorationHeight = appWindow.outerBounds.height - | 617 var decorationHeight = |
| 624 appWindow.innerBounds.height; | 618 appWindow.outerBounds.height - appWindow.innerBounds.height; |
| 625 | 619 |
| 626 var outerWidth = INNER_WIDTH + decorationWidth; | 620 var outerWidth = INNER_WIDTH + decorationWidth; |
| 627 var outerHeight = INNER_HEIGHT + decorationHeight; | 621 var outerHeight = INNER_HEIGHT + decorationHeight; |
| 628 if (outerWidth > screen.availWidth) { | 622 if (outerWidth > screen.availWidth) { |
| 629 outerWidth = screen.availWidth; | 623 outerWidth = screen.availWidth; |
| 630 } | 624 } |
| 631 if (outerHeight > screen.availHeight) { | 625 if (outerHeight > screen.availHeight) { |
| 632 outerHeight = screen.availHeight; | 626 outerHeight = screen.availHeight; |
| 633 } | 627 } |
| 634 if (appWindow.outerBounds.width == outerWidth && | 628 if (appWindow.outerBounds.width == outerWidth && |
| 635 appWindow.outerBounds.height == outerHeight) { | 629 appWindow.outerBounds.height == outerHeight) { |
| 636 return; | 630 return; |
| 637 } | 631 } |
| 638 | 632 |
| 639 appWindow.outerBounds.width = outerWidth; | 633 appWindow.outerBounds.width = outerWidth; |
| 640 appWindow.outerBounds.height = outerHeight; | 634 appWindow.outerBounds.height = outerHeight; |
| 641 appWindow.outerBounds.left = Math.ceil((screen.availWidth - outerWidth) / 2); | 635 appWindow.outerBounds.left = Math.ceil((screen.availWidth - outerWidth) / 2); |
| 642 appWindow.outerBounds.top = | 636 appWindow.outerBounds.top = Math.ceil((screen.availHeight - outerHeight) / 2); |
| 643 Math.ceil((screen.availHeight - outerHeight) / 2); | |
| 644 } | 637 } |
| 645 | 638 |
| 646 chrome.app.runtime.onLaunched.addListener(function() { | 639 chrome.app.runtime.onLaunched.addListener(function() { |
| 647 var onAppContentLoad = function() { | 640 var onAppContentLoad = function() { |
| 648 var doc = appWindow.contentWindow.document; | 641 var doc = appWindow.contentWindow.document; |
| 649 lsoView = doc.getElementById('arc-support'); | 642 lsoView = doc.getElementById('arc-support'); |
| 650 lsoView.addContentScripts([ | 643 lsoView.addContentScripts([{ |
| 651 { name: 'postProcess', | 644 name: 'postProcess', |
| 652 matches: ['https://accounts.google.com/*'], | 645 matches: ['https://accounts.google.com/*'], |
| 653 css: { files: ['lso.css'] }, | 646 css: {files: ['lso.css']}, |
| 654 run_at: 'document_end' | 647 run_at: 'document_end' |
| 655 }]); | 648 }]); |
| 656 | 649 |
| 657 var isApprovalResponse = function(url) { | 650 var isApprovalResponse = function(url) { |
| 658 var resultUrlPrefix = 'https://accounts.google.com/o/oauth2/approval?'; | 651 var resultUrlPrefix = 'https://accounts.google.com/o/oauth2/approval?'; |
| 659 return url.substring(0, resultUrlPrefix.length) == resultUrlPrefix; | 652 return url.substring(0, resultUrlPrefix.length) == resultUrlPrefix; |
| 660 }; | 653 }; |
| 661 | 654 |
| 662 var lsoError = false; | 655 var lsoError = false; |
| 663 var onLsoViewRequestResponseStarted = function(details) { | 656 var onLsoViewRequestResponseStarted = function(details) { |
| 664 if (isApprovalResponse(details.url)) { | 657 if (isApprovalResponse(details.url)) { |
| 665 showPage('arc-loading'); | 658 showPage('arc-loading'); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 689 } | 682 } |
| 690 | 683 |
| 691 lsoView.executeScript({code: 'document.title;'}, function(results) { | 684 lsoView.executeScript({code: 'document.title;'}, function(results) { |
| 692 var authCodePrefix = 'Success code='; | 685 var authCodePrefix = 'Success code='; |
| 693 if (results && results.length == 1 && typeof results[0] == 'string' && | 686 if (results && results.length == 1 && typeof results[0] == 'string' && |
| 694 results[0].substring(0, authCodePrefix.length) == authCodePrefix) { | 687 results[0].substring(0, authCodePrefix.length) == authCodePrefix) { |
| 695 var authCode = results[0].substring(authCodePrefix.length); | 688 var authCode = results[0].substring(authCodePrefix.length); |
| 696 sendNativeMessage('onAuthSucceeded', {code: authCode}); | 689 sendNativeMessage('onAuthSucceeded', {code: authCode}); |
| 697 } else { | 690 } else { |
| 698 sendNativeMessage('onAuthFailed'); | 691 sendNativeMessage('onAuthFailed'); |
| 699 showErrorPage( | 692 showErrorPage(appWindow.contentWindow.loadTimeData.getString( |
| 700 appWindow.contentWindow.loadTimeData.getString( | 693 'authorizationFailed')); |
| 701 'authorizationFailed')); | |
| 702 } | 694 } |
| 703 }); | 695 }); |
| 704 }; | 696 }; |
| 705 | 697 |
| 706 var requestFilter = { | 698 var requestFilter = {urls: ['<all_urls>'], types: ['main_frame']}; |
| 707 urls: ['<all_urls>'], | |
| 708 types: ['main_frame'] | |
| 709 }; | |
| 710 | 699 |
| 711 lsoView.request.onResponseStarted.addListener( | 700 lsoView.request.onResponseStarted.addListener( |
| 712 onLsoViewRequestResponseStarted, requestFilter); | 701 onLsoViewRequestResponseStarted, requestFilter); |
| 713 lsoView.request.onErrorOccurred.addListener( | 702 lsoView.request.onErrorOccurred.addListener( |
| 714 onLsoViewErrorOccurred, requestFilter); | 703 onLsoViewErrorOccurred, requestFilter); |
| 715 lsoView.addEventListener('contentload', onLsoViewContentLoad); | 704 lsoView.addEventListener('contentload', onLsoViewContentLoad); |
| 716 | 705 |
| 717 var onRetry = function() { | 706 var onRetry = function() { |
| 718 sendNativeMessage('onRetryClicked'); | 707 sendNativeMessage('onRetryClicked'); |
| 719 }; | 708 }; |
| 720 | 709 |
| 721 var onSendFeedback = function() { | 710 var onSendFeedback = function() { |
| 722 sendNativeMessage('onSendFeedbackClicked'); | 711 sendNativeMessage('onSendFeedbackClicked'); |
| 723 }; | 712 }; |
| 724 | 713 |
| 725 doc.getElementById('button-retry').addEventListener('click', onRetry); | 714 doc.getElementById('button-retry').addEventListener('click', onRetry); |
| 726 doc.getElementById('button-send-feedback') | 715 doc.getElementById('button-send-feedback') |
| 727 .addEventListener('click', onSendFeedback); | 716 .addEventListener('click', onSendFeedback); |
| 728 doc.getElementById('overlay-close').addEventListener('click', hideOverlay); | 717 doc.getElementById('overlay-close').addEventListener('click', hideOverlay); |
| 729 doc.getElementById('privacy-policy-link').addEventListener( | 718 doc.getElementById('privacy-policy-link') |
| 730 'click', showPrivacyPolicyOverlay); | 719 .addEventListener('click', showPrivacyPolicyOverlay); |
| 731 | 720 |
| 732 var overlay = doc.getElementById('overlay-container'); | 721 var overlay = doc.getElementById('overlay-container'); |
| 733 appWindow.contentWindow.cr.ui.overlay.setupOverlay(overlay); | 722 appWindow.contentWindow.cr.ui.overlay.setupOverlay(overlay); |
| 734 appWindow.contentWindow.cr.ui.overlay.globalInitialization(); | 723 appWindow.contentWindow.cr.ui.overlay.globalInitialization(); |
| 735 overlay.addEventListener('cancelOverlay', hideOverlay); | 724 overlay.addEventListener('cancelOverlay', hideOverlay); |
| 736 | 725 |
| 737 connectPort(); | 726 connectPort(); |
| 738 }; | 727 }; |
| 739 | 728 |
| 740 var onWindowCreated = function(createdWindow) { | 729 var onWindowCreated = function(createdWindow) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 755 // otherwise the background page would be kept alive so that the extension | 744 // otherwise the background page would be kept alive so that the extension |
| 756 // would not be unloaded. | 745 // would not be unloaded. |
| 757 port.disconnect(); | 746 port.disconnect(); |
| 758 port = null; | 747 port = null; |
| 759 }; | 748 }; |
| 760 | 749 |
| 761 var options = { | 750 var options = { |
| 762 'id': 'play_store_wnd', | 751 'id': 'play_store_wnd', |
| 763 'resizable': false, | 752 'resizable': false, |
| 764 'hidden': true, | 753 'hidden': true, |
| 765 'frame': { | 754 'frame': {type: 'chrome', color: '#ffffff'}, |
| 766 type: 'chrome', | 755 'innerBounds': {'width': INNER_WIDTH, 'height': INNER_HEIGHT} |
| 767 color: '#ffffff' | |
| 768 }, | |
| 769 'innerBounds': { | |
| 770 'width': INNER_WIDTH, | |
| 771 'height': INNER_HEIGHT | |
| 772 } | |
| 773 }; | 756 }; |
| 774 chrome.app.window.create('main.html', options, onWindowCreated); | 757 chrome.app.window.create('main.html', options, onWindowCreated); |
| 775 }); | 758 }); |
| OLD | NEW |