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..c7cab6914d1a572fd80c11251da375dc216c036b |
--- /dev/null |
+++ b/chrome/browser/resources/settings/internet_page/tether_connection_dialog.js |
@@ -0,0 +1,86 @@ |
+// 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, |
stevenjb
2017/03/17 20:50:44
Also, minor nit: if you remove the , here clang wi
Kyle Horimoto
2017/03/17 20:56:19
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(); |
+ }, |
+ |
+ 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'; |
+ } |
+}); |