| 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-cups-printers' is a component for showing CUPS | 6 * @fileoverview 'settings-cups-printers' is a component for showing CUPS |
| 7 * Printer settings subpage (chrome://md-settings/cupsPrinters). It is used to | 7 * Printer settings subpage (chrome://md-settings/cupsPrinters). It is used to |
| 8 * set up legacy & non-CloudPrint printers on ChromeOS by leveraging CUPS (the | 8 * set up legacy & non-CloudPrint printers on ChromeOS by leveraging CUPS (the |
| 9 * unix printing system) and the many open source drivers built for CUPS. | 9 * unix printing system) and the many open source drivers built for CUPS. |
| 10 */ | 10 */ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 chrome.networkingPrivate.onNetworksChanged.removeListener( | 54 chrome.networkingPrivate.onNetworksChanged.removeListener( |
| 55 this.networksChangedListener_); | 55 this.networksChangedListener_); |
| 56 }, | 56 }, |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * Callback function when networks change. | 59 * Callback function when networks change. |
| 60 * @private | 60 * @private |
| 61 */ | 61 */ |
| 62 refreshNetworks_: function() { | 62 refreshNetworks_: function() { |
| 63 chrome.networkingPrivate.getNetworks( | 63 chrome.networkingPrivate.getNetworks( |
| 64 {'networkType': chrome.networkingPrivate.NetworkType.ALL, | 64 { |
| 65 'configured': true}, | 65 'networkType': chrome.networkingPrivate.NetworkType.ALL, |
| 66 'configured': true |
| 67 }, |
| 66 this.onNetworksReceived_.bind(this)); | 68 this.onNetworksReceived_.bind(this)); |
| 67 }, | 69 }, |
| 68 | 70 |
| 69 /** | 71 /** |
| 70 * Callback function when configured networks are received. | 72 * Callback function when configured networks are received. |
| 71 * @param {!Array<!chrome.networkingPrivate.NetworkStateProperties>} states | 73 * @param {!Array<!chrome.networkingPrivate.NetworkStateProperties>} states |
| 72 * A list of network state information for each network. | 74 * A list of network state information for each network. |
| 73 * @private | 75 * @private |
| 74 */ | 76 */ |
| 75 onNetworksReceived_: function(states) { | 77 onNetworksReceived_: function(states) { |
| 76 this.canAddPrinter_ = states.some(function(entry) { | 78 this.canAddPrinter_ = states.some(function(entry) { |
| 77 return entry.hasOwnProperty('ConnectionState') && | 79 return entry.hasOwnProperty('ConnectionState') && |
| 78 entry.ConnectionState == 'Connected'; | 80 entry.ConnectionState == 'Connected'; |
| 79 }); | 81 }); |
| 80 }, | 82 }, |
| 81 | 83 |
| 82 /** | 84 /** |
| 83 * @param {boolean} success | 85 * @param {boolean} success |
| 84 * @param {string} printerName | 86 * @param {string} printerName |
| 85 * @private | 87 * @private |
| 86 */ | 88 */ |
| 87 onAddPrinter_: function(success, printerName) { | 89 onAddPrinter_: function(success, printerName) { |
| 88 if (success) { | 90 if (success) { |
| 89 this.updateCupsPrintersList_(); | 91 this.updateCupsPrintersList_(); |
| 90 var message = this.$.addPrinterDoneMessage; | 92 var message = this.$.addPrinterDoneMessage; |
| 91 message.textContent = loadTimeData.getStringF( | 93 message.textContent = |
| 92 'printerAddedSuccessfulMessage', printerName); | 94 loadTimeData.getStringF('printerAddedSuccessfulMessage', printerName); |
| 93 } else { | 95 } else { |
| 94 var message = this.$.addPrinterErrorMessage; | 96 var message = this.$.addPrinterErrorMessage; |
| 95 } | 97 } |
| 96 message.hidden = false; | 98 message.hidden = false; |
| 97 window.setTimeout(function() { | 99 window.setTimeout(function() { |
| 98 message.hidden = true; | 100 message.hidden = true; |
| 99 }, 3000); | 101 }, 3000); |
| 100 }, | 102 }, |
| 101 | 103 |
| 102 /** @private */ | 104 /** @private */ |
| 103 updateCupsPrintersList_: function() { | 105 updateCupsPrintersList_: function() { |
| 104 settings.CupsPrintersBrowserProxyImpl.getInstance(). | 106 settings.CupsPrintersBrowserProxyImpl.getInstance() |
| 105 getCupsPrintersList().then(this.printersChanged_.bind(this)); | 107 .getCupsPrintersList() |
| 108 .then(this.printersChanged_.bind(this)); |
| 106 }, | 109 }, |
| 107 | 110 |
| 108 /** | 111 /** |
| 109 * @param {!CupsPrintersList} cupsPrintersList | 112 * @param {!CupsPrintersList} cupsPrintersList |
| 110 * @private | 113 * @private |
| 111 */ | 114 */ |
| 112 printersChanged_: function(cupsPrintersList) { | 115 printersChanged_: function(cupsPrintersList) { |
| 113 this.printers = cupsPrintersList.printerList; | 116 this.printers = cupsPrintersList.printerList; |
| 114 }, | 117 }, |
| 115 | 118 |
| 116 /** @private */ | 119 /** @private */ |
| 117 onAddPrinterTap_: function() { | 120 onAddPrinterTap_: function() { |
| 118 this.$.addPrinterDialog.open(); | 121 this.$.addPrinterDialog.open(); |
| 119 this.$.addPrinterErrorMessage.hidden = true; | 122 this.$.addPrinterErrorMessage.hidden = true; |
| 120 }, | 123 }, |
| 121 | 124 |
| 122 /** @private */ | 125 /** @private */ |
| 123 onAddPrinterDialogClose_: function() { | 126 onAddPrinterDialogClose_: function() { |
| 124 cr.ui.focusWithoutInk(assert(this.$$('#addPrinter'))); | 127 cr.ui.focusWithoutInk(assert(this.$$('#addPrinter'))); |
| 125 }, | 128 }, |
| 126 }); | 129 }); |
| OLD | NEW |