Chromium Code Reviews| Index: chrome/browser/resources/settings/internet_page/tether_connection_dialog.js |
| diff --git a/chrome/browser/resources/settings/internet_page/tether_connection_dialog.js b/chrome/browser/resources/settings/internet_page/tether_connection_dialog.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cf340b6740ba02295ba9dea52b1b95b4f8ffd3fa |
| --- /dev/null |
| +++ b/chrome/browser/resources/settings/internet_page/tether_connection_dialog.js |
| @@ -0,0 +1,87 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @typedef {{ |
| + * tetherNostDeviceName: string, |
| + * batteryPercentage: number, |
| + * connectionStrength: number, |
| + * isTetherHostCurrentlyOnWifi: boolean |
| + * }} |
| + */ |
| +var TetherConnectionData; |
| + |
| +Polymer({ |
| + is: 'tether-connection-dialog', |
| + |
| + behaviors: [ |
| + I18nBehavior, |
| + CrScrollableBehavior, |
|
stevenjb
2017/03/17 20:43:54
You shouldn't need this behavior?
Kyle Horimoto
2017/03/17 20:48:38
Done.
|
| + ], |
| + |
| + properties: { |
| + /** |
| + * The data used to display the tether connection dialog. |
| + * @private {!TetherConnectionData|undefined} |
| + */ |
| + tetherData_: { |
| + type: Object, |
| + // TODO(khorimoto): Remove this and use real data when available. |
| + value: { |
| + tetherNostDeviceName: 'Pixel XL', |
| + batteryPercentage: 100, |
| + connectionStrength: 4, |
| + isTetherHostCurrentlyOnWifi: false |
| + }, |
| + }, |
| + }, |
| + |
| + open: function() { |
| + this.getDialog_().showModal(); |
|
Dan Beam
2017/03/17 21:50:05
note: showModal throws if the dialog is already op
Kyle Horimoto
2017/03/17 22:06:38
Done.
|
| + }, |
| + |
| + close: function() { |
| + var dialog = this.getDialog_(); |
| + if (dialog.open) |
| + dialog.close(); |
| + }, |
| + |
| + /** @override */ |
| + ready: function() { |
| + this.open(); |
| + }, |
| + |
| + /** |
| + * @return {!CrDialogElement} |
| + * @private |
| + */ |
| + getDialog_: function() { |
| + return /** @type {!CrDialogElement} */ (this.$.dialog); |
| + }, |
| + |
| + /** @private */ |
| + onNotNowTap_: function() { |
| + this.getDialog_().cancel(); |
| + }, |
| + |
| + /** |
| + * @param {!TetherConnectionData|undefined} tetherData |
| + * @return {string} |
| + * @private |
| + */ |
| + getReceptionIcon_: function(tetherData) { |
| + var connectionStrength; |
| + |
| + if (!tetherData || !tetherData.connectionStrength) { |
| + connectionStrength = 0; |
| + } else { |
| + // Ensure that 0 <= connectionStrength <= 4, since these values are the |
| + // limits of the cellular strength icons. |
| + connectionStrength = |
| + Math.min(Math.max(tetherData.connectionStrength, 0), 4); |
| + } |
| + |
| + return 'device:signal-cellular-' + connectionStrength + '-bar'; |
| + } |
| +}); |