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

Unified Diff: ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js

Issue 874283006: Add custom Polymer network icon element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + Elim extra div in icon Created 5 years, 10 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: ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js
diff --git a/ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js b/ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js
new file mode 100644
index 0000000000000000000000000000000000000000..21b1c0d78fdfeaa640be3238f0a460f61def0098
--- /dev/null
+++ b/ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js
@@ -0,0 +1,56 @@
+// Copyright 2015 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.
+
+/**
+ * @fileoverview ONC network configuration support class. Wraps a dictionary
Dan Beam 2015/02/20 01:02:43 why @fileoverview on separate line in other files
stevenjb 2015/02/20 02:22:47 Which other files? This seems to be the more commo
+ * object containing ONC managed or unmanaged dictionaries. Also provides
+ * special accessors for ONC properties. See cr-onc-types for ONC types,
+ * e.g. CrOnc.NetworkConfigType. Used by consumers of the
+ * chrome.networkingPrivate API. See components/onc/docs/onc_spec.html.
+ */
+
Dan Beam 2015/02/20 01:02:43 why extra \n?
stevenjb 2015/02/20 02:22:48 Done.
+Polymer('cr-onc-data', {
+ publish: {
+ /**
+ * ONC configuration property dictionary, e.g. the result of a
+ * chrome.networkingPrivate.getProperties() call.
+ *
+ * @attribute data
+ * @type CrOnc.NetworkConfigType
+ * @default null
+ */
+ data: null
+ },
+
+ created: function() {
Dan Beam 2015/02/20 01:02:43 /** @type {CrOnc.NetworkConfigType} */
stevenjb 2015/02/20 02:22:48 Done.
+ this.data = {};
+ },
+
+ /**
+ * @return {number} The signal strength of the network.
+ */
+ getStrength: function() {
+ var type = this.data.Type;
+ var strength = 0;
+ if (type == 'WiFi') {
+ strength = this.data.WiFi ? this.data.WiFi.SignalStrength : 0;
+ } else if (type == 'Cellular') {
+ strength = this.data.Cellular ? this.data.Cellular.SignalStrength : 0;
+ } else if (type == 'WiMAX') {
+ strength = this.data.WiMAX ? this.data.WiMAX.SignalStrength : 0;
+ }
Dan Beam 2015/02/20 01:02:44 no curlies
stevenjb 2015/02/20 02:22:48 Done.
+ return strength;
+ },
+
+ /**
+ * Returns the WiFi security type. Undefined or empty defaults to 'None'.
+ * @return {string} The WiFi security type.
+ */
+ getWiFiSecurity: function() {
+ var security = this.data.WiFi ? this.data.WiFi.Security : undefined;
Dan Beam 2015/02/20 01:02:43 nit: return this.data.WiFi && this.data.WiFi.Secur
stevenjb 2015/02/20 02:22:48 Wow, I find that extremely non intuitive for a non
+ if (security)
+ return security;
+ return 'None';
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698