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

Unified Diff: chrome/browser/resources/options/chromeos/onc_data.js

Issue 547703004: Some JS cleanup, including proper ownership of ONC properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_279351_internet_options_8b
Patch Set: Rebase Created 6 years, 3 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/options/chromeos/onc_data.js
diff --git a/chrome/browser/resources/options/chromeos/onc_data.js b/chrome/browser/resources/options/chromeos/onc_data.js
index 78e25a7170f8ae302867cc125c0a0ab4628f5a73..dd1f062c72bb902865fbce841049915fa2538cc7 100644
--- a/chrome/browser/resources/options/chromeos/onc_data.js
+++ b/chrome/browser/resources/options/chromeos/onc_data.js
@@ -12,8 +12,6 @@ cr.define('cr.onc', function() {
function OncData(data) {
this.data_ = data;
- // For convenience set 'type' to the active 'Type' value.
- this.type = this.getActiveValue('Type');
}
OncData.prototype = {
@@ -104,7 +102,7 @@ cr.define('cr.onc', function() {
return value;
var oncString = 'Onc' + key + value;
// Handle special cases
- if (key == 'Name' && this.type == 'Ethernet')
+ if (key == 'Name' && this.getActiveValue('Type') == 'Ethernet')
return loadTimeData.getString('ethernetName');
if (key == 'VPN.Type' && value == 'L2TP-IPsec') {
var auth = this.getActiveValue('VPN.IPsec.AuthenticationType');
@@ -135,6 +133,21 @@ cr.define('cr.onc', function() {
},
/**
+ * Updates the properties of |data_| from the properties in |update|.
+ * Note: this only looks at top level entries, so if a dictionary is
+ * updated the entire dictionary is written over. TODO(stevenjb):
+ * eliminate this function when |data_| contains only ONC entries and
+ * any updates consist of complete ONC dictionaries.
+ * @param {Object} update Dictionary containing the updated properties.
+ */
+ updateData: function(update) {
+ for (var prop in update) {
+ if (prop in this.data_)
+ this.data_[prop] = update[prop];
+ }
+ },
+
+ /**
* Get the effective value from a Managed property ONC dictionary.
* @param {object} property The managed property ONC dictionary.
* @return {*} The effective value or undefined.

Powered by Google App Engine
This is Rietveld 408576698