Skip to content

Commit

Permalink
Add network import settings to network options.
Browse files Browse the repository at this point in the history
BUG=chromium-os:19398,chromium-os:21361
TEST=Go to chrome://settings, select Internet, choose a file to import network settings.
Review URL: http://codereview.chromium.org/8243002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106531 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
achuith@chromium.org committed Oct 20, 2011
1 parent 8d5d761 commit d2504e9
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 1 deletion.
6 changes: 6 additions & 0 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -11699,6 +11699,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_OPTIONS_SETTINGS_ENABLE_DATA_ROAMING" desc="In the settings tab, the text next to the checkbox for data roaming.">
Allow mobile data roaming
</message>
<message name="IDS_OPTIONS_SETTINGS_IMPORT_NETWORK_SETTINGS" desc="In the settings tab, the text next to the file input selector.">
Import network settings:
</message>
<message name="IDS_OPTIONS_SETTINGS_INVALID_NETWORK_SETTINGS" desc="Dialog when network settings file is of invalid format.">
Invalid network settings file
</message>
<message name="IDS_OPTIONS_ACCOUNTS_ALLOW_BWSI_DESCRIPTION" desc="In the Accounts settings tab, the text on the checkbox to allow browse without signing in.">
Enable guest browsing
</message>
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/cros/network_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,7 @@ bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob) {

// TODO(chocobo): Pass parsed network values to flimflam update network.
}
return true;
return parser.GetNetworkConfigsSize() != 0;
}

////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ <h3 i18n-content="generalNetworkingTitle"></h3>
<span i18n-content="enableDataRoaming"></span>
</label>
</div>
<div id="import-network-settings">
<div i18n-content="importNetworkSettings"></div>
<input type="file" name="network_settings" id="upload-network-settings"/>
</div>
</div>
</section>
<section id="wired-section">
Expand Down
17 changes: 17 additions & 0 deletions chrome/browser/resources/options/chromeos/internet_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ cr.define('options', function() {
chrome.send('coreOptionsUserMetricsAction',
['Options_ShowProxySettings']);
});
$('upload-network-settings').addEventListener('change', function(event) {
var file = event.target.files[0];
if (!file.type.match('text/plain')) {
InternetOptions.invalidNetworkSettings();
return;
}

var reader = new FileReader();
reader.onloadend = function(e) {
chrome.send('importNetworkSettings', [this.result]);
};
reader.readAsText(file);
}, false);
$('buyplanDetails').addEventListener('click', function(event) {
chrome.send('buyDataPlan', []);
OptionsPage.closeOverlay();
Expand Down Expand Up @@ -663,6 +676,10 @@ cr.define('options', function() {
OptionsPage.showPageByName('detailsInternetPage', false);
};

InternetOptions.invalidNetworkSettings = function () {
alert(localStrings.getString('invalidNetworkSettings'));
};

// Export
return {
InternetOptions: InternetOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ html[dir='rtl'] .network-item-text {
background: right center no-repeat;
}

input[type='file'] {
margin-top: 5px;
}

#import-network-settings {
margin-top: 10px;
}
.network-item[connected] > * > .network-name-label {
font-weight: bold;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ void InternetOptionsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_USE_SHARED_PROXIES));
localized_strings->SetString("enableDataRoaming",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_ENABLE_DATA_ROAMING));
localized_strings->SetString("importNetworkSettings",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_IMPORT_NETWORK_SETTINGS));
localized_strings->SetString("invalidNetworkSettings",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_INVALID_NETWORK_SETTINGS));
localized_strings->SetString("generalNetworkingTitle",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_CONTROL_TITLE));
Expand Down Expand Up @@ -400,6 +404,9 @@ void InternetOptionsHandler::RegisterMessages() {
web_ui_->RegisterMessageCallback("disableCellular",
base::Bind(&InternetOptionsHandler::DisableCellularCallback,
base::Unretained(this)));
web_ui_->RegisterMessageCallback("importNetworkSettings",
base::Bind(&InternetOptionsHandler::ImportNetworkSettingsCallback,
base::Unretained(this)));
web_ui_->RegisterMessageCallback("buyDataPlan",
base::Bind(&InternetOptionsHandler::BuyDataPlanCallback,
base::Unretained(this)));
Expand Down Expand Up @@ -443,6 +450,20 @@ void InternetOptionsHandler::DisableCellularCallback(const ListValue* args) {
cros_->EnableCellularNetworkDevice(false);
}

void InternetOptionsHandler::ImportNetworkSettingsCallback(
const ListValue* args) {
std::string onc_blob;
if (args->GetSize() != 1 ||
!args->GetString(0, &onc_blob)) {
NOTREACHED();
return;
}

if (!cros_->LoadOncNetworks(onc_blob))
web_ui_->CallJavascriptFunction(
"options.InternetOptions.invalidNetworkSettings");
}

void InternetOptionsHandler::BuyDataPlanCallback(const ListValue* args) {
if (!web_ui_)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class InternetOptionsHandler
void DisableWifiCallback(const base::ListValue* args);
void EnableCellularCallback(const base::ListValue* args);
void DisableCellularCallback(const base::ListValue* args);
void ImportNetworkSettingsCallback(const base::ListValue* args);
void BuyDataPlanCallback(const base::ListValue* args);
void SetApnCallback(const base::ListValue* args);
void SetSimCardLockCallback(const base::ListValue* args);
Expand Down

0 comments on commit d2504e9

Please sign in to comment.