Commit 5ca466f1 authored by stevenjb's avatar stevenjb Committed by Commit bot

Some JS cleanup, including proper ownership of ONC properties.

This is in preparation for eliminating the remaining non ONC properties
from the 'data' object passed from Chrome.

BUG=279351

Review URL: https://codereview.chromium.org/547703004

Cr-Commit-Position: refs/heads/master@{#293895}
parent c35ed07f
......@@ -2126,9 +2126,6 @@ Press any key to continue exploring.
<message name="IDS_OPTIONS_SETTINGS_ACTIVATE" desc="In the settings tab, the text on the button to activate a cellular network.">
Activate
</message>
<message name="IDS_OPTIONS_SETTINGS_BUY_PLAN" desc="In settings Internet options, the title for buy cellular data plan button.">
Buy plan
</message>
<message name="IDS_OPTIONS_SETTINGS_OPTIONS" desc="In the settings tab, the text on the button to display more options.">
Options...
</message>
......
......@@ -672,7 +672,6 @@
<button id="details-internet-configure" i18n-content="configureButton">
</button>
<button id="activate-details" i18n-content="activateButton"></button>
<button id="buyplan-details" i18n-content="buyplanButton"></button>
<button id="view-account-details" i18n-content="viewAccountButton">
</button>
</div>
......
......@@ -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');
......@@ -134,6 +132,21 @@ cr.define('cr.onc', function() {
return undefined;
},
/**
* 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.
......
......@@ -90,7 +90,6 @@ const char kUpdateCarrierFunction[] =
"options.internet.DetailsInternetPage.updateCarrier";
// These are used to register message handlers with JavaScript.
const char kBuyDataPlanMessage[] = "buyDataPlan";
const char kChangePinMessage[] = "changePin";
const char kDisableCellularMessage[] = "disableCellular";
const char kDisableWifiMessage[] = "disableWifi";
......@@ -459,9 +458,6 @@ void InternetOptionsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(kDisableWimaxMessage,
base::Bind(&InternetOptionsHandler::DisableWimaxCallback,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(kBuyDataPlanMessage,
base::Bind(&InternetOptionsHandler::BuyDataPlanCallback,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(kShowMorePlanInfoMessage,
base::Bind(&InternetOptionsHandler::ShowMorePlanInfoCallback,
base::Unretained(this)));
......@@ -554,17 +550,6 @@ void InternetOptionsHandler::ShowMorePlanInfoCallback(
ash::network_connect::ShowMobileSetup(service_path);
}
void InternetOptionsHandler::BuyDataPlanCallback(const base::ListValue* args) {
if (!web_ui())
return;
std::string service_path;
if (args->GetSize() != 1 || !args->GetString(0, &service_path)) {
NOTREACHED();
return;
}
ash::network_connect::ShowMobileSetup(service_path);
}
void InternetOptionsHandler::SetApnCallback(const base::ListValue* args) {
std::string service_path;
if (!args->GetString(0, &service_path)) {
......
......@@ -58,7 +58,6 @@ class InternetOptionsHandler
void EnableWimaxCallback(const base::ListValue* args);
void DisableWimaxCallback(const base::ListValue* args);
void ShowMorePlanInfoCallback(const base::ListValue* args);
void BuyDataPlanCallback(const base::ListValue* args);
void SetApnCallback(const base::ListValue* args);
void SetApnProperties(const base::ListValue* args,
const std::string& service_path,
......
......@@ -106,7 +106,6 @@ StringResource kStringResources[] = {
{"hardwareAddress", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_HARDWARE_ADDRESS},
{"detailsInternetDismiss", IDS_CLOSE},
{"activateButton", IDS_OPTIONS_SETTINGS_ACTIVATE},
{"buyplanButton", IDS_OPTIONS_SETTINGS_BUY_PLAN},
{"connectButton", IDS_OPTIONS_SETTINGS_CONNECT},
{"configureButton", IDS_OPTIONS_SETTINGS_CONFIGURE},
{"disconnectButton", IDS_OPTIONS_SETTINGS_DISCONNECT},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment