Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4694)

Unified Diff: chrome/browser/resources/settings/internet_page/network_property_list.js

Issue 2838323002: [CrOS Tether] Add tether settings section to the MD settings page. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/internet_page/network_property_list.js
diff --git a/chrome/browser/resources/settings/internet_page/network_property_list.js b/chrome/browser/resources/settings/internet_page/network_property_list.js
index d64e6225395d45b7563c9c923de695370ae7b790..cb73a4b9d12c7a9a77a2446570b3a81d3963deb5 100644
--- a/chrome/browser/resources/settings/internet_page/network_property_list.js
+++ b/chrome/browser/resources/settings/internet_page/network_property_list.js
@@ -55,6 +55,13 @@ Polymer({
},
/**
+ * Regular expression matching tether property names.
+ * @const {!RegExp}
+ * @private
+ */
+ tetherPropertyRegex_: new RegExp(/^Tether\./),
+
+ /**
* Event triggered when an input field changes. Fires a 'property-change'
* event with the field (property) name set to the target id, and the value
* set to the target input value.
@@ -157,6 +164,9 @@ Polymer({
value =
CrOnc.getActiveValue(/** @type {!CrOnc.ManagedProperty} */ (value));
}
+ if (this.tetherPropertyRegex_.test(key))
Dan Beam 2017/04/26 02:00:46 why not: key.startsWith('Tether.')?
Dan Beam 2017/04/26 02:00:46 needs curlies
Kyle Horimoto 2017/04/26 17:05:04 Done.
Kyle Horimoto 2017/04/26 17:05:04 Done.
+ return this.getTetherPropertyValue_(
+ key, /** @type {string|number} */ (value));
stevenjb 2017/04/26 17:05:08 Alternately, how about: valueStr = this.getCustom
Kyle Horimoto 2017/04/26 17:17:41 Done.
if (typeof value == 'number' || typeof value == 'boolean')
return value.toString();
assert(typeof value == 'string');
@@ -168,4 +178,41 @@ Polymer({
return this.i18n(oncKey);
return valueStr;
},
+
+ /**
+ * @param {string} key The property key.
+ * @param {string|number} value The property value.
+ * @return {string} The text to display for the property value.
+ * @private
+ */
+ getTetherPropertyValue_: function(key, value) {
+ if (key == 'Tether.BatteryPercentage') {
Dan Beam 2017/04/26 02:00:46 no curlies
Kyle Horimoto 2017/04/26 17:05:04 Done.
+ return this.i18n('OncTether-BatteryPercentage_Value', value);
+ }
+
+ if (key == 'Tether.SignalStrength') {
+ // Possible |signalStrength| values should be 0, 25, 50, 75, and 100. Add
+ // <= checks for robustness.
+ if (value <= 24)
+ return this.i18n('OncTether-SignalStrength_VeryWeak');
+ if (value <= 49)
+ return this.i18n('OncTether-SignalStrength_Weak');
+ if (value <= 74)
+ return this.i18n('OncTether-SignalStrength_Fine');
+ if (value <= 99)
+ return this.i18n('OncTether-SignalStrength_Strong');
+ return this.i18n('OncTether-SignalStrength_VeryStrong');
+ }
+
+ if (key == 'Tether.Carrier') {
+ // Note: The 'unknown-carrier' string is used when carrier information is
+ // not available. See host_scanner.cc.
stevenjb 2017/04/26 17:05:08 Not sure this comment is really helpful, that seem
Kyle Horimoto 2017/04/26 17:17:41 Done.
+ return (!value || value == 'unknown-carrier')
+ ? this.i18n('tetherUnknownCarrier')
+ : value;
+ }
+
+ assertNotReached();
+ return '';
+ },
});

Powered by Google App Engine
This is Rietveld 408576698