| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Javascript for local_discovery.html, served from chrome://devices/ | 6 * Javascript for local_discovery.html, served from chrome://devices/ |
| 7 * This is used to show discoverable devices near the user as well as | 7 * This is used to show discoverable devices near the user as well as |
| 8 * cloud devices registered to them. | 8 * cloud devices registered to them. |
| 9 * | 9 * |
| 10 * The object defined in this javascript file listens for callbacks from the | 10 * The object defined in this javascript file listens for callbacks from the |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 */ | 96 */ |
| 97 renderDevice: function() { | 97 renderDevice: function() { |
| 98 if (this.domElement) { | 98 if (this.domElement) { |
| 99 clearElement(this.domElement); | 99 clearElement(this.domElement); |
| 100 } else { | 100 } else { |
| 101 this.domElement = document.createElement('div'); | 101 this.domElement = document.createElement('div'); |
| 102 this.deviceContainer().appendChild(this.domElement); | 102 this.deviceContainer().appendChild(this.domElement); |
| 103 } | 103 } |
| 104 | 104 |
| 105 this.registerButton = fillDeviceDescription( | 105 this.registerButton = fillDeviceDescription( |
| 106 this.domElement, | 106 this.domElement, this.info.display_name, this.info.description, |
| 107 this.info.display_name, | 107 this.info.type, loadTimeData.getString('serviceRegister'), |
| 108 this.info.description, | 108 this.showRegister.bind(this, this.info.type)); |
| 109 this.info.type, | |
| 110 loadTimeData.getString('serviceRegister'), | |
| 111 this.showRegister.bind(this, this.info.type)); | |
| 112 | 109 |
| 113 this.setRegisterEnabled(this.registerEnabled); | 110 this.setRegisterEnabled(this.registerEnabled); |
| 114 }, | 111 }, |
| 115 | 112 |
| 116 /** | 113 /** |
| 117 * Return the correct container for the device. | 114 * Return the correct container for the device. |
| 118 * @param {boolean} is_mine Whether or not the device is in the 'Registered' | 115 * @param {boolean} is_mine Whether or not the device is in the 'Registered' |
| 119 * section. | 116 * section. |
| 120 */ | 117 */ |
| 121 deviceContainer: function() { | 118 deviceContainer: function() { |
| 122 return $('register-device-list'); | 119 return $('register-device-list'); |
| 123 }, | 120 }, |
| 124 /** | 121 /** |
| 125 * Register the device. | 122 * Register the device. |
| 126 */ | 123 */ |
| 127 register: function() { | 124 register: function() { |
| 128 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CONFIRMED); | 125 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CONFIRMED); |
| 129 chrome.send('registerDevice', [this.info.service_name]); | 126 chrome.send('registerDevice', [this.info.service_name]); |
| 130 setRegisterPage(isPrinter(this.info.type) ? | 127 setRegisterPage( |
| 131 'register-printer-page-adding1' : 'register-device-page-adding1'); | 128 isPrinter(this.info.type) ? 'register-printer-page-adding1' : |
| 129 'register-device-page-adding1'); |
| 132 }, | 130 }, |
| 133 /** | 131 /** |
| 134 * Show registrtation UI for device. | 132 * Show registrtation UI for device. |
| 135 */ | 133 */ |
| 136 showRegister: function() { | 134 showRegister: function() { |
| 137 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CLICKED); | 135 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CLICKED); |
| 138 $('register-message').textContent = loadTimeData.getStringF( | 136 $('register-message').textContent = loadTimeData.getStringF( |
| 139 isPrinter(this.info.type) ? 'registerPrinterConfirmMessage' : | 137 isPrinter(this.info.type) ? 'registerPrinterConfirmMessage' : |
| 140 'registerDeviceConfirmMessage', | 138 'registerDeviceConfirmMessage', |
| 141 this.info.display_name); | 139 this.info.display_name); |
| 142 $('register-continue-button').onclick = this.register.bind(this); | 140 $('register-continue-button').onclick = this.register.bind(this); |
| 143 showRegisterOverlay(); | 141 showRegisterOverlay(); |
| 144 }, | 142 }, |
| 145 /** | 143 /** |
| 146 * Set registration button enabled/disabled | 144 * Set registration button enabled/disabled |
| 147 */ | 145 */ |
| 148 setRegisterEnabled: function(isEnabled) { | 146 setRegisterEnabled: function(isEnabled) { |
| 149 this.registerEnabled = isEnabled; | 147 this.registerEnabled = isEnabled; |
| 150 if (this.registerButton) { | 148 if (this.registerButton) { |
| 151 this.registerButton.disabled = !isEnabled; | 149 this.registerButton.disabled = !isEnabled; |
| 152 } | 150 } |
| 153 } | 151 } |
| 154 }; | 152 }; |
| 155 | 153 |
| 156 /** | 154 /** |
| 157 * Manages focus for local devices page. | 155 * Manages focus for local devices page. |
| 158 * @constructor | 156 * @constructor |
| 159 * @extends {cr.ui.FocusManager} | 157 * @extends {cr.ui.FocusManager} |
| 160 */ | 158 */ |
| 161 function LocalDiscoveryFocusManager() { | 159 function LocalDiscoveryFocusManager() { |
| 162 cr.ui.FocusManager.call(this); | 160 cr.ui.FocusManager.call(this); |
| 163 this.focusParent_ = document.body; | 161 this.focusParent_ = document.body; |
| 164 } | 162 } |
| 165 | 163 |
| 166 LocalDiscoveryFocusManager.prototype = { | 164 LocalDiscoveryFocusManager.prototype = { |
| 167 __proto__: cr.ui.FocusManager.prototype, | 165 __proto__: cr.ui.FocusManager.prototype, |
| 168 /** @override */ | 166 /** @override */ |
| 169 getFocusParent: function() { | 167 getFocusParent: function() { |
| 170 return document.querySelector('#overlay .showing') || | 168 return document.querySelector('#overlay .showing') || $('main-page'); |
| 171 $('main-page'); | |
| 172 } | 169 } |
| 173 }; | 170 }; |
| 174 | 171 |
| 175 /** | 172 /** |
| 176 * Returns a textual representation of the number of printers on the network. | 173 * Returns a textual representation of the number of printers on the network. |
| 177 * @return {string} Number of printers on the network as localized string. | 174 * @return {string} Number of printers on the network as localized string. |
| 178 */ | 175 */ |
| 179 function generateNumberPrintersAvailableText(numberPrinters) { | 176 function generateNumberPrintersAvailableText(numberPrinters) { |
| 180 if (numberPrinters == 0) { | 177 if (numberPrinters == 0) { |
| 181 return loadTimeData.getString('printersOnNetworkZero'); | 178 return loadTimeData.getString('printersOnNetworkZero'); |
| 182 } else if (numberPrinters == 1) { | 179 } else if (numberPrinters == 1) { |
| 183 return loadTimeData.getString('printersOnNetworkOne'); | 180 return loadTimeData.getString('printersOnNetworkOne'); |
| 184 } else { | 181 } else { |
| 185 return loadTimeData.getStringF('printersOnNetworkMultiple', | 182 return loadTimeData.getStringF( |
| 186 numberPrinters); | 183 'printersOnNetworkMultiple', numberPrinters); |
| 187 } | 184 } |
| 188 } | 185 } |
| 189 | 186 |
| 190 /** | 187 /** |
| 191 * Fill device element with the description of a device. | 188 * Fill device element with the description of a device. |
| 192 * @param {HTMLElement} device_dom_element Element to be filled. | 189 * @param {HTMLElement} device_dom_element Element to be filled. |
| 193 * @param {string} name Name of device. | 190 * @param {string} name Name of device. |
| 194 * @param {string} description Description of device. | 191 * @param {string} description Description of device. |
| 195 * @param {string} type Type of device. | 192 * @param {string} type Type of device. |
| 196 * @param {string} button_text Text to appear on button. | 193 * @param {string} button_text Text to appear on button. |
| 197 * @param {function()?} button_action Action for button. | 194 * @param {function()?} button_action Action for button. |
| 198 * @return {HTMLElement} The button (for enabling/disabling/rebinding) | 195 * @return {HTMLElement} The button (for enabling/disabling/rebinding) |
| 199 */ | 196 */ |
| 200 function fillDeviceDescription(device_dom_element, | 197 function fillDeviceDescription( |
| 201 name, | 198 device_dom_element, name, description, type, button_text, button_action) { |
| 202 description, | |
| 203 type, | |
| 204 button_text, | |
| 205 button_action) { | |
| 206 device_dom_element.classList.add('device'); | 199 device_dom_element.classList.add('device'); |
| 207 if (isPrinter(type)) | 200 if (isPrinter(type)) |
| 208 device_dom_element.classList.add('printer'); | 201 device_dom_element.classList.add('printer'); |
| 209 | 202 |
| 210 var deviceInfo = document.createElement('div'); | 203 var deviceInfo = document.createElement('div'); |
| 211 deviceInfo.className = 'device-info'; | 204 deviceInfo.className = 'device-info'; |
| 212 device_dom_element.appendChild(deviceInfo); | 205 device_dom_element.appendChild(deviceInfo); |
| 213 | 206 |
| 214 var deviceName = document.createElement('h3'); | 207 var deviceName = document.createElement('h3'); |
| 215 deviceName.className = 'device-name'; | 208 deviceName.className = 'device-name'; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 while (element.firstChild) { | 254 while (element.firstChild) { |
| 262 element.removeChild(element.firstChild); | 255 element.removeChild(element.firstChild); |
| 263 } | 256 } |
| 264 } | 257 } |
| 265 | 258 |
| 266 /** | 259 /** |
| 267 * Announce that a registration failed. | 260 * Announce that a registration failed. |
| 268 */ | 261 */ |
| 269 function onRegistrationFailed() { | 262 function onRegistrationFailed() { |
| 270 $('error-message').textContent = | 263 $('error-message').textContent = |
| 271 loadTimeData.getString('addingErrorMessage'); | 264 loadTimeData.getString('addingErrorMessage'); |
| 272 setRegisterPage('register-page-error'); | 265 setRegisterPage('register-page-error'); |
| 273 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_FAILURE); | 266 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_FAILURE); |
| 274 } | 267 } |
| 275 | 268 |
| 276 /** | 269 /** |
| 277 * Announce that a registration has been canceled on the printer. | 270 * Announce that a registration has been canceled on the printer. |
| 278 */ | 271 */ |
| 279 function onRegistrationCanceledPrinter() { | 272 function onRegistrationCanceledPrinter() { |
| 280 $('error-message').textContent = | 273 $('error-message').textContent = |
| 281 loadTimeData.getString('addingCanceledMessage'); | 274 loadTimeData.getString('addingCanceledMessage'); |
| 282 setRegisterPage('register-page-error'); | 275 setRegisterPage('register-page-error'); |
| 283 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CANCEL_ON_PRINTER); | 276 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CANCEL_ON_PRINTER); |
| 284 } | 277 } |
| 285 | 278 |
| 286 /** | 279 /** |
| 287 * Announce that a registration has timed out. | 280 * Announce that a registration has timed out. |
| 288 */ | 281 */ |
| 289 function onRegistrationTimeout() { | 282 function onRegistrationTimeout() { |
| 290 $('error-message').textContent = | 283 $('error-message').textContent = |
| 291 loadTimeData.getString('addingTimeoutMessage'); | 284 loadTimeData.getString('addingTimeoutMessage'); |
| 292 setRegisterPage('register-page-error'); | 285 setRegisterPage('register-page-error'); |
| 293 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_TIMEOUT); | 286 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_TIMEOUT); |
| 294 } | 287 } |
| 295 | 288 |
| 296 /** | 289 /** |
| 297 * Update UI to reflect that registration has been confirmed on the printer. | 290 * Update UI to reflect that registration has been confirmed on the printer. |
| 298 */ | 291 */ |
| 299 function onRegistrationConfirmedOnPrinter() { | 292 function onRegistrationConfirmedOnPrinter() { |
| 300 setRegisterPage('register-printer-page-adding2'); | 293 setRegisterPage('register-printer-page-adding2'); |
| 301 } | 294 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 var description; | 342 var description; |
| 350 if (device.description == '') { | 343 if (device.description == '') { |
| 351 if (isPrinter(device.type)) | 344 if (isPrinter(device.type)) |
| 352 description = loadTimeData.getString('noDescriptionPrinter'); | 345 description = loadTimeData.getString('noDescriptionPrinter'); |
| 353 else | 346 else |
| 354 description = loadTimeData.getString('noDescriptionDevice'); | 347 description = loadTimeData.getString('noDescriptionDevice'); |
| 355 } else { | 348 } else { |
| 356 description = device.description; | 349 description = device.description; |
| 357 } | 350 } |
| 358 | 351 |
| 359 fillDeviceDescription(devicesDomElement, device.display_name, | 352 fillDeviceDescription( |
| 360 description, device.type, | 353 devicesDomElement, device.display_name, description, device.type, |
| 361 loadTimeData.getString('manageDevice'), | 354 loadTimeData.getString('manageDevice'), |
| 362 isPrinter(device.type) ? | 355 isPrinter(device.type) ? manageCloudDevice.bind(null, device.id) : |
| 363 manageCloudDevice.bind(null, device.id) : null); | 356 null); |
| 364 return devicesDomElement; | 357 return devicesDomElement; |
| 365 } | 358 } |
| 366 | 359 |
| 367 /** | 360 /** |
| 368 * Handle a list of cloud devices available to the user globally. | 361 * Handle a list of cloud devices available to the user globally. |
| 369 * @param {Array<Object>} devices_list List of devices. | 362 * @param {Array<Object>} devices_list List of devices. |
| 370 */ | 363 */ |
| 371 function onCloudDeviceListAvailable(devices_list) { | 364 function onCloudDeviceListAvailable(devices_list) { |
| 372 var devicesListLength = devices_list.length; | 365 var devicesListLength = devices_list.length; |
| 373 var devicesContainer = $('cloud-devices'); | 366 var devicesContainer = $('cloud-devices'); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 * Update UI strings to reflect the number of local devices. | 399 * Update UI strings to reflect the number of local devices. |
| 407 */ | 400 */ |
| 408 function updateUIToReflectState() { | 401 function updateUIToReflectState() { |
| 409 var numberPrinters = $('register-device-list').children.length; | 402 var numberPrinters = $('register-device-list').children.length; |
| 410 if (numberPrinters == 0) { | 403 if (numberPrinters == 0) { |
| 411 $('no-printers-message').hidden = false; | 404 $('no-printers-message').hidden = false; |
| 412 | 405 |
| 413 $('register-login-promo').hidden = true; | 406 $('register-login-promo').hidden = true; |
| 414 } else { | 407 } else { |
| 415 $('no-printers-message').hidden = true; | 408 $('no-printers-message').hidden = true; |
| 416 $('register-login-promo').hidden = isUserLoggedIn || | 409 $('register-login-promo').hidden = |
| 417 isUserSupervisedOrOffTheRecord; | 410 isUserLoggedIn || isUserSupervisedOrOffTheRecord; |
| 418 } | 411 } |
| 419 if (!($('register-login-promo').hidden) || | 412 if (!($('register-login-promo').hidden) || |
| 420 !($('cloud-devices-login-promo').hidden) || | 413 !($('cloud-devices-login-promo').hidden) || |
| 421 !($('register-overlay-login-promo').hidden)) { | 414 !($('register-overlay-login-promo').hidden)) { |
| 422 chrome.send( | 415 chrome.send( |
| 423 'metricsHandler:recordAction', | 416 'metricsHandler:recordAction', ['Signin_Impression_FromDevicesPage']); |
| 424 ['Signin_Impression_FromDevicesPage']); | |
| 425 } | 417 } |
| 426 } | 418 } |
| 427 | 419 |
| 428 /** | 420 /** |
| 429 * Announce that a registration succeeeded. | 421 * Announce that a registration succeeeded. |
| 430 */ | 422 */ |
| 431 function onRegistrationSuccess(device_data) { | 423 function onRegistrationSuccess(device_data) { |
| 432 hideRegisterOverlay(); | 424 hideRegisterOverlay(); |
| 433 | 425 |
| 434 if (device_data.service_name == getOverlayIDFromPath()) { | 426 if (device_data.service_name == getOverlayIDFromPath()) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 recordUmaEvent(DEVICES_PAGE_EVENTS.MANAGE_CLICKED); | 474 recordUmaEvent(DEVICES_PAGE_EVENTS.MANAGE_CLICKED); |
| 483 chrome.send('openCloudPrintURL', [device_id]); | 475 chrome.send('openCloudPrintURL', [device_id]); |
| 484 } | 476 } |
| 485 | 477 |
| 486 /** | 478 /** |
| 487 * Record an event in the UMA histogram. | 479 * Record an event in the UMA histogram. |
| 488 * @param {number} eventId The id of the event to be recorded. | 480 * @param {number} eventId The id of the event to be recorded. |
| 489 * @private | 481 * @private |
| 490 */ | 482 */ |
| 491 function recordUmaEvent(eventId) { | 483 function recordUmaEvent(eventId) { |
| 492 chrome.send('metricsHandler:recordInHistogram', | 484 chrome.send( |
| 493 ['LocalDiscovery.DevicesPage', eventId, DEVICES_PAGE_EVENTS.MAX_EVENT]); | 485 'metricsHandler:recordInHistogram', |
| 486 ['LocalDiscovery.DevicesPage', eventId, DEVICES_PAGE_EVENTS.MAX_EVENT]); |
| 494 } | 487 } |
| 495 | 488 |
| 496 /** | 489 /** |
| 497 * Cancel the registration. | 490 * Cancel the registration. |
| 498 */ | 491 */ |
| 499 function cancelRegistration() { | 492 function cancelRegistration() { |
| 500 hideRegisterOverlay(); | 493 hideRegisterOverlay(); |
| 501 chrome.send('cancelRegistration'); | 494 chrome.send('cancelRegistration'); |
| 502 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CANCEL); | 495 recordUmaEvent(DEVICES_PAGE_EVENTS.REGISTER_CANCEL); |
| 503 } | 496 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 517 requestDeviceList(); | 510 requestDeviceList(); |
| 518 } | 511 } |
| 519 | 512 |
| 520 /** | 513 /** |
| 521 * User is not logged in. | 514 * User is not logged in. |
| 522 */ | 515 */ |
| 523 function setUserLoggedIn(userLoggedIn, userSupervisedOrOffTheRecord) { | 516 function setUserLoggedIn(userLoggedIn, userSupervisedOrOffTheRecord) { |
| 524 isUserLoggedIn = userLoggedIn; | 517 isUserLoggedIn = userLoggedIn; |
| 525 isUserSupervisedOrOffTheRecord = userSupervisedOrOffTheRecord; | 518 isUserSupervisedOrOffTheRecord = userSupervisedOrOffTheRecord; |
| 526 | 519 |
| 527 $('cloud-devices-login-promo').hidden = isUserLoggedIn || | 520 $('cloud-devices-login-promo').hidden = |
| 528 isUserSupervisedOrOffTheRecord; | 521 isUserLoggedIn || isUserSupervisedOrOffTheRecord; |
| 529 $('register-overlay-login-promo').hidden = isUserLoggedIn || | 522 $('register-overlay-login-promo').hidden = |
| 530 isUserSupervisedOrOffTheRecord; | 523 isUserLoggedIn || isUserSupervisedOrOffTheRecord; |
| 531 $('register-continue-button').disabled = !isUserLoggedIn || | 524 $('register-continue-button').disabled = |
| 532 isUserSupervisedOrOffTheRecord; | 525 !isUserLoggedIn || isUserSupervisedOrOffTheRecord; |
| 533 | 526 |
| 534 $('my-devices-container').hidden = userSupervisedOrOffTheRecord; | 527 $('my-devices-container').hidden = userSupervisedOrOffTheRecord; |
| 535 | 528 |
| 536 if (isUserSupervisedOrOffTheRecord) { | 529 if (isUserSupervisedOrOffTheRecord) { |
| 537 $('cloud-print-connector-section').hidden = true; | 530 $('cloud-print-connector-section').hidden = true; |
| 538 } | 531 } |
| 539 | 532 |
| 540 if (isUserLoggedIn && !isUserSupervisedOrOffTheRecord) { | 533 if (isUserLoggedIn && !isUserSupervisedOrOffTheRecord) { |
| 541 requestDeviceList(); | 534 requestDeviceList(); |
| 542 $('register-login-promo').hidden = true; | 535 $('register-login-promo').hidden = true; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 558 chrome.send('showSyncUI'); | 551 chrome.send('showSyncUI'); |
| 559 } | 552 } |
| 560 | 553 |
| 561 function registerLoginButtonClicked() { | 554 function registerLoginButtonClicked() { |
| 562 recordUmaEvent(DEVICES_PAGE_EVENTS.LOG_IN_STARTED_FROM_REGISTER_PROMO); | 555 recordUmaEvent(DEVICES_PAGE_EVENTS.LOG_IN_STARTED_FROM_REGISTER_PROMO); |
| 563 openSignInPage(); | 556 openSignInPage(); |
| 564 } | 557 } |
| 565 | 558 |
| 566 function registerOverlayLoginButtonClicked() { | 559 function registerOverlayLoginButtonClicked() { |
| 567 recordUmaEvent( | 560 recordUmaEvent( |
| 568 DEVICES_PAGE_EVENTS.LOG_IN_STARTED_FROM_REGISTER_OVERLAY_PROMO); | 561 DEVICES_PAGE_EVENTS.LOG_IN_STARTED_FROM_REGISTER_OVERLAY_PROMO); |
| 569 openSignInPage(); | 562 openSignInPage(); |
| 570 } | 563 } |
| 571 | 564 |
| 572 function cloudDevicesLoginButtonClicked() { | 565 function cloudDevicesLoginButtonClicked() { |
| 573 recordUmaEvent(DEVICES_PAGE_EVENTS.LOG_IN_STARTED_FROM_DEVICE_LIST_PROMO); | 566 recordUmaEvent(DEVICES_PAGE_EVENTS.LOG_IN_STARTED_FROM_DEVICE_LIST_PROMO); |
| 574 openSignInPage(); | 567 openSignInPage(); |
| 575 } | 568 } |
| 576 | 569 |
| 577 /** | 570 /** |
| 578 * Set the Cloud Print proxy UI to enabled, disabled, or processing. | 571 * Set the Cloud Print proxy UI to enabled, disabled, or processing. |
| 579 * @private | 572 * @private |
| 580 */ | 573 */ |
| 581 function setupCloudPrintConnectorSection(disabled, label, allowed) { | 574 function setupCloudPrintConnectorSection(disabled, label, allowed) { |
| 582 if (!cr.isChromeOS) { | 575 if (!cr.isChromeOS) { |
| 583 $('cloudPrintConnectorLabel').textContent = label; | 576 $('cloudPrintConnectorLabel').textContent = label; |
| 584 if (disabled || !allowed) { | 577 if (disabled || !allowed) { |
| 585 $('cloudPrintConnectorSetupButton').textContent = | 578 $('cloudPrintConnectorSetupButton').textContent = |
| 586 loadTimeData.getString('cloudPrintConnectorDisabledButton'); | 579 loadTimeData.getString('cloudPrintConnectorDisabledButton'); |
| 587 } else { | 580 } else { |
| 588 $('cloudPrintConnectorSetupButton').textContent = | 581 $('cloudPrintConnectorSetupButton').textContent = |
| 589 loadTimeData.getString('cloudPrintConnectorEnabledButton'); | 582 loadTimeData.getString('cloudPrintConnectorEnabledButton'); |
| 590 } | 583 } |
| 591 $('cloudPrintConnectorSetupButton').disabled = !allowed; | 584 $('cloudPrintConnectorSetupButton').disabled = !allowed; |
| 592 | 585 |
| 593 if (disabled) { | 586 if (disabled) { |
| 594 $('cloudPrintConnectorSetupButton').onclick = function(event) { | 587 $('cloudPrintConnectorSetupButton').onclick = function(event) { |
| 595 // Disable the button, set its text to the intermediate state. | 588 // Disable the button, set its text to the intermediate state. |
| 596 $('cloudPrintConnectorSetupButton').textContent = | 589 $('cloudPrintConnectorSetupButton').textContent = |
| 597 loadTimeData.getString('cloudPrintConnectorEnablingButton'); | 590 loadTimeData.getString('cloudPrintConnectorEnablingButton'); |
| 598 $('cloudPrintConnectorSetupButton').disabled = true; | 591 $('cloudPrintConnectorSetupButton').disabled = true; |
| 599 chrome.send('showCloudPrintSetupDialog'); | 592 chrome.send('showCloudPrintSetupDialog'); |
| 600 }; | 593 }; |
| 601 } else { | 594 } else { |
| 602 $('cloudPrintConnectorSetupButton').onclick = function(event) { | 595 $('cloudPrintConnectorSetupButton').onclick = function(event) { |
| 603 chrome.send('disableCloudPrintConnector'); | 596 chrome.send('disableCloudPrintConnector'); |
| 604 requestDeviceList(); | 597 requestDeviceList(); |
| 605 }; | 598 }; |
| 606 } | 599 } |
| 607 } | 600 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 622 return type == 'printer'; | 615 return type == 'printer'; |
| 623 } | 616 } |
| 624 | 617 |
| 625 document.addEventListener('DOMContentLoaded', function() { | 618 document.addEventListener('DOMContentLoaded', function() { |
| 626 cr.ui.overlay.setupOverlay($('overlay')); | 619 cr.ui.overlay.setupOverlay($('overlay')); |
| 627 cr.ui.overlay.globalInitialization(); | 620 cr.ui.overlay.globalInitialization(); |
| 628 $('overlay').addEventListener('cancelOverlay', cancelRegistration); | 621 $('overlay').addEventListener('cancelOverlay', cancelRegistration); |
| 629 | 622 |
| 630 [].forEach.call( | 623 [].forEach.call( |
| 631 document.querySelectorAll('.register-cancel'), function(button) { | 624 document.querySelectorAll('.register-cancel'), function(button) { |
| 632 button.addEventListener('click', cancelRegistration); | 625 button.addEventListener('click', cancelRegistration); |
| 633 }); | 626 }); |
| 634 | 627 |
| 635 [].forEach.call( | 628 [].forEach.call( |
| 636 document.querySelectorAll('.confirm-code'), function(button) { | 629 document.querySelectorAll('.confirm-code'), function(button) { |
| 637 button.addEventListener('click', confirmCode); | 630 button.addEventListener('click', confirmCode); |
| 638 }); | 631 }); |
| 639 | 632 |
| 640 $('register-error-exit').addEventListener('click', cancelRegistration); | 633 $('register-error-exit').addEventListener('click', cancelRegistration); |
| 641 | 634 |
| 642 | 635 |
| 643 $('cloud-devices-retry-link').addEventListener('click', | 636 $('cloud-devices-retry-link') |
| 644 retryLoadCloudDevices); | 637 .addEventListener('click', retryLoadCloudDevices); |
| 645 | 638 |
| 646 $('cloud-devices-login-link').addEventListener( | 639 $('cloud-devices-login-link') |
| 647 'click', | 640 .addEventListener('click', cloudDevicesLoginButtonClicked); |
| 648 cloudDevicesLoginButtonClicked); | |
| 649 | 641 |
| 650 $('register-login-link').addEventListener( | 642 $('register-login-link') |
| 651 'click', | 643 .addEventListener('click', registerLoginButtonClicked); |
| 652 registerLoginButtonClicked); | |
| 653 | 644 |
| 654 $('register-overlay-login-button').addEventListener( | 645 $('register-overlay-login-button') |
| 655 'click', | 646 .addEventListener('click', registerOverlayLoginButtonClicked); |
| 656 registerOverlayLoginButtonClicked); | |
| 657 | 647 |
| 658 if (loadTimeData.valueExists('backButtonURL')) { | 648 if (loadTimeData.valueExists('backButtonURL')) { |
| 659 $('back-link').hidden = false; | 649 $('back-link').hidden = false; |
| 660 $('back-link').addEventListener('click', function() { | 650 $('back-link').addEventListener('click', function() { |
| 661 window.location.href = loadTimeData.getString('backButtonURL'); | 651 window.location.href = loadTimeData.getString('backButtonURL'); |
| 662 }); | 652 }); |
| 663 } | 653 } |
| 664 | 654 |
| 665 updateVisibility(); | 655 updateVisibility(); |
| 666 document.addEventListener('visibilitychange', updateVisibility, false); | 656 document.addEventListener('visibilitychange', updateVisibility, false); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 680 onRegistrationConfirmDeviceCode: onRegistrationConfirmDeviceCode, | 670 onRegistrationConfirmDeviceCode: onRegistrationConfirmDeviceCode, |
| 681 onCloudDeviceListAvailable: onCloudDeviceListAvailable, | 671 onCloudDeviceListAvailable: onCloudDeviceListAvailable, |
| 682 onCloudDeviceListUnavailable: onCloudDeviceListUnavailable, | 672 onCloudDeviceListUnavailable: onCloudDeviceListUnavailable, |
| 683 onDeviceCacheFlushed: onDeviceCacheFlushed, | 673 onDeviceCacheFlushed: onDeviceCacheFlushed, |
| 684 onRegistrationCanceledPrinter: onRegistrationCanceledPrinter, | 674 onRegistrationCanceledPrinter: onRegistrationCanceledPrinter, |
| 685 onRegistrationTimeout: onRegistrationTimeout, | 675 onRegistrationTimeout: onRegistrationTimeout, |
| 686 setUserLoggedIn: setUserLoggedIn, | 676 setUserLoggedIn: setUserLoggedIn, |
| 687 setupCloudPrintConnectorSection: setupCloudPrintConnectorSection, | 677 setupCloudPrintConnectorSection: setupCloudPrintConnectorSection, |
| 688 }; | 678 }; |
| 689 }); | 679 }); |
| OLD | NEW |