Commit 9dc53e6e authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Eliminate deprecated Views based network config code.

This CL eliminates:
* disable-network-settings-config
* networkSettingsConfig
* NetworkConfigView and related unused classes

This also cleans up some stale comments and related interfaces.

Bug: 848090
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Id79b835f72b79694d7013cf19a17d553622f844b
Reviewed-on: https://chromium-review.googlesource.com/1102912
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568327}
parent 54b9145d
This diff is collapsed.
......@@ -2890,12 +2890,6 @@ are declared in build/common.gypi.
<message name="IDS_CERTIFICATE_MANAGER_TITLE" desc="String to be displayed in the title bar of the certificate manager dialog">
Certificate manager
</message>
<message name="IDS_CERT_MANAGER_PKCS12_FILES" desc="The label in the file selector dialog for PKCS #12 file type.">
PKCS #12 Files
</message>
<message name="IDS_CERT_MANAGER_PKCS12_EXPORT_ERROR_TITLE" desc="The title in the error dialog for PKCS #12 file export errors.">
PKCS #12 Export Error
</message>
<message name="IDS_CERT_MANAGER_HARDWARE_BACKED_KEY_FORMAT" desc="A format used to create label for hardware-backed keys.">
<ph name="KEY_NAME">$1<ex>John Doe</ex></ph> (<ph name="DEVICE">$2<ex>hardware-backed</ex></ph>)
</message>
......@@ -2907,15 +2901,6 @@ are declared in build/common.gypi.
</message>
</if>
<if expr="chromeos">
<message name="IDS_CERT_MANAGER_KEY_FORMAT_LONG" desc="A longer format for keys in the wifi / vpn config dialogs.">
<ph name="ISSUED_BY">$1<ex>Google Inc</ex></ph> [<ph name="ISSUED_TO">$2<ex>John Doe</ex></ph>]
</message>
<message name="IDS_CERT_MANAGER_HARDWARE_BACKED_KEY_FORMAT_LONG" desc="A longer format for hardware-backed keys in the wifi / vpn config dialogs.">
<ph name="ISSUED_BY">$1<ex>Google Inc</ex></ph> [<ph name="ISSUED_TO">$2<ex>John Doe</ex></ph>] (<ph name="DEVICE">$3<ex>hardware-backed</ex></ph>)
</message>
</if>
<!-- DevTools attached infobar -->
<message name="IDS_DEV_TOOLS_INFOBAR_LABEL" desc="Label displayed in an infobar when external debugger is attached to the browser">
"<ph name="CLIENT_NAME">$1<ex>Extension Foo</ex></ph>" is debugging this browser
......
......@@ -1578,6 +1578,9 @@
<message name="IDS_SETTINGS_INTERNET_NETWORK_CERTIFICATE_NONE_INSTALLED" desc="Settings > Internet > Network configuration: Label when no certificates are installed.">
None installed
</message>
<message name="IDS_SETTINGS_INTERNET_NETWORK_REQUIRE_HARDWARE_BACKED" desc="In the network connect dialog, when creating a VPN or enterprise Wi-Fi connection, error message to display when a non hardware-backed user certificate is selected.">
User certificate must be hardware-backed.
</message>
<message name="IDS_SETTINGS_INTERNET_NETWORK_ACCESS_POINT" desc="Settings > Internet > Network details: Access Point section label.">
Access Point
</message>
......
......@@ -1265,20 +1265,6 @@ source_set("chromeos") {
"note_taking_helper.h",
"oauth2_token_service_delegate.cc",
"oauth2_token_service_delegate.h",
"options/cert_library.cc",
"options/cert_library.h",
"options/network_config_view.cc",
"options/network_config_view.h",
"options/network_property_ui_data.cc",
"options/network_property_ui_data.h",
"options/passphrase_textfield.cc",
"options/passphrase_textfield.h",
"options/vpn_config_view.cc",
"options/vpn_config_view.h",
"options/wifi_config_view.cc",
"options/wifi_config_view.h",
"options/wimax_config_view.cc",
"options/wimax_config_view.h",
"ownership/owner_settings_service_chromeos.cc",
"ownership/owner_settings_service_chromeos.h",
"ownership/owner_settings_service_chromeos_factory.cc",
......@@ -1695,8 +1681,8 @@ source_set("chromeos") {
"ui/kiosk_external_update_notification.h",
"ui/low_disk_notification.cc",
"ui/low_disk_notification.h",
"ui/mobile_config_ui.cc",
"ui/mobile_config_ui.h",
"ui/passphrase_textfield.cc",
"ui/passphrase_textfield.h",
"ui/request_pin_view.cc",
"ui/request_pin_view.h",
"ui/screen_capture_notification_ui_chromeos.cc",
......@@ -2054,7 +2040,6 @@ source_set("unit_tests") {
"night_light/night_light_client_unittest.cc",
"note_taking_helper_unittest.cc",
"oauth2_token_service_delegate_unittest.cc",
"options/network_property_ui_data_unittest.cc",
"ownership/fake_owner_settings_service.cc",
"ownership/fake_owner_settings_service.h",
"ownership/owner_settings_service_chromeos_unittest.cc",
......
......@@ -75,7 +75,6 @@
#include "chrome/browser/chromeos/net/network_throttling_observer.h"
#include "chrome/browser/chromeos/net/wake_on_wifi_manager.h"
#include "chrome/browser/chromeos/note_taking_helper.h"
#include "chrome/browser/chromeos/options/cert_library.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
......@@ -395,7 +394,6 @@ class DBusServices {
cryptohome::HomedirMethods::Initialize();
NetworkHandler::Initialize();
CertLibrary::Initialize();
// Initialize the network change notifier for Chrome OS. The network
// change notifier starts to monitor changes from the power manager and
......@@ -412,7 +410,6 @@ class DBusServices {
}
~DBusServices() {
CertLibrary::Shutdown();
NetworkHandler::Shutdown();
cryptohome::AsyncMethodCaller::Shutdown();
disks::DiskMountManager::Shutdown();
......
// Copyright 2013 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/chromeos/options/cert_library.h"
#include <algorithm>
#include "base/i18n/string_compare.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list_threadsafe.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h" // g_browser_process
#include "chrome/grit/generated_resources.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/login/login_state.h"
#include "chromeos/network/certificate_helper.h"
#include "chromeos/network/onc/onc_utils.h"
#include "crypto/nss_util.h"
#include "net/cert/cert_database.h"
#include "net/cert/nss_cert_database.h"
#include "net/cert/x509_util_nss.h"
#include "third_party/icu/source/i18n/unicode/coll.h" // icu::Collator
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_collator.h"
namespace chromeos {
namespace {
// Root CA certificates that are built into Chrome use this token name.
const char kRootCertificateTokenName[] = "Builtin Object Token";
base::string16 GetDisplayString(CERTCertificate* cert, bool hardware_backed) {
base::string16 issued_by =
base::UTF8ToUTF16(certificate::GetIssuerDisplayName(cert));
base::string16 issued_to =
base::UTF8ToUTF16(certificate::GetCertNameOrNickname(cert));
base::string16 issued_to_ascii =
base::UTF8ToUTF16(certificate::GetCertAsciiNameOrNickname(cert));
if (issued_to_ascii != issued_to) {
// Input contained encoded data, show original and decoded forms.
issued_to = l10n_util::GetStringFUTF16(IDS_CERT_INFO_IDN_VALUE_FORMAT,
issued_to_ascii, issued_to);
}
if (hardware_backed) {
return l10n_util::GetStringFUTF16(
IDS_CERT_MANAGER_HARDWARE_BACKED_KEY_FORMAT_LONG,
issued_by,
issued_to,
l10n_util::GetStringUTF16(IDS_CERT_MANAGER_HARDWARE_BACKED));
} else {
return l10n_util::GetStringFUTF16(
IDS_CERT_MANAGER_KEY_FORMAT_LONG,
issued_by,
issued_to);
}
}
std::string CertToPEM(CERTCertificate* cert) {
std::string pem_encoded_cert;
if (!net::x509_util::GetPEMEncoded(cert, &pem_encoded_cert)) {
LOG(ERROR) << "Couldn't PEM-encode certificate";
return std::string();
}
return pem_encoded_cert;
}
} // namespace
class CertNameComparator {
public:
explicit CertNameComparator(icu::Collator* collator)
: collator_(collator) {
}
bool operator()(const net::ScopedCERTCertificate& lhs,
const net::ScopedCERTCertificate& rhs) const {
base::string16 lhs_name = GetDisplayString(lhs.get(), false);
base::string16 rhs_name = GetDisplayString(rhs.get(), false);
if (collator_ == NULL)
return lhs_name < rhs_name;
return base::i18n::CompareString16WithCollator(*collator_, lhs_name,
rhs_name) == UCOL_LESS;
}
private:
icu::Collator* collator_;
};
static CertLibrary* g_cert_library = NULL;
// static
void CertLibrary::Initialize() {
CHECK(!g_cert_library);
g_cert_library = new CertLibrary();
}
// static
void CertLibrary::Shutdown() {
CHECK(g_cert_library);
delete g_cert_library;
g_cert_library = NULL;
}
// static
CertLibrary* CertLibrary::Get() {
CHECK(g_cert_library) << "CertLibrary::Get() called before Initialize()";
return g_cert_library;
}
// static
bool CertLibrary::IsInitialized() {
return g_cert_library;
}
CertLibrary::CertLibrary() {
CertLoader::Get()->AddObserver(this);
}
CertLibrary::~CertLibrary() {
CertLoader::Get()->RemoveObserver(this);
}
void CertLibrary::AddObserver(CertLibrary::Observer* observer) {
observer_list_.AddObserver(observer);
}
void CertLibrary::RemoveObserver(CertLibrary::Observer* observer) {
observer_list_.RemoveObserver(observer);
}
bool CertLibrary::CertificatesLoading() const {
return CertLoader::Get()->initial_load_of_any_database_running();
}
bool CertLibrary::CertificatesLoaded() const {
return CertLoader::Get()->initial_load_finished();
}
int CertLibrary::NumCertificates(CertType type) const {
const net::ScopedCERTCertificateList& cert_list =
GetCertificateListForType(type);
return static_cast<int>(cert_list.size());
}
base::string16 CertLibrary::GetCertDisplayStringAt(CertType type,
int index) const {
CERTCertificate* cert = GetCertificateAt(type, index);
bool hardware_backed = IsCertHardwareBackedAt(type, index);
return GetDisplayString(cert, hardware_backed);
}
std::string CertLibrary::GetServerCACertPEMAt(int index) const {
return CertToPEM(GetCertificateAt(CERT_TYPE_SERVER_CA, index));
}
std::string CertLibrary::GetUserCertPkcs11IdAt(int index, int* slot_id) const {
CERTCertificate* cert = GetCertificateAt(CERT_TYPE_USER, index);
return CertLoader::GetPkcs11IdAndSlotForCert(cert, slot_id);
}
bool CertLibrary::IsCertHardwareBackedAt(CertType type, int index) const {
CERTCertificate* cert = GetCertificateAt(type, index);
return CertLoader::IsCertificateHardwareBacked(cert);
}
int CertLibrary::GetServerCACertIndexByPEM(
const std::string& pem_encoded) const {
int num_certs = NumCertificates(CERT_TYPE_SERVER_CA);
for (int index = 0; index < num_certs; ++index) {
CERTCertificate* cert = GetCertificateAt(CERT_TYPE_SERVER_CA, index);
if (CertToPEM(cert) != pem_encoded)
continue;
return index;
}
return -1;
}
int CertLibrary::GetUserCertIndexByPkcs11Id(
const std::string& pkcs11_id) const {
int num_certs = NumCertificates(CERT_TYPE_USER);
for (int index = 0; index < num_certs; ++index) {
CERTCertificate* cert = GetCertificateAt(CERT_TYPE_USER, index);
int slot_id = -1;
std::string id = CertLoader::GetPkcs11IdAndSlotForCert(cert, &slot_id);
if (id == pkcs11_id)
return index;
}
return -1; // Not found.
}
void CertLibrary::OnCertificatesLoaded(
const net::ScopedCERTCertificateList& cert_list) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
VLOG(1) << "CertLibrary::OnCertificatesLoaded: " << cert_list.size();
certs_.clear();
user_certs_.clear();
server_certs_.clear();
server_ca_certs_.clear();
// Add certificates to the appropriate list.
certs_.reserve(cert_list.size());
for (const net::ScopedCERTCertificate& cert : cert_list) {
certs_.push_back(net::x509_util::DupCERTCertificate(cert.get()));
net::CertType type = certificate::GetCertType(cert.get());
switch (type) {
case net::USER_CERT:
user_certs_.push_back(net::x509_util::DupCERTCertificate(cert.get()));
break;
case net::SERVER_CERT:
server_certs_.push_back(net::x509_util::DupCERTCertificate(cert.get()));
break;
case net::CA_CERT: {
// Exclude root CA certificates that are built into Chrome.
std::string token_name = certificate::GetCertTokenName(cert.get());
if (token_name != kRootCertificateTokenName)
server_ca_certs_.push_back(
net::x509_util::DupCERTCertificate(cert.get()));
break;
}
default:
break;
}
}
// Perform locale-sensitive sorting by certificate name.
UErrorCode error = U_ZERO_ERROR;
std::unique_ptr<icu::Collator> collator(icu::Collator::createInstance(
icu::Locale(g_browser_process->GetApplicationLocale().c_str()), error));
if (U_FAILURE(error))
collator.reset();
CertNameComparator cert_name_comparator(collator.get());
std::sort(certs_.begin(), certs_.end(), cert_name_comparator);
std::sort(user_certs_.begin(), user_certs_.end(), cert_name_comparator);
std::sort(server_certs_.begin(), server_certs_.end(), cert_name_comparator);
std::sort(server_ca_certs_.begin(), server_ca_certs_.end(),
cert_name_comparator);
VLOG(1) << "certs_: " << certs_.size();
VLOG(1) << "user_certs_: " << user_certs_.size();
VLOG(1) << "server_certs_: " << server_certs_.size();
VLOG(1) << "server_ca_certs_: " << server_ca_certs_.size();
for (auto& observer : observer_list_)
observer.OnCertificatesLoaded();
}
CERTCertificate* CertLibrary::GetCertificateAt(CertType type, int index) const {
const net::ScopedCERTCertificateList& cert_list =
GetCertificateListForType(type);
DCHECK_GE(index, 0);
DCHECK_LT(index, static_cast<int>(cert_list.size()));
return cert_list[index].get();
}
const net::ScopedCERTCertificateList& CertLibrary::GetCertificateListForType(
CertType type) const {
if (type == CERT_TYPE_USER)
return user_certs_;
if (type == CERT_TYPE_SERVER)
return server_certs_;
if (type == CERT_TYPE_SERVER_CA)
return server_ca_certs_;
DCHECK(type == CERT_TYPE_DEFAULT);
return certs_;
}
} // namespace chromeos
// Copyright 2013 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_CHROMEOS_OPTIONS_CERT_LIBRARY_H_
#define CHROME_BROWSER_CHROMEOS_OPTIONS_CERT_LIBRARY_H_
#include <string>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/threading/thread_checker.h"
#include "chromeos/cert_loader.h"
#include "net/cert/scoped_nss_types.h"
namespace chromeos {
// This class is responsible for keeping track of certificates in a UI
// friendly manner. It observes CertLoader to receive certificate list
// updates and sorts them by type for the UI. All public APIs are expected
// to be called from the UI thread and are non blocking. Observers will also
// be called on the UI thread.
class CertLibrary : public CertLoader::Observer {
public:
class Observer {
public:
virtual ~Observer() {}
// Called for any Observers whenever the certificates are loaded.
virtual void OnCertificatesLoaded() = 0;
protected:
Observer() {}
private:
DISALLOW_COPY_AND_ASSIGN(Observer);
};
enum CertType {
CERT_TYPE_DEFAULT,
CERT_TYPE_USER,
CERT_TYPE_SERVER,
CERT_TYPE_SERVER_CA
};
// Manage the global instance.
static void Initialize();
static void Shutdown();
static CertLibrary* Get();
static bool IsInitialized();
// Add / Remove Observer
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
// Returns true when the certificate list has been requested but not loaded.
bool CertificatesLoading() const;
// Returns true when the certificate list has been initiailized.
bool CertificatesLoaded() const;
// Retruns the number of certificates available for |type|.
int NumCertificates(CertType type) const;
// Retreives the certificate property for |type| at |index|.
base::string16 GetCertDisplayStringAt(CertType type, int index) const;
std::string GetServerCACertPEMAt(int index) const;
std::string GetUserCertPkcs11IdAt(int index, int* slot_id) const;
bool IsCertHardwareBackedAt(CertType type, int index) const;
// Returns the index of a Certificate matching |pem_encoded| or -1 if none
// found. This function may be slow depending on the number of stored
// certificates.
// TODO(pneubeck): Either make this more efficient, asynchronous or get rid of
// it.
int GetServerCACertIndexByPEM(const std::string& pem_encoded) const;
// Same as above but for a PKCS#11 id.
int GetUserCertIndexByPkcs11Id(const std::string& pkcs11_id) const;
// CertLoader::Observer
void OnCertificatesLoaded(const net::ScopedCERTCertificateList&) override;
private:
CertLibrary();
~CertLibrary() override;
CERTCertificate* GetCertificateAt(CertType type, int index) const;
const net::ScopedCERTCertificateList& GetCertificateListForType(
CertType type) const;
base::ObserverList<CertLibrary::Observer> observer_list_;
// Sorted certificate lists
net::ScopedCERTCertificateList certs_;
net::ScopedCERTCertificateList user_certs_;
net::ScopedCERTCertificateList server_certs_;
net::ScopedCERTCertificateList server_ca_certs_;
THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(CertLibrary);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_CERT_LIBRARY_H_
This diff is collapsed.
// Copyright (c) 2012 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_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_
#include <string>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "ui/gfx/native_widget_types.h" // gfx::NativeWindow
#include "ui/views/controls/button/button.h" // views::ButtonListener
#include "ui/views/window/dialog_delegate.h"
namespace views {
class ImageView;
}
namespace chromeos {
class ChildNetworkConfigView;
class NetworkPropertyUIData;
class NetworkState;
// A dialog box for showing a password textfield.
class NetworkConfigView : public views::DialogDelegateView,
public views::ButtonListener {
public:
class Delegate {
public:
// Called when dialog "OK" button is pressed.
virtual void OnDialogAccepted() = 0;
// Called when dialog "Cancel" button is pressed.
virtual void OnDialogCancelled() = 0;
protected:
virtual ~Delegate() {}
};
// Returns true if a NetworkConfigView instance exists.
static bool HasInstance();
// Shows a network connection dialog if none is currently visible. The dialog
// is placed on the default display for new windows. Returns the dialog or
// nullptr on error.
static NetworkConfigView* ShowForNetworkId(const std::string& network_id);
// Shows a dialog to configure a new network. |type| must be a valid Shill
// 'Type' property value. Returns the dialog or nullptr on error.
static NetworkConfigView* ShowForType(const std::string& type);
// Returns corresponding native window.
gfx::NativeWindow GetNativeWindow() const;
// views::DialogDelegate methods.
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
bool Cancel() override;
bool Accept() override;
views::View* CreateExtraView() override;
views::View* GetInitiallyFocusedView() override;
// views::WidgetDelegate methods.
base::string16 GetWindowTitle() const override;
ui::ModalType GetModalType() const override;
// views::View overrides.
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// views::ButtonListener overrides.
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
void set_delegate(Delegate* delegate) {
delegate_ = delegate;
}
protected:
// views::View overrides:
void Layout() override;
gfx::Size CalculatePreferredSize() const override;
void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) override;
private:
NetworkConfigView();
~NetworkConfigView() override;
// Login dialog for known networks. Returns true if successfully created.
bool InitWithNetworkState(const NetworkState* network);
// Login dialog for new/hidden networks. Returns true if successfully created.
bool InitWithType(const std::string& type);
// Creates and shows a dialog containing this view.
void ShowDialog();
// Resets the underlying view to show advanced options.
void ShowAdvancedView();
// There's always only one child view, which will get deleted when
// NetworkConfigView gets cleaned up.
ChildNetworkConfigView* child_config_view_;
Delegate* delegate_;
// Button in lower-left corner, may be null or hidden.
views::View* advanced_button_;
DISALLOW_COPY_AND_ASSIGN(NetworkConfigView);
};
// Children of NetworkConfigView must subclass this and implement the virtual
// methods, which are called by NetworkConfigView.
class ChildNetworkConfigView : public views::View {
public:
// If |service_path| is NULL, a dialog for configuring a new network will
// be created.
ChildNetworkConfigView(NetworkConfigView* parent,
const std::string& service_path);
~ChildNetworkConfigView() override;
// Get the title to show for the dialog.
virtual base::string16 GetTitle() const = 0;
// Returns view that should be focused on dialog activation.
virtual views::View* GetInitiallyFocusedView() = 0;
// Called to determine if "Connect" button should be enabled.
virtual bool CanLogin() = 0;
// Called when "Connect" button is clicked.
// Should return false if dialog should remain open.
virtual bool Login() = 0;
// Called when "Cancel" button is clicked.
virtual void Cancel() = 0;
// Called to set focus when view is recreated with the same dialog
// being active. For example, clicking on "Advanced" button.
virtual void InitFocus() = 0;
// Returns 'true' if the dialog is for configuration only (default is false).
virtual bool IsConfigureDialog();
// Minimum width of input fields / combo boxes.
static const int kInputFieldMinWidth;
// The height of input fields /combo boxes.
static const int kInputFieldHeight;
protected:
// Gets the default network share state for the current login state.
static void GetShareStateForLoginState(bool* default_value, bool* modifiable);
NetworkConfigView* parent_;
std::string service_path_;
private:
DISALLOW_COPY_AND_ASSIGN(ChildNetworkConfigView);
};
// Shows an icon with tooltip indicating whether a setting is under policy
// control.
class ControlledSettingIndicatorView : public views::View {
public:
explicit ControlledSettingIndicatorView(const NetworkPropertyUIData& ui_data);
~ControlledSettingIndicatorView() override;
protected:
// views::View:
gfx::Size CalculatePreferredSize() const override;
private:
bool managed_;
views::ImageView* image_view_;
DISALLOW_COPY_AND_ASSIGN(ControlledSettingIndicatorView);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_
// 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/chromeos/options/network_config_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
namespace chromeos {
namespace {
using NetworkConfigViewTest = InProcessBrowserTest;
IN_PROC_BROWSER_TEST_F(NetworkConfigViewTest, ShowForType) {
// An invalid network type does not create a dialog.
EXPECT_FALSE(NetworkConfigView::ShowForType("invalid"));
// Showing the dialog creates an always-on-top widget.
NetworkConfigView* view = NetworkConfigView::ShowForType(shill::kTypeWifi);
ASSERT_TRUE(view->GetWidget());
EXPECT_TRUE(view->GetWidget()->IsVisible());
EXPECT_TRUE(view->GetWidget()->IsAlwaysOnTop());
// Showing again returns the same dialog.
NetworkConfigView* repeat = NetworkConfigView::ShowForType(shill::kTypeWifi);
EXPECT_EQ(view, repeat);
view->GetWidget()->CloseNow();
}
IN_PROC_BROWSER_TEST_F(NetworkConfigViewTest, ShowForNetworkId) {
// An invalid network ID does not create a dialog.
EXPECT_FALSE(NetworkConfigView::ShowForNetworkId("invalid"));
// Showing the dialog creates an always-on-top widget.
NetworkConfigView* view = NetworkConfigView::ShowForNetworkId("wifi1_guid");
ASSERT_TRUE(view->GetWidget());
EXPECT_TRUE(view->GetWidget()->IsVisible());
EXPECT_TRUE(view->GetWidget()->IsAlwaysOnTop());
// Showing again returns the same dialog.
NetworkConfigView* repeat = NetworkConfigView::ShowForNetworkId("wifi1_guid");
EXPECT_EQ(view, repeat);
view->GetWidget()->CloseNow();
}
} // namespace
} // namespace chromeos
// Copyright 2013 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/chromeos/options/network_property_ui_data.h"
#include "base/logging.h"
#include "base/values.h"
#include "chromeos/network/onc/onc_utils.h"
namespace chromeos {
NetworkPropertyUIData::NetworkPropertyUIData()
: onc_source_(::onc::ONC_SOURCE_NONE) {
}
NetworkPropertyUIData::NetworkPropertyUIData(::onc::ONCSource onc_source)
: onc_source_(onc_source) {
}
NetworkPropertyUIData::~NetworkPropertyUIData() {
}
void NetworkPropertyUIData::ParseOncProperty(::onc::ONCSource onc_source,
const base::DictionaryValue* onc,
const std::string& property_key) {
default_value_.reset();
onc_source_ = onc_source;
if (!onc || !IsManaged())
return;
if (!onc::IsRecommendedValue(onc, property_key))
return;
// Set onc_source_ to NONE to indicate that the value is not enforced.
onc_source_ = ::onc::ONC_SOURCE_NONE;
const base::Value* default_value = NULL;
if (!onc->Get(property_key, &default_value)) {
// No default entry indicates that the property can be modified by the user,
// but has no default value, e.g. Username or Passphrase. (The default
// behavior for a property with no entry is non user modifiable).
return;
}
// Set the recommended (default) value.
default_value_.reset(default_value->DeepCopy());
}
} // namespace chromeos
// Copyright 2013 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_CHROMEOS_OPTIONS_NETWORK_PROPERTY_UI_DATA_H_
#define CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_PROPERTY_UI_DATA_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "components/onc/onc_constants.h"
namespace base {
class DictionaryValue;
class Value;
}
namespace chromeos {
// Holds meta information for a network property: Whether the property is under
// policy control, if it is user-editable, and policy-provided default value, if
// available.
class NetworkPropertyUIData {
public:
// Initializes with ONC_SOURCE_NONE and no default value.
NetworkPropertyUIData();
// Initializes with the given |onc_source| and no default value.
explicit NetworkPropertyUIData(::onc::ONCSource onc_source);
~NetworkPropertyUIData();
// Update the property object from dictionary, reading the key given by
// |property_key|.
void ParseOncProperty(::onc::ONCSource onc_source,
const base::DictionaryValue* onc,
const std::string& property_key);
const base::Value* default_value() const { return default_value_.get(); }
bool IsManaged() const {
return (onc_source_ == ::onc::ONC_SOURCE_DEVICE_POLICY ||
onc_source_ == ::onc::ONC_SOURCE_USER_POLICY);
}
bool IsEditable() const { return !IsManaged(); }
private:
::onc::ONCSource onc_source_;
std::unique_ptr<base::Value> default_value_;
DISALLOW_COPY_AND_ASSIGN(NetworkPropertyUIData);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_PROPERTY_UI_DATA_H_
// Copyright 2013 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/chromeos/options/network_property_ui_data.h"
#include "base/values.h"
#include "components/onc/onc_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
class NetworkPropertyUIDataTest : public testing::Test {
protected:
NetworkPropertyUIDataTest() {}
~NetworkPropertyUIDataTest() override {}
void CheckProperty(const NetworkPropertyUIData& property,
const base::Value* expected_default_value,
bool expected_managed,
bool expected_editable) {
if (expected_default_value) {
EXPECT_EQ(*expected_default_value, *property.default_value());
} else {
EXPECT_FALSE(property.default_value());
}
EXPECT_EQ(expected_managed, property.IsManaged());
EXPECT_EQ(expected_editable, property.IsEditable());
}
};
TEST_F(NetworkPropertyUIDataTest, PropertyInit) {
NetworkPropertyUIData empty_prop;
CheckProperty(empty_prop, NULL, false, true);
NetworkPropertyUIData null_prop(onc::ONC_SOURCE_NONE);
CheckProperty(null_prop, NULL, false, true);
}
TEST_F(NetworkPropertyUIDataTest, ParseOncProperty) {
base::DictionaryValue onc;
base::Value val_a("a");
base::Value val_b("b");
base::Value val_a_a("a_a");
base::Value val_a_b("a_b");
onc.Set("a", val_a.CreateDeepCopy());
onc.Set("b", val_b.CreateDeepCopy());
onc.Set("a.a", val_a_a.CreateDeepCopy());
onc.Set("a.b", val_a_b.CreateDeepCopy());
base::ListValue recommended;
recommended.AppendString("b");
recommended.AppendString("c");
recommended.AppendString("a.a");
onc.Set("Recommended", recommended.CreateDeepCopy());
onc.Set("a.Recommended", recommended.CreateDeepCopy());
NetworkPropertyUIData prop;
prop.ParseOncProperty(onc::ONC_SOURCE_NONE, &onc, "a");
CheckProperty(prop, NULL, false, true);
onc::ONCSource source = onc::ONC_SOURCE_USER_IMPORT;
prop.ParseOncProperty(source, &onc, "a");
CheckProperty(prop, NULL, false, true);
prop.ParseOncProperty(source, &onc, "a.b");
CheckProperty(prop, NULL, false, true);
prop.ParseOncProperty(source, &onc, "c");
CheckProperty(prop, NULL, false, true);
source = onc::ONC_SOURCE_USER_POLICY;
prop.ParseOncProperty(source, &onc, "a");
CheckProperty(prop, NULL, true, false);
prop.ParseOncProperty(source, &onc, "b");
CheckProperty(prop, &val_b, false, true);
prop.ParseOncProperty(source, &onc, "c");
CheckProperty(prop, NULL, false, true);
prop.ParseOncProperty(source, &onc, "d");
CheckProperty(prop, NULL, true, false);
prop.ParseOncProperty(source, &onc, "a.a");
CheckProperty(prop, NULL, true, false);
prop.ParseOncProperty(source, &onc, "a.b");
CheckProperty(prop, &val_a_b, false, true);
prop.ParseOncProperty(source, &onc, "a.c");
CheckProperty(prop, NULL, false, true);
prop.ParseOncProperty(source, &onc, "a.d");
CheckProperty(prop, NULL, true, false);
prop.ParseOncProperty(source, NULL, "a.e");
CheckProperty(prop, NULL, true, false);
}
} // namespace chromeos
This diff is collapsed.
// Copyright (c) 2012 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_CHROMEOS_OPTIONS_VPN_CONFIG_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_OPTIONS_VPN_CONFIG_VIEW_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "chrome/browser/chromeos/options/cert_library.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
#include "chrome/browser/chromeos/options/network_property_ui_data.h"
#include "chrome/browser/chromeos/options/passphrase_textfield.h"
#include "chromeos/network/client_cert_util.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/combobox/combobox_listener.h"
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/view.h"
namespace base {
class DictionaryValue;
}
namespace views {
class Checkbox;
class Label;
}
namespace chromeos {
namespace internal {
class ProviderTypeComboboxModel;
class VpnServerCACertComboboxModel;
class VpnUserCertComboboxModel;
}
// A dialog box to allow configuration of VPN connection.
class VPNConfigView : public ChildNetworkConfigView,
public views::TextfieldController,
public views::ButtonListener,
public views::ComboboxListener,
public CertLibrary::Observer {
public:
VPNConfigView(NetworkConfigView* parent, const std::string& service_path);
~VPNConfigView() override;
// views::TextfieldController:
void ContentsChanged(views::Textfield* sender,
const base::string16& new_contents) override;
bool HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::ComboboxListener:
void OnPerformAction(views::Combobox* combobox) override;
// CertLibrary::Observer:
void OnCertificatesLoaded() override;
// ChildNetworkConfigView:
base::string16 GetTitle() const override;
views::View* GetInitiallyFocusedView() override;
bool CanLogin() override;
bool Login() override;
void Cancel() override;
void InitFocus() override;
private:
// Initializes data members and create UI controls.
void Init();
// Callback to initialize fields from uncached network properties.
void InitFromProperties(const std::string& service_path,
const base::DictionaryValue& dictionary);
void GetPropertiesError(const std::string& error_name,
std::unique_ptr<base::DictionaryValue> error_data);
// Fill in |properties| with the properties for the selected client (user)
// certificate or empty properties if no client cert is required.
void SetUserCertProperties(chromeos::client_cert::ConfigType client_cert_type,
base::DictionaryValue* properties) const;
// Helper function to set configurable properties.
void SetConfigProperties(base::DictionaryValue* properties);
// Set and update all control values.
void Refresh();
// Update various controls.
void UpdateControlsToEnable();
void UpdateControls();
void UpdateErrorLabel();
// Update state of the Login button.
void UpdateCanLogin();
// Returns true if there is at least one user certificate installed.
bool HaveUserCerts() const;
// Returns true if there is a selected user certificate and it is valid.
bool IsUserCertValid() const;
// Get text from input field.
const std::string GetTextFromField(views::Textfield* textfield,
bool trim_whitespace) const;
// Get passphrase from input field.
const std::string GetPassphraseFromField(
PassphraseTextfield* textfield) const;
// Convenience methods to get text from input field or cached VirtualNetwork.
std::string GetService() const;
std::string GetServer() const;
std::string GetPSKPassphrase() const;
std::string GetUsername() const;
std::string GetUserPassphrase() const;
std::string GetOTP() const;
std::string GetGroupName() const;
std::string GetServerCACertPEM() const;
bool GetSaveCredentials() const;
int GetProviderTypeIndex() const;
std::string GetProviderTypeString() const;
base::string16 service_name_from_server_;
bool service_text_modified_;
// Initialized in Init():
bool enable_psk_passphrase_;
bool enable_user_cert_;
bool enable_server_ca_cert_;
bool enable_otp_;
bool enable_group_name_;
bool user_passphrase_required_;
NetworkPropertyUIData ca_cert_ui_data_;
NetworkPropertyUIData psk_passphrase_ui_data_;
NetworkPropertyUIData user_cert_ui_data_;
NetworkPropertyUIData username_ui_data_;
NetworkPropertyUIData user_passphrase_ui_data_;
NetworkPropertyUIData group_name_ui_data_;
NetworkPropertyUIData save_credentials_ui_data_;
int title_;
views::Textfield* server_textfield_;
views::Label* service_text_;
views::Textfield* service_textfield_;
std::unique_ptr<internal::ProviderTypeComboboxModel>
provider_type_combobox_model_;
views::Combobox* provider_type_combobox_;
views::Label* provider_type_text_label_;
views::Label* psk_passphrase_label_;
PassphraseTextfield* psk_passphrase_textfield_;
views::Label* user_cert_label_;
std::unique_ptr<internal::VpnUserCertComboboxModel> user_cert_combobox_model_;
views::Combobox* user_cert_combobox_;
views::Label* server_ca_cert_label_;
std::unique_ptr<internal::VpnServerCACertComboboxModel>
server_ca_cert_combobox_model_;
views::Combobox* server_ca_cert_combobox_;
views::Textfield* username_textfield_;
PassphraseTextfield* user_passphrase_textfield_;
views::Label* otp_label_;
views::Textfield* otp_textfield_;
views::Label* group_name_label_;
views::Textfield* group_name_textfield_;
views::Checkbox* save_credentials_checkbox_;
views::Label* error_label_;
// Cached VPN properties, only set when configuring an existing network.
int provider_type_index_;
std::string ca_cert_pem_;
std::string client_cert_id_;
base::WeakPtrFactory<VPNConfigView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(VPNConfigView);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_VPN_CONFIG_VIEW_H_
This diff is collapsed.
// Copyright (c) 2012 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_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/chromeos/options/cert_library.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
#include "chrome/browser/chromeos/options/network_property_ui_data.h"
#include "chromeos/network/network_state_handler_observer.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/models/combobox_model.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/combobox/combobox_listener.h"
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/view.h"
namespace views {
class Checkbox;
class Label;
class ToggleImageButton;
}
namespace chromeos {
class NetworkState;
class PassphraseTextfield;
namespace internal {
class EAPMethodComboboxModel;
class Phase2AuthComboboxModel;
class SecurityComboboxModel;
class ServerCACertComboboxModel;
class UserCertComboboxModel;
}
// A dialog box for configuring Wifi and Ethernet networks
class WifiConfigView : public ChildNetworkConfigView,
public views::TextfieldController,
public views::ButtonListener,
public views::ComboboxListener,
public CertLibrary::Observer,
public NetworkStateHandlerObserver {
public:
// If |service_path| is not empty it identifies the network to be configured.
// Otherwise |show_8021x| determines whether or not to show the 'advanced'
// 8021x configuration UI for a hidden WiFi network.
WifiConfigView(NetworkConfigView* parent,
const std::string& service_path,
bool show_8021x);
~WifiConfigView() override;
// views::TextfieldController
void ContentsChanged(views::Textfield* sender,
const base::string16& new_contents) override;
bool HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) override;
// views::ButtonListener
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::ComboboxListener
void OnPerformAction(views::Combobox* combobox) override;
// CertLibrary::Observer
void OnCertificatesLoaded() override;
// ChildNetworkConfigView
base::string16 GetTitle() const override;
views::View* GetInitiallyFocusedView() override;
bool CanLogin() override;
bool Login() override;
void Cancel() override;
void InitFocus() override;
bool IsConfigureDialog() override;
// NetworkStateHandlerObserver
void NetworkPropertiesUpdated(const NetworkState* network) override;
// Parses a UI |property| from the ONC associated with |network|. |key|
// is the property name within the ONC dictionary.
static void ParseUIProperty(NetworkPropertyUIData* property_ui_data,
const NetworkState* network,
const std::string& key);
// Parses an EAP UI |property| from the ONC associated with |network|.
// |key| is the property name within the ONC EAP dictionary.
static void ParseEAPUIProperty(NetworkPropertyUIData* property_ui_data,
const NetworkState* network,
const std::string& key);
private:
friend class internal::UserCertComboboxModel;
// This will initialize the view depending on whether an existing network
// is being configured, the type of network, and the security model (i.e.
// simple password encryption or 802.1x).
void Init(bool show_8021x);
// Callback to initialize fields from uncached network properties.
void InitFromProperties(bool show_8021x,
const std::string& service_path,
const base::DictionaryValue& dictionary);
// Get input values.
std::string GetSsid() const;
std::string GetPassphrase() const;
bool GetSaveCredentials() const;
bool GetShareNetwork(bool share_default) const;
// Get various 802.1X EAP values from the widgets.
std::string GetEapMethod() const;
std::string GetEapPhase2Auth() const;
std::string GetEapServerCaCertPEM() const;
bool GetEapUseSystemCas() const;
std::string GetEapSubjectMatch() const;
std::string GetEapIdentity() const;
std::string GetEapAnonymousIdentity() const;
// Fill in |properties| with the properties for the selected client
// certificate or empty properties if no client cert is required.
void SetEapClientCertProperties(base::DictionaryValue* properties) const;
// Fill in |properties| with the appropriate values. If |configured| is
// true then this is for an already configured network.
void SetEapProperties(base::DictionaryValue* properties,
bool configured);
// Returns true if the EAP method requires a user certificate.
bool UserCertRequired() const;
// Returns true if at least one user certificate is installed.
bool HaveUserCerts() const;
// Returns true if there is a selected user certificate and it is valid.
bool IsUserCertValid() const;
// Returns true if the phase 2 auth is relevant.
bool Phase2AuthActive() const;
// Returns whether the current configuration requires a passphrase.
bool PassphraseActive() const;
// Returns true if a user cert should be selected.
bool UserCertActive() const;
// Returns true if the user cert is managed but could not be found.
bool ManagedUserCertNotFound() const { return managed_user_cert_not_found_; }
// Returns true if a CA cert selection should be allowed.
bool CaCertActive() const;
// Updates state of the Login button.
void UpdateDialogButtons();
// Enable/Disable EAP fields as appropriate based on selected EAP method.
void RefreshEapFields();
// Enable/Disable "share this network" checkbox.
void RefreshShareCheckbox();
// Updates the error text label.
void UpdateErrorLabel();
// Helper method, returns NULL if |service_path_| is empty, otherwise returns
// the NetworkState* associated with |service_path_| or NULL if none exists.
const NetworkState* GetNetworkState() const;
NetworkPropertyUIData eap_method_ui_data_;
NetworkPropertyUIData phase_2_auth_ui_data_;
NetworkPropertyUIData user_cert_ui_data_;
NetworkPropertyUIData server_ca_cert_ui_data_;
NetworkPropertyUIData identity_ui_data_;
NetworkPropertyUIData identity_anonymous_ui_data_;
NetworkPropertyUIData save_credentials_ui_data_;
NetworkPropertyUIData passphrase_ui_data_;
views::Textfield* ssid_textfield_;
std::unique_ptr<internal::EAPMethodComboboxModel> eap_method_combobox_model_;
views::Combobox* eap_method_combobox_;
views::Label* phase_2_auth_label_;
std::unique_ptr<internal::Phase2AuthComboboxModel>
phase_2_auth_combobox_model_;
views::Combobox* phase_2_auth_combobox_;
views::Label* user_cert_label_;
std::unique_ptr<internal::UserCertComboboxModel> user_cert_combobox_model_;
views::Combobox* user_cert_combobox_;
views::Label* server_ca_cert_label_;
std::unique_ptr<internal::ServerCACertComboboxModel>
server_ca_cert_combobox_model_;
views::Combobox* server_ca_cert_combobox_;
views::Label* subject_match_label_;
views::Textfield* subject_match_textfield_;
views::Label* identity_label_;
views::Textfield* identity_textfield_;
views::Label* identity_anonymous_label_;
views::Textfield* identity_anonymous_textfield_;
views::Checkbox* save_credentials_checkbox_;
views::Checkbox* share_network_checkbox_;
std::unique_ptr<internal::SecurityComboboxModel> security_combobox_model_;
views::Combobox* security_combobox_;
views::Label* passphrase_label_;
PassphraseTextfield* passphrase_textfield_;
views::ToggleImageButton* passphrase_visible_button_;
views::Label* error_label_;
// Indicates that the user certificate is managed by policy (not editable),
// but the policy-specified certificate has not been found.
bool managed_user_cert_not_found_ = false;
base::WeakPtrFactory<WifiConfigView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WifiConfigView);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
This diff is collapsed.
// Copyright (c) 2012 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_CHROMEOS_OPTIONS_WIMAX_CONFIG_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_OPTIONS_WIMAX_CONFIG_VIEW_H_
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
#include "chrome/browser/chromeos/options/wifi_config_view.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/view.h"
namespace views {
class Checkbox;
class Label;
class ToggleImageButton;
}
namespace chromeos {
// A dialog box for showing a password textfield.
class WimaxConfigView : public ChildNetworkConfigView,
public views::TextfieldController,
public views::ButtonListener {
public:
// Configuration dialog for a WiMax network. If |service_path| is not empty
// it identifies the network to be configured.
WimaxConfigView(NetworkConfigView* parent, const std::string& service_path);
~WimaxConfigView() override;
// views::TextfieldController:
void ContentsChanged(views::Textfield* sender,
const base::string16& new_contents) override;
bool HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// ChildNetworkConfigView:
base::string16 GetTitle() const override;
views::View* GetInitiallyFocusedView() override;
bool CanLogin() override;
bool Login() override;
void Cancel() override;
void InitFocus() override;
private:
// Initializes UI.
void Init();
// Callback to initialize fields from uncached network properties.
void InitFromProperties(const std::string& service_path,
const base::DictionaryValue& dictionary);
// Get input values.
std::string GetEapIdentity() const;
std::string GetEapPassphrase() const;
bool GetSaveCredentials() const;
bool GetShareNetwork(bool share_default) const;
// Updates state of the Login button.
void UpdateDialogButtons();
// Updates the error text label.
void UpdateErrorLabel();
NetworkPropertyUIData identity_ui_data_;
NetworkPropertyUIData passphrase_ui_data_;
NetworkPropertyUIData save_credentials_ui_data_;
views::Label* identity_label_;
views::Textfield* identity_textfield_;
views::Checkbox* save_credentials_checkbox_;
views::Checkbox* share_network_checkbox_;
views::Label* passphrase_label_;
views::Textfield* passphrase_textfield_;
views::ToggleImageButton* passphrase_visible_button_;
views::Label* error_label_;
base::WeakPtrFactory<WimaxConfigView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WimaxConfigView);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_WIMAX_CONFIG_VIEW_H_
// Copyright 2014 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/chromeos/ui/mobile_config_ui.h"
#include <string>
#include "base/logging.h"
#include "chrome/browser/chromeos/mobile_config.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/singleton_tabs.h"
namespace chromeos {
namespace mobile_config_ui {
bool DisplayConfigDialog() {
MobileConfig* config = MobileConfig::GetInstance();
if (!config->IsReady()) {
LOG(ERROR) << "MobileConfig not ready";
return false;
}
const MobileConfig::LocaleConfig* locale_config = config->GetLocaleConfig();
if (!locale_config) {
LOG(ERROR) << "MobileConfig::LocaleConfig not available";
return false;
}
std::string setup_url = locale_config->setup_url();
if (setup_url.empty()) {
LOG(ERROR) << "MobileConfig setup url is empty";
return false;
}
// The mobile device will be managed by the primary user.
chrome::ScopedTabbedBrowserDisplayer displayer(
ProfileManager::GetPrimaryUserProfile());
ShowSingletonTab(displayer.browser(), GURL(setup_url));
return true;
}
} // namespace mobile_config_ui
} // namespace chromeos
// Copyright 2014 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_CHROMEOS_UI_MOBILE_CONFIG_UI_H_
#define CHROME_BROWSER_CHROMEOS_UI_MOBILE_CONFIG_UI_H_
namespace chromeos {
namespace mobile_config_ui {
// Helper function for showing the mobile config UI.
// Returns true if the dialog was displayed successfully.
bool DisplayConfigDialog();
} // namespace mobile_config_ui
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_UI_MOBILE_CONFIG_UI_H_
......@@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/options/passphrase_textfield.h"
#include "chrome/browser/chromeos/ui/passphrase_textfield.h"
#include "base/strings/utf_string_conversions.h"
namespace chromeos {
PassphraseTextfield::PassphraseTextfield()
: Textfield(),
show_fake_(false),
changed_(true) {
: Textfield(), show_fake_(false), changed_(true) {
SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
}
......@@ -43,7 +41,7 @@ std::string PassphraseTextfield::GetPassphrase() {
void PassphraseTextfield::SetFakePassphrase() {
CR_DEFINE_STATIC_LOCAL(base::string16, fake_passphrase,
(base::ASCIIToUTF16("********")));
(base::ASCIIToUTF16("********")));
SetText(fake_passphrase);
changed_ = false;
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_PASSPHRASE_TEXTFIELD_H_
#define CHROME_BROWSER_CHROMEOS_OPTIONS_PASSPHRASE_TEXTFIELD_H_
#ifndef CHROME_BROWSER_CHROMEOS_UI_PASSPHRASE_TEXTFIELD_H_
#define CHROME_BROWSER_CHROMEOS_UI_PASSPHRASE_TEXTFIELD_H_
#include <string>
......@@ -40,4 +40,4 @@ class PassphraseTextfield : public views::Textfield {
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_PASSPHRASE_TEXTFIELD_H_
#endif // CHROME_BROWSER_CHROMEOS_UI_PASSPHRASE_TEXTFIELD_H_
......@@ -10,7 +10,7 @@
#include "base/callback_helpers.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/options/passphrase_textfield.h"
#include "chrome/browser/chromeos/ui/passphrase_textfield.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
#include "chrome/grit/generated_resources.h"
......
......@@ -303,9 +303,8 @@ void AddErrorLocalizedStrings(content::WebUIDataSource* html_source) {
{NetworkConnectionHandler::kErrorPassphraseRequired,
IDS_NETWORK_ERROR_PASSPHRASE_REQUIRED},
{"networkErrorUnknown", IDS_NETWORK_ERROR_UNKNOWN},
// TODO(stevenjb): Move this id to settings_strings.grdp:
{"networkErrorNotHardwareBacked",
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED},
IDS_SETTINGS_INTERNET_NETWORK_REQUIRE_HARDWARE_BACKED},
};
for (const auto& entry : localized_strings)
html_source->AddLocalizedString(entry.name, entry.id);
......
......@@ -12,8 +12,8 @@
#include "base/memory/weak_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.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"
......@@ -205,10 +205,7 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
void AddNetwork(const base::ListValue* args) {
std::string onc_type;
args->GetString(0, &onc_type);
std::string shill_type = (onc_type == ::onc::network_type::kVPN)
? shill::kTypeVPN
: shill::kTypeWifi;
NetworkConfigView::ShowForType(shill_type);
InternetConfigDialog::ShowDialogForNetworkType(onc_type);
}
base::WeakPtrFactory<NetworkConfigMessageHandler> weak_ptr_factory_;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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