Commit da77427d authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

CrOS Network Config: Add InternetConfigDialog

This adds a new WebUI dialog for network configuraiton using the
shared network-config component.

Bug: 380937
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I44d9db4f01e366afc59e56286cc8fd7adf536bea
Reviewed-on: https://chromium-review.googlesource.com/693288Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506906}
parent 258841bf
......@@ -465,6 +465,8 @@
<include name="IDR_ECHO_MANIFEST" file="resources\chromeos\echo\manifest.json" type="BINDATA" />
<include name="IDR_MERGE_SESSION_LOAD_HTML" file="resources\chromeos\merge_session_load.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_OS_CREDITS_HTML" file="resources\chromeos\about_os_credits.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_INTERNET_CONFIG_DIALOG_HTML" file="resources\chromeos\internet_config_dialog.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<include name="IDR_INTERNET_CONFIG_DIALOG_JS" file="resources\chromeos\internet_config_dialog.js" type="chrome_html" />
<include name="IDR_INTERNET_DETAIL_DIALOG_HTML" file="resources\chromeos\internet_detail_dialog.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<include name="IDR_INTERNET_DETAIL_DIALOG_JS" file="resources\chromeos\internet_detail_dialog.js" type="chrome_html" />
<include name="IDR_CERT_MANAGER_DIALOG_HTML" file="resources\chromeos\certificate_manager_dialog.html" flattenhtml="true" type="BINDATA" />
......
......@@ -15,6 +15,20 @@
],
'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'internet_config_dialog',
'dependencies': [
'<(DEPTH)/ui/webui/resources/cr_components/chromeos/network/compiled_resources2.gyp:network_config',
'<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
'<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_network_behavior',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
'<(EXTERNS_GYP):chrome_send',
'<(EXTERNS_GYP):networking_private',
'<(INTERFACES_GYP):networking_private_interface',
],
'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'internet_detail_dialog',
'dependencies': [
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/network/network_config.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/network/network_shared_css.html">
<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html">
<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<dom-module id="internet-config-dialog">
<template>
<style include="network-shared iron-flex">
.button-strip {
justify-content: flex-end;
}
.section {
@apply(--cr-section);
margin-bottom: 10px;
}
.section.first {
border-top: none;
}
.section.single-column {
align-items: stretch;
flex-direction: column;
justify-content: center;
}
.section > .start {
align-items: center;
flex: auto;
}
.title {
-webkit-margin-start: 20px;
font-size: 107.69%; /* 14px / 13px */
font-weight: 500;
}
</style>
<!-- Title section: Icon + name. -->
<div class="section first">
<div class="start layout horizontal center">
<cr-network-icon network-state="[[networkProperties_]]" is-list-item>
</cr-network-icon>
<div class="title">[[getTitle_(type_, name_)]]</div>
</div>
</div>
<div class="section single-column">
<network-config id="networkConfig" class="flex"
networking-private="[[networkingPrivate]]"
guid="[[guid_]]" type="[[type_]]" name="{{name_}}"
network-properties="[[networkProperties_]]"
enable-connect="{{enableConnect_}}" enable-save="{{enableSave_}}"
on-close="close_">
</network-config>
</div>
<div class="section button-strip">
<paper-button class="secondary-button" on-tap="onCancelTap_">
$i18n{cancel}
</paper-button>
<template is="dom-if" if="[[guid_]]">
<paper-button class="primary-button" on-tap="onSaveTap_"
disabled="[[!enableSave_]]">
$i18n{save}
</paper-button>
</template>
<template is="dom-if" if="[[!guid_]]">
<paper-button class="primary-button" on-tap="onConnectTap_"
disabled="[[!enableConnect_]]">
$i18n{networkButtonConnect}
</paper-button>
</template>
</div>
</template>
<script src="internet_config_dialog.js"></script>
</dom-module>
<html i18n-values="dir:textdirection;lang:language">
<script src="chrome://internet-config-dialog/strings.js"></script>
<body>
<internet-config-dialog></internet-config-dialog>
</body>
</html>
// Copyright 2017 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
* 'internet-config-dialog' is used to configure a new or existing network
* outside of settings (e.g. from the login screen or when configuring a
* new network from the system tray).
*/
Polymer({
is: 'internet-config-dialog',
behaviors: [I18nBehavior],
properties: {
/**
* Interface for networkingPrivate calls.
* @type {NetworkingPrivate}
*/
networkingPrivate: {
type: Object,
value: chrome.networkingPrivate,
},
/**
* The network GUID to configure, or empty when configuring a new network.
* @private
*/
guid_: String,
/**
* The type of network being configured.
* @private {!chrome.networkingPrivate.NetworkType}
*/
type_: String,
/**
* The name of the network being configured (set by network-config).
* @private
*/
name_: {
type: String,
value: '',
},
/** @private */
enableConnect_: String,
/** @private */
enableSave_: String,
/**
* The current properties for an existing network, or a minimal subset when
* a new network is being configured.
* @type {!chrome.networkingPrivate.NetworkProperties|undefined}
*/
networkProperties_: Object,
},
/** @override */
attached: function() {
var dialogArgs = chrome.getVariableValue('dialogArguments');
assert(dialogArgs);
var args = JSON.parse(dialogArgs);
this.type_ =
/** @type {chrome.networkingPrivate.NetworkType} */ (args.type);
assert(this.type_);
this.guid_ = args.guid || '';
this.networkProperties_ = {
GUID: this.guid_,
Name: this.name_,
Type: this.type_,
};
this.$.networkConfig.init();
},
/** @private */
close_: function() {
chrome.send('dialogClose');
},
/**
* @return {string}
* @private
*/
getTitle_: function() {
return this.name_ || this.i18n('OncType' + this.type_);
},
/** @private */
onCancelTap_: function() {
this.close_();
},
/** @private */
onSaveTap_: function() {
this.$.networkConfig.saveOrConnect();
},
/** @private */
onConnectTap_: function() {
this.$.networkConfig.saveOrConnect();
},
});
......@@ -45,8 +45,8 @@ Polymer({
enableSave_: String,
/**
* The current properties if an existing network being configured.
* This will be undefined when configuring a new network.
* The current properties if an existing network being configured, or
* a minimal subset for a new network.
* @private {!chrome.networkingPrivate.NetworkProperties|undefined}
*/
networkProperties_: Object,
......
......@@ -1326,6 +1326,8 @@ split_static_library("ui") {
"webui/chromeos/first_run/first_run_ui.h",
"webui/chromeos/image_source.cc",
"webui/chromeos/image_source.h",
"webui/chromeos/internet_config_dialog.cc",
"webui/chromeos/internet_config_dialog.h",
"webui/chromeos/internet_detail_dialog_ui.cc",
"webui/chromeos/internet_detail_dialog_ui.h",
"webui/chromeos/keyboard_overlay_ui.cc",
......
......@@ -8,6 +8,7 @@
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/shell.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/user_metrics.h"
......@@ -29,14 +30,17 @@
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "chrome/browser/upgrade_detector.h"
#include "chrome/common/url_constants.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "chromeos/login/login_state.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_util.h"
#include "chromeos/network/tether_constants.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_service_manager.h"
......@@ -365,13 +369,25 @@ void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) {
chromeos::NetworkHandler::Get()
->network_state_handler()
->GetNetworkStateFromGuid(network_id);
if (network_state && network_state->type() == chromeos::kTypeTether &&
if (!network_state) {
LOG(ERROR) << "Network not found: " << network_id;
return;
}
if (network_state->type() == chromeos::kTypeTether &&
!network_state->tether_has_connected_to_host()) {
ShowNetworkSettingsHelper(network_id, true /* show_configure */);
return;
}
chromeos::NetworkConfigView::ShowForNetworkId(network_id);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kNetworkSettingsConfig)) {
chromeos::InternetConfigDialog::ShowDialogForNetworkState(
ProfileManager::GetActiveUserProfile(), GetDialogParentContainerId(),
network_state);
} else {
chromeos::NetworkConfigView::ShowForNetworkId(network_id);
}
}
void SystemTrayClient::ShowNetworkCreate(const std::string& type) {
......@@ -384,7 +400,18 @@ void SystemTrayClient::ShowNetworkCreate(const std::string& type) {
ShowNetworkSettingsHelper(network_id, false /* show_configure */);
return;
}
chromeos::NetworkConfigView::ShowForType(type);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kNetworkSettingsConfig)) {
// TODO(stevenjb): Pass ONC type to ShowNetworkCreate once NetworkConfigView
// is deprecated.
std::string onc_type =
chromeos::network_util::TranslateShillTypeToONC(type);
chromeos::InternetConfigDialog::ShowDialogForNetworkType(
ProfileManager::GetActiveUserProfile(), GetDialogParentContainerId(),
onc_type);
} else {
chromeos::NetworkConfigView::ShowForType(type);
}
}
void SystemTrayClient::ShowThirdPartyVpnCreate(
......
......@@ -140,6 +140,7 @@
#include "chrome/browser/ui/webui/chromeos/cryptohome_ui.h"
#include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h"
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h"
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog_ui.h"
#include "chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
......@@ -465,6 +466,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::PowerUI>;
if (url.host_piece() == proximity_auth::kChromeUIProximityAuthHost)
return &NewWebUI<proximity_auth::ProximityAuthUI>;
if (url.host_piece() == chrome::kChromeUIInternetConfigDialogHost)
return &NewWebUI<chromeos::InternetConfigDialogUI>;
if (url.host_piece() == chrome::kChromeUIInternetDetailDialogHost)
return &NewWebUI<chromeos::InternetDetailDialogUI>;
if (url.host_piece() == chrome::kChromeUISetTimeHost)
......
// Copyright 2017 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.
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "base/json/json_writer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_util.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
namespace {
// Width matches the Settings UI, height will be resized to match the content.
const int kInternetConfigDialogWidth = 640;
const int kInternetConfigDialogHeight = 480;
void AddInternetStrings(content::WebUIDataSource* html_source) {
// Add default strings first.
chromeos::network_element::AddLocalizedStrings(html_source);
chromeos::network_element::AddOncLocalizedStrings(html_source);
chromeos::network_element::AddConfigLocalizedStrings(html_source);
// Add additional strings and overrides needed by the dialog.
struct {
const char* name;
int id;
} localized_strings[] = {
{"networkButtonConnect", IDS_SETTINGS_INTERNET_BUTTON_CONNECT},
{"cancel", IDS_CANCEL},
{"save", IDS_SAVE},
};
for (const auto& entry : localized_strings)
html_source->AddLocalizedString(entry.name, entry.id);
}
} // namespace
InternetConfigDialog::InternetConfigDialog(const std::string& network_type,
const std::string& network_id)
: network_type_(network_type), network_id_(network_id) {}
InternetConfigDialog::~InternetConfigDialog() {}
ui::ModalType InternetConfigDialog::GetDialogModalType() const {
return ui::MODAL_TYPE_SYSTEM;
}
base::string16 InternetConfigDialog::GetDialogTitle() const {
return l10n_util::GetStringUTF16(IDS_SETTINGS_INTERNET_CONFIG);
}
GURL InternetConfigDialog::GetDialogContentURL() const {
return GURL(chrome::kChromeUIIntenetConfigDialogURL);
}
void InternetConfigDialog::GetWebUIMessageHandlers(
std::vector<content::WebUIMessageHandler*>* handlers) const {}
void InternetConfigDialog::GetDialogSize(gfx::Size* size) const {
size->SetSize(kInternetConfigDialogWidth, kInternetConfigDialogHeight);
}
std::string InternetConfigDialog::GetDialogArgs() const {
base::DictionaryValue args;
args.SetKey("type", base::Value(network_type_));
args.SetKey("guid", base::Value(network_id_));
std::string json;
base::JSONWriter::Write(args, &json);
return json;
}
void InternetConfigDialog::OnDialogClosed(const std::string& json_retval) {
delete this;
}
void InternetConfigDialog::OnCloseContents(content::WebContents* source,
bool* out_close_dialog) {
*out_close_dialog = true;
}
bool InternetConfigDialog::ShouldShowDialogTitle() const {
return true;
}
// static
void InternetConfigDialog::ShowDialogForNetworkState(
content::BrowserContext* browser_context,
int container_id,
const NetworkState* network_state) {
std::string network_type =
chromeos::network_util::TranslateShillTypeToONC(network_state->type());
InternetConfigDialog* dialog =
new InternetConfigDialog(network_type, network_state->guid());
chrome::ShowWebDialogInContainer(container_id, browser_context, dialog);
}
// static
void InternetConfigDialog::ShowDialogForNetworkType(
content::BrowserContext* browser_context,
int container_id,
const std::string& network_type) {
InternetConfigDialog* dialog = new InternetConfigDialog(network_type, "");
chrome::ShowWebDialogInContainer(container_id, browser_context, dialog);
}
// InternetConfigDialogUI
InternetConfigDialogUI::InternetConfigDialogUI(content::WebUI* web_ui)
: ui::WebDialogUI(web_ui) {
content::WebUIDataSource* source = content::WebUIDataSource::Create(
chrome::kChromeUIInternetConfigDialogHost);
AddInternetStrings(source);
source->SetJsonPath("strings.js");
source->SetDefaultResource(IDR_INTERNET_CONFIG_DIALOG_HTML);
source->DisableContentSecurityPolicy();
source->AddResourcePath("internet_config_dialog.js",
IDR_INTERNET_CONFIG_DIALOG_JS);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
InternetConfigDialogUI::~InternetConfigDialogUI() {}
} // namespace chromeos
// Copyright 2017 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.
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_INTERNET_CONFIG_DIALOG_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_INTERNET_CONFIG_DIALOG_H_
#include <string>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
#include "ui/web_dialogs/web_dialog_ui.h"
namespace content {
class BrowserContext;
}
namespace chromeos {
class NetworkState;
class InternetConfigDialog : public ui::WebDialogDelegate {
public:
// Shows a network configuration dialog for |network_state|.
static void ShowDialogForNetworkState(
content::BrowserContext* browser_context,
int container_id,
const NetworkState* network_state);
// Shows a network configuration dialog for a new network of |network_type|.
static void ShowDialogForNetworkType(content::BrowserContext* browser_context,
int container_id,
const std::string& network_type);
protected:
// ui::WebDialogDelegate
ui::ModalType GetDialogModalType() const override;
base::string16 GetDialogTitle() const override;
GURL GetDialogContentURL() const override;
void GetWebUIMessageHandlers(
std::vector<content::WebUIMessageHandler*>* handlers) const override;
void GetDialogSize(gfx::Size* size) const override;
std::string GetDialogArgs() const override;
void OnDialogClosed(const std::string& json_retval) override;
void OnCloseContents(content::WebContents* source,
bool* out_close_dialog) override;
bool ShouldShowDialogTitle() const override;
InternetConfigDialog(const std::string& network_type,
const std::string& network_id);
~InternetConfigDialog() override;
private:
std::string network_type_;
std::string network_id_;
DISALLOW_COPY_AND_ASSIGN(InternetConfigDialog);
};
// A WebUI to host the network configuration UI in a dialog, used in the
// login screen and when a new network is configured from the system tray.
class InternetConfigDialogUI : public ui::WebDialogUI {
public:
explicit InternetConfigDialogUI(content::WebUI* web_ui);
~InternetConfigDialogUI() override;
private:
DISALLOW_COPY_AND_ASSIGN(InternetConfigDialogUI);
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_INTERNET_CONFIG_DIALOG_H_
......@@ -21,7 +21,7 @@ void AddInternetStrings(content::WebUIDataSource* html_source) {
// Add default strings first.
chromeos::network_element::AddLocalizedStrings(html_source);
chromeos::network_element::AddOncLocalizedStrings(html_source);
chromeos::network_element::AddConfigLocalizedStrings(html_source);
chromeos::network_element::AddDetailsLocalizedStrings(html_source);
// Add additional strings and overrides needed by the dialog.
struct {
const char* name;
......@@ -34,7 +34,7 @@ void AddInternetStrings(content::WebUIDataSource* html_source) {
{"networkSectionProxy", IDS_SETTINGS_INTERNET_NETWORK_SECTION_PROXY},
{"networkIPConfigAuto", IDS_SETTINGS_INTERNET_NETWORK_IP_CONFIG_AUTO},
{"save", IDS_SAVE},
// Override for network_element::AddConfigLocalizedStrings
// Override for network_element::AddDetailsLocalizedStrings
{"networkProxyConnectionType",
IDS_SETTINGS_INTERNET_NETWORK_PROXY_CONNECTION_TYPE_DIALOG},
};
......
......@@ -17,7 +17,7 @@ namespace {
struct {
const char* name;
int id;
} const localized_strings[] = {
} const element_localized_strings[] = {
{"OncTypeCellular", IDS_NETWORK_TYPE_MOBILE_DATA},
{"OncTypeEthernet", IDS_NETWORK_TYPE_ETHERNET},
{"OncTypeTether", IDS_NETWORK_TYPE_MOBILE_DATA},
......@@ -32,42 +32,19 @@ struct {
{"networkListItemNoNetwork", IDS_NETWORK_LIST_NO_NETWORK},
{"vpnNameTemplate", IDS_NETWORK_LIST_THIRD_PARTY_VPN_NAME_TEMPLATE},
};
} // namespace
void AddLocalizedStrings(content::WebUIDataSource* html_source) {
for (const auto& entry : localized_strings)
for (const auto& entry : element_localized_strings)
html_source->AddLocalizedString(entry.name, entry.id);
}
void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder) {
for (const auto& entry : localized_strings)
for (const auto& entry : element_localized_strings)
builder->Add(entry.name, entry.id);
}
// TODO(stevenjb): Remove this function; it is mostly a duplicate of the strings
// above.
void AddDetailsLocalizedStrings(content::WebUIDataSource* html_source) {
struct {
const char* name;
int id;
} localized_strings[] = {
{"OncTypeCellular", IDS_NETWORK_TYPE_MOBILE_DATA},
{"OncTypeEthernet", IDS_NETWORK_TYPE_ETHERNET},
{"OncTypeTether", IDS_NETWORK_TYPE_MOBILE_DATA},
{"OncTypeVPN", IDS_NETWORK_TYPE_VPN},
{"OncTypeWiFi", IDS_NETWORK_TYPE_WIFI},
{"OncTypeWiMAX", IDS_NETWORK_TYPE_WIMAX},
{"networkListItemConnected", IDS_STATUSBAR_NETWORK_DEVICE_CONNECTED},
{"networkListItemConnecting", IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING},
{"networkListItemConnectingTo", IDS_NETWORK_LIST_CONNECTING_TO},
{"networkListItemNotConnected", IDS_NETWORK_LIST_NOT_CONNECTED},
{"networkListItemNoNetwork", IDS_NETWORK_LIST_NO_NETWORK},
{"vpnNameTemplate", IDS_NETWORK_LIST_THIRD_PARTY_VPN_NAME_TEMPLATE},
};
for (const auto& entry : localized_strings)
html_source->AddLocalizedString(entry.name, entry.id);
}
void AddOncLocalizedStrings(content::WebUIDataSource* html_source) {
struct {
const char* name;
......@@ -183,7 +160,7 @@ void AddOncLocalizedStrings(content::WebUIDataSource* html_source) {
html_source->AddLocalizedString(entry.name, entry.id);
}
void AddConfigLocalizedStrings(content::WebUIDataSource* html_source) {
void AddDetailsLocalizedStrings(content::WebUIDataSource* html_source) {
struct {
const char* name;
int id;
......@@ -233,6 +210,21 @@ void AddConfigLocalizedStrings(content::WebUIDataSource* html_source) {
html_source->AddLocalizedString(entry.name, entry.id);
}
void AddConfigLocalizedStrings(content::WebUIDataSource* html_source) {
struct {
const char* name;
int id;
} localized_strings[] = {
{"networkCAUseDefault", IDS_SETTINGS_INTERNET_NETWORK_CA_USE_DEFAULT},
{"networkCADoNotCheck", IDS_SETTINGS_INTERNET_NETWORK_CA_DO_NOT_CHECK},
{"networkConfigSaveCredentials",
IDS_SETTINGS_INTERNET_CONFIG_SAVE_CREDENTIALS},
{"networkConfigShare", IDS_SETTINGS_INTERNET_CONFIG_SHARE},
};
for (const auto& entry : localized_strings)
html_source->AddLocalizedString(entry.name, entry.id);
}
} // namespace network_element
} // namespace chromeos
......@@ -26,7 +26,10 @@ void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder);
// Adds ONC strings used by the details dialog used in Settings and WebUI.
void AddOncLocalizedStrings(content::WebUIDataSource* html_source);
// Adds configuration strings used by the details dialog used in Settings and
// Adds strings used by the details dialog used in Settings and WebUI.
void AddDetailsLocalizedStrings(content::WebUIDataSource* html_source);
// Adds strings used by the configuration dialog used in Settings and
// WebUI.
void AddConfigLocalizedStrings(content::WebUIDataSource* html_source);
......
......@@ -929,8 +929,6 @@ void AddInternetStrings(content::WebUIDataSource* html_source) {
{"networkButtonDisconnect", IDS_SETTINGS_INTERNET_BUTTON_DISCONNECT},
{"networkButtonForget", IDS_SETTINGS_INTERNET_BUTTON_FORGET},
{"networkButtonViewAccount", IDS_SETTINGS_INTERNET_BUTTON_VIEW_ACCOUNT},
{"networkCAUseDefault", IDS_SETTINGS_INTERNET_NETWORK_CA_USE_DEFAULT},
{"networkCADoNotCheck", IDS_SETTINGS_INTERNET_NETWORK_CA_DO_NOT_CHECK},
{"networkCertificateName",
IDS_SETTINGS_INTERNET_NETWORK_CERTIFICATE_NAME},
{"networkCertificateNameHardwareBacked",
......@@ -938,9 +936,6 @@ void AddInternetStrings(content::WebUIDataSource* html_source) {
{"networkCertificateNoneInstalled",
IDS_SETTINGS_INTERNET_NETWORK_CERTIFICATE_NONE_INSTALLED},
{"networkConnectNotAllowed", IDS_SETTINGS_INTERNET_CONNECT_NOT_ALLOWED},
{"networkConfigSaveCredentials",
IDS_SETTINGS_INTERNET_CONFIG_SAVE_CREDENTIALS},
{"networkConfigShare", IDS_SETTINGS_INTERNET_CONFIG_SHARE},
{"networkIPAddress", IDS_SETTINGS_INTERNET_NETWORK_IP_ADDRESS},
{"networkIPConfigAuto", IDS_SETTINGS_INTERNET_NETWORK_IP_CONFIG_AUTO},
{"networkPrefer", IDS_SETTINGS_INTERNET_NETWORK_PREFER},
......@@ -2130,6 +2125,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
#if defined(OS_CHROMEOS)
chromeos::network_element::AddLocalizedStrings(html_source);
chromeos::network_element::AddOncLocalizedStrings(html_source);
chromeos::network_element::AddDetailsLocalizedStrings(html_source);
chromeos::network_element::AddConfigLocalizedStrings(html_source);
#endif
policy_indicator::AddLocalizedStrings(html_source);
......
......@@ -128,6 +128,8 @@ const char kChromeUIKeyboardOverlayURL[] = "chrome://keyboardoverlay/";
const char kChromeUIMobileSetupURL[] = "chrome://mobilesetup/";
const char kChromeUIOobeURL[] = "chrome://oobe/";
const char kChromeUIOSCreditsURL[] = "chrome://os-credits/";
const char kChromeUIIntenetConfigDialogURL[] =
"chrome://internet-config-dialog/";
const char kChromeUIIntenetDetailDialogURL[] =
"chrome://internet-detail-dialog/";
const char kChromeUIScreenlockIconURL[] = "chrome://screenlock-icon/";
......@@ -315,6 +317,7 @@ const char kChromeUINetworkHost[] = "network";
const char kChromeUIOobeHost[] = "oobe";
const char kChromeUIOSCreditsHost[] = "os-credits";
const char kChromeUIPowerHost[] = "power";
const char kChromeUIInternetConfigDialogHost[] = "internet-config-dialog";
const char kChromeUIInternetDetailDialogHost[] = "internet-detail-dialog";
const char kChromeUIRotateHost[] = "rotate";
const char kChromeUIScreenlockIconHost[] = "screenlock-icon";
......@@ -733,6 +736,7 @@ const char* const kChromeHostURLs[] = {
kChromeUIOobeHost,
kChromeUIOSCreditsHost,
kChromeUIPowerHost,
kChromeUIInternetConfigDialogHost,
kChromeUIInternetDetailDialogHost,
kChromeUIVoiceSearchHost,
#endif
......
......@@ -118,6 +118,7 @@ extern const char kChromeUIKeyboardOverlayURL[];
extern const char kChromeUIMobileSetupURL[];
extern const char kChromeUIOobeURL[];
extern const char kChromeUIOSCreditsURL[];
extern const char kChromeUIIntenetConfigDialogURL[];
extern const char kChromeUIIntenetDetailDialogURL[];
extern const char kChromeUIScreenlockIconURL[];
extern const char kChromeUISetTimeURL[];
......@@ -298,6 +299,7 @@ extern const char kChromeUINetworkHost[];
extern const char kChromeUIOobeHost[];
extern const char kChromeUIOSCreditsHost[];
extern const char kChromeUIPowerHost[];
extern const char kChromeUIInternetConfigDialogHost[];
extern const char kChromeUIInternetDetailDialogHost[];
extern const char kChromeUIRotateHost[];
extern const char kChromeUIScreenlockIconHost[];
......
......@@ -340,6 +340,7 @@
"matches": [
"chrome://network/*",
"chrome://oobe/*",
"chrome://internet-config-dialog/*",
"chrome://internet-detail-dialog/*",
"chrome://settings/*"
]
......
......@@ -1016,9 +1016,18 @@ Polymer({
error);
return;
}
this.networkProperties.GUID = guid;
this.fire('network-connect', {networkProperties: this.networkProperties});
this.close_();
this.networkingPrivate.startConnect(guid, () => {
error = chrome.runtime.lastError && chrome.runtime.lastError.message;
if (error) {
if (error == 'connecting' || error == 'connected' ||
error == 'connect-canceled') {
return;
}
// TODO(stevenjb): Display error message.
console.error('Error connecting to network: ' + error);
}
this.close_();
});
},
/**
......
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