summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-30 21:22:22 +0000
committermihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-30 21:22:22 +0000
commit4e941444e96c7c1748456ea7643d91829f1ccc4f (patch)
treee4cf769360bf37583c1c20efd373acedf6e9cfd0
parent69353119ad3b0266db545d0f0203c235bec6589f (diff)
downloadchromium_src-4e941444e96c7c1748456ea7643d91829f1ccc4f.zip
chromium_src-4e941444e96c7c1748456ea7643d91829f1ccc4f.tar.gz
chromium_src-4e941444e96c7c1748456ea7643d91829f1ccc4f.tar.bz2
Revert 129915 - This adds a dialog that allows the user to enroll a certificate
when they try to connect to a network that uses a certificate pattern. It opens a modal dialog with a website (configured from ONC) where they are able to obtain a new network certificate. BUG=chromium-os:19409 TEST=Ran on device and on chrome for chromeos on linux. Review URL: https://chromiumcodereview.appspot.com/9809008 TBR=gspencer@chromium.org Review URL: https://chromiumcodereview.appspot.com/9963031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129939 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/cros/network_library.cc64
-rw-r--r--chrome/browser/chromeos/cros/network_library.h85
-rw-r--r--chrome/browser/chromeos/cros/network_library_impl_base.cc19
-rw-r--r--chrome/browser/chromeos/cros/network_library_impl_stub.cc24
-rw-r--r--chrome/browser/chromeos/cros/network_library_unittest.cc48
-rw-r--r--chrome/browser/chromeos/enrollment_dialog_view.cc251
-rw-r--r--chrome/browser/chromeos/enrollment_dialog_view.h64
-rw-r--r--chrome/browser/chromeos/options/vpn_config_view.cc5
-rw-r--r--chrome/browser/chromeos/options/wifi_config_view.cc5
-rw-r--r--chrome/browser/chromeos/status/network_menu.cc7
-rw-r--r--chrome/browser/ui/webui/net_internals/net_internals_ui.cc13
-rw-r--r--chrome/chrome_browser.gypi2
12 files changed, 99 insertions, 488 deletions
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc
index ba3db0f..1d2d304 100644
--- a/chrome/browser/chromeos/cros/network_library.cc
+++ b/chrome/browser/chromeos/cros/network_library.cc
@@ -520,8 +520,7 @@ VirtualNetwork::VirtualNetwork(const std::string& service_path)
provider_type_(PROVIDER_TYPE_L2TP_IPSEC_PSK),
// Assume PSK and user passphrase are not available initially
psk_passphrase_required_(true),
- user_passphrase_required_(true),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_pointer_factory_(this)) {
+ user_passphrase_required_(true) {
}
VirtualNetwork::~VirtualNetwork() {}
@@ -542,11 +541,11 @@ bool VirtualNetwork::RequiresUserProfile() const {
return true;
}
-void VirtualNetwork::AttemptConnection(const base::Closure& connect) {
+void VirtualNetwork::AttemptConnection(const base::Closure& closure) {
if (client_cert_type() == CLIENT_CERT_TYPE_PATTERN) {
- MatchCertificatePattern(true, connect);
+ MatchCertificatePattern(closure);
} else {
- connect.Run();
+ closure.Run();
}
}
@@ -700,12 +699,11 @@ void VirtualNetwork::SetCertificateSlotAndPin(
}
}
-void VirtualNetwork::MatchCertificatePattern(bool allow_enroll,
- const base::Closure& connect) {
+void VirtualNetwork::MatchCertificatePattern(const base::Closure& closure) {
DCHECK(client_cert_type() == CLIENT_CERT_TYPE_PATTERN);
DCHECK(!client_cert_pattern().Empty());
if (client_cert_pattern().Empty()) {
- connect.Run();
+ closure.Run();
return;
}
@@ -722,23 +720,15 @@ void VirtualNetwork::MatchCertificatePattern(bool allow_enroll,
client_cert_id, &client_cert_id_);
}
} else {
- if (allow_enroll && enrollment_delegate()) {
- // Wrap the closure in another callback so that we can retry the
- // certificate match again before actually connecting.
- base::Closure wrapped_connect =
- base::Bind(&VirtualNetwork::MatchCertificatePattern,
- weak_pointer_factory_.GetWeakPtr(),
- false,
- connect);
-
- enrollment_delegate()->Enroll(client_cert_pattern().enrollment_uri_list(),
- wrapped_connect);
- // Enrollment delegate will take care of running the closure at the
+ if (enrollment_handler()) {
+ enrollment_handler()->Enroll(client_cert_pattern().enrollment_uri_list(),
+ closure);
+ // Enrollment handler will take care of running the closure at the
// appropriate time, if the user doesn't cancel.
return;
}
}
- connect.Run();
+ closure.Run();
}
////////////////////////////////////////////////////////////////////////////////
@@ -1166,8 +1156,7 @@ WifiNetwork::WifiNetwork(const std::string& service_path)
eap_method_(EAP_METHOD_UNKNOWN),
eap_phase_2_auth_(EAP_PHASE_2_AUTH_AUTO),
eap_use_system_cas_(true),
- eap_save_credentials_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_pointer_factory_(this)) {
+ eap_save_credentials_(false) {
}
WifiNetwork::~WifiNetwork() {}
@@ -1414,11 +1403,11 @@ bool WifiNetwork::RequiresUserProfile() const {
return true;
}
-void WifiNetwork::AttemptConnection(const base::Closure& connect) {
+void WifiNetwork::AttemptConnection(const base::Closure& closure) {
if (client_cert_type() == CLIENT_CERT_TYPE_PATTERN) {
- MatchCertificatePattern(true, connect);
+ MatchCertificatePattern(closure);
} else {
- connect.Run();
+ closure.Run();
}
}
@@ -1426,12 +1415,11 @@ void WifiNetwork::SetCertificatePin(const std::string& pin) {
SetOrClearStringProperty(flimflam::kEapPinProperty, pin, NULL);
}
-void WifiNetwork::MatchCertificatePattern(bool allow_enroll,
- const base::Closure& connect) {
+void WifiNetwork::MatchCertificatePattern(const base::Closure& closure) {
DCHECK(client_cert_type() == CLIENT_CERT_TYPE_PATTERN);
DCHECK(!client_cert_pattern().Empty());
if (client_cert_pattern().Empty()) {
- connect.Run();
+ closure.Run();
return;
}
@@ -1441,23 +1429,15 @@ void WifiNetwork::MatchCertificatePattern(bool allow_enroll,
SetEAPClientCertPkcs11Id(
x509_certificate_model::GetPkcs11Id(matching_cert->os_cert_handle()));
} else {
- if (allow_enroll && enrollment_delegate()) {
- // Wrap the closure in another callback so that we can retry the
- // certificate match again before actually connecting.
- base::Closure wrapped_connect =
- base::Bind(&WifiNetwork::MatchCertificatePattern,
- weak_pointer_factory_.GetWeakPtr(),
- false,
- connect);
-
- enrollment_delegate()->Enroll(client_cert_pattern().enrollment_uri_list(),
- wrapped_connect);
- // Enrollment delegate should take care of running the closure at the
+ if (enrollment_handler()) {
+ enrollment_handler()->Enroll(client_cert_pattern().enrollment_uri_list(),
+ closure);
+ // Enrollment handler should take care of running the closure at the
// appropriate time, if the user doesn't cancel.
return;
}
}
- connect.Run();
+ closure.Run();
}
// static
diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h
index 441aecd..cb978d4 100644
--- a/chrome/browser/chromeos/cros/network_library.h
+++ b/chrome/browser/chromeos/cros/network_library.h
@@ -15,7 +15,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/singleton.h"
-#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/string16.h"
#include "base/timer.h"
@@ -279,30 +278,30 @@ class NetworkDevice {
DISALLOW_COPY_AND_ASSIGN(NetworkDevice);
};
-// A virtual class that can be used to handle certificate enrollment URIs when
-// encountered. Also used by unit tests to avoid opening browser windows
-// when testing.
-class EnrollmentDelegate {
- public:
- EnrollmentDelegate() {}
- virtual ~EnrollmentDelegate() {}
-
- // Implemented to handle a given certificate enrollment URI. Returns false
- // if the enrollment URI doesn't use a scheme that we can handle, and in
- // that case, this will be called for any remaining enrollment URIs.
- // If enrollment succeeds, then the enrollment handler must run
- // |post_action| to finish connecting.
- virtual void Enroll(const std::vector<std::string>& uri_list,
- const base::Closure& post_action) = 0;
- private:
- DISALLOW_COPY_AND_ASSIGN(EnrollmentDelegate);
-};
-
// Contains data common to all network service types.
class Network {
public:
virtual ~Network();
+ // A virtual class that can be used to handle certificate enrollment URIs when
+ // encountered. Also used by unit tests to avoid opening browser windows
+ // when testing.
+ class EnrollmentHandler {
+ public:
+ EnrollmentHandler() {}
+ virtual ~EnrollmentHandler() {}
+
+ // Implemented to handle a given certificate enrollment URI. Returns false
+ // if the enrollment URI doesn't use a scheme that we can handle, and in
+ // that case, this will be called for any remaining enrollment URIs.
+ // If enrollment succeeds, then the enrollment handler must run
+ // |post_action| to finish connecting.
+ virtual void Enroll(const std::vector<std::string>& uri_list,
+ const base::Closure& post_action) = 0;
+ private:
+ DISALLOW_COPY_AND_ASSIGN(EnrollmentHandler);
+ };
+
// Test API for accessing setters in tests.
class TestApi {
public:
@@ -429,8 +428,8 @@ class Network {
// Adopts the given enrollment handler to handle any certificate enrollment
// URIs encountered during network connection.
- void SetEnrollmentDelegate(EnrollmentDelegate* delegate) {
- enrollment_delegate_.reset(delegate);
+ void SetEnrollmentHandler(EnrollmentHandler* handler) {
+ enrollment_handler_.reset(handler);
}
virtual bool UpdateStatus(const std::string& key,
@@ -486,8 +485,8 @@ class Network {
return ui_data_.certificate_type();
}
- EnrollmentDelegate* enrollment_delegate() const {
- return enrollment_delegate_.get();
+ EnrollmentHandler* enrollment_handler() const {
+ return enrollment_handler_.get();
}
private:
@@ -513,8 +512,6 @@ class Network {
TestLoadWifiCertificatePattern);
FRIEND_TEST_ALL_PREFIXES(OncNetworkParserTest,
TestLoadVPNCertificatePattern);
- FRIEND_TEST_ALL_PREFIXES(NetworkLibraryStubTest, NetworkConnectOncWifi);
- FRIEND_TEST_ALL_PREFIXES(NetworkLibraryStubTest, NetworkConnectOncVPN);
// Use these functions at your peril. They are used by the various
// parsers to set state, and really shouldn't be used by anything else
@@ -567,7 +564,7 @@ class Network {
bool save_credentials_; // save passphrase and EAP credentials to disk.
std::string proxy_config_; // ProxyConfig property in flimflam.
ProxyOncConfig proxy_onc_config_; // Only used for parsing ONC proxy value.
- scoped_ptr<EnrollmentDelegate> enrollment_delegate_;
+ scoped_ptr<EnrollmentHandler> enrollment_handler_;
// Unique identifier, set the first time the network is parsed.
std::string unique_id_;
@@ -722,14 +719,12 @@ class VirtualNetwork : public Network {
group_name_ = group_name;
}
- // Matches the client certificate pattern by checking to see if a certificate
- // exists that meets the pattern criteria. If it finds one, it sets the
- // appropriate network property. If not, it passes |connect| to the
- // EnrollmentDelegate to do something with the enrollment URI (e.g. launch a
- // dialog) to install the certificate, and then invoke |connect|. If
- // |allow_enroll| is false, then the enrollment handler will not be invoked in
- // the case of a missing certificate.
- void MatchCertificatePattern(bool allow_enroll, const base::Closure& connect);
+ // Matches the client certificate pattern by checking to see if a
+ // certificate exists that meets the pattern criteria. If it finds one,
+ // it sets the appropriate network property. If not, it passes |connect| to
+ // the EnrollmentHandler to do something with the enrollment URI (e.g. launch
+ // a dialog) to install the certificate, and then invoke |connect|.
+ void MatchCertificatePattern(const base::Closure& connect);
// Network overrides.
virtual void EraseCredentials() OVERRIDE;
@@ -751,9 +746,6 @@ class VirtualNetwork : public Network {
bool user_passphrase_required_;
std::string group_name_;
- // Weak pointer factory for wrapping pointers to this network in callbacks.
- base::WeakPtrFactory<VirtualNetwork> weak_pointer_factory_;
-
DISALLOW_COPY_AND_ASSIGN(VirtualNetwork);
};
typedef std::vector<VirtualNetwork*> VirtualNetworkVector;
@@ -1078,14 +1070,12 @@ class WifiNetwork : public WirelessNetwork {
eap_save_credentials_ = save_credentials;
}
- // Matches the client certificate pattern by checking to see if a certificate
- // exists that meets the pattern criteria. If it finds one, it sets the
- // appropriate network property. If not, it passes |connect| to the
- // EnrollmentDelegate to do something with the enrollment URI (e.g. launch a
- // dialog) to install the certificate, and then invoke |connect|. If
- // |allow_enroll| is false, then the enrollment handler will not be invoked in
- // the case of a missing certificate.
- void MatchCertificatePattern(bool allow_enroll, const base::Closure& connect);
+ // Matches the client certificate pattern by checking to see if a
+ // certificate exists that meets the pattern criteria. If it finds one,
+ // it sets the appropriate network property. If not, it passes |connect| to
+ // the EnrollmentHandler to do something with the enrollment URI (e.g. launch
+ // a dialog) to install the certificate, and then invoke |connect|.
+ void MatchCertificatePattern(const base::Closure& connect);
// Network overrides.
virtual void EraseCredentials() OVERRIDE;
@@ -1110,9 +1100,6 @@ class WifiNetwork : public WirelessNetwork {
// Passphrase set by user (stored for UI).
std::string user_passphrase_;
- // Weak pointer factory for wrapping pointers to this network in callbacks.
- base::WeakPtrFactory<WifiNetwork> weak_pointer_factory_;
-
DISALLOW_COPY_AND_ASSIGN(WifiNetwork);
};
typedef std::vector<WifiNetwork*> WifiNetworkVector;
diff --git a/chrome/browser/chromeos/cros/network_library_impl_base.cc b/chrome/browser/chromeos/cros/network_library_impl_base.cc
index 45afacc..f1ecc03 100644
--- a/chrome/browser/chromeos/cros/network_library_impl_base.cc
+++ b/chrome/browser/chromeos/cros/network_library_impl_base.cc
@@ -735,6 +735,16 @@ void NetworkLibraryImplBase::NetworkConnectStartWifi(
std::string tpm_pin = GetTpmPin();
if (!tpm_pin.empty())
wifi->SetCertificatePin(tpm_pin);
+
+ // For certificate patterns, we have to delay the connect start.
+ if (wifi->client_cert_type() == CLIENT_CERT_TYPE_PATTERN) {
+ wifi->MatchCertificatePattern(
+ base::Bind(&NetworkLibraryImplBase::NetworkConnectStart,
+ notify_manager_weak_factory_.GetWeakPtr(),
+ wifi,
+ profile_type));
+ return;
+ }
}
NetworkConnectStart(wifi, profile_type);
}
@@ -748,6 +758,15 @@ void NetworkLibraryImplBase::NetworkConnectStartVPN(VirtualNetwork* vpn) {
std::string tpm_slot = GetTpmSlot();
vpn->SetCertificateSlotAndPin(tpm_slot, tpm_pin);
}
+ // Resolve any certificate pattern.
+ if (vpn->client_cert_type() == CLIENT_CERT_TYPE_PATTERN) {
+ vpn->MatchCertificatePattern(
+ base::Bind(&NetworkLibraryImplBase::NetworkConnectStart,
+ notify_manager_weak_factory_.GetWeakPtr(),
+ vpn,
+ PROFILE_NONE));
+ return;
+ }
NetworkConnectStart(vpn, PROFILE_NONE);
}
diff --git a/chrome/browser/chromeos/cros/network_library_impl_stub.cc b/chrome/browser/chromeos/cros/network_library_impl_stub.cc
index c2e6f74..fbb8bf2 100644
--- a/chrome/browser/chromeos/cros/network_library_impl_stub.cc
+++ b/chrome/browser/chromeos/cros/network_library_impl_stub.cc
@@ -100,28 +100,6 @@ void NetworkLibraryImplStub::Init() {
wifi3->set_passphrase_required(true);
AddStubNetwork(wifi3, PROFILE_USER);
- WifiNetwork* wifi_cert_pattern = new WifiNetwork("wifi_cert_pattern");
- wifi_cert_pattern->set_name("Fake WiFi CertPattern 802.1x");
- wifi_cert_pattern->set_strength(50);
- wifi_cert_pattern->set_connectable(false);
- wifi_cert_pattern->set_encryption(SECURITY_8021X);
- wifi_cert_pattern->SetEAPMethod(EAP_METHOD_TLS);
- wifi_cert_pattern->SetEAPUseSystemCAs(true);
- wifi_cert_pattern->SetEAPIdentity("user@example.com");
- wifi_cert_pattern->SetEAPPhase2Auth(EAP_PHASE_2_AUTH_AUTO);
- wifi_cert_pattern->set_client_cert_type(CLIENT_CERT_TYPE_PATTERN);
- CertificatePattern pattern;
- IssuerSubjectPattern subject;
- subject.set_organization("Google Inc");
- pattern.set_subject(subject);
- std::vector<std::string> enrollment_uris;
- enrollment_uris.push_back("http://www.google.com/chromebook");
- pattern.set_enrollment_uri_list(enrollment_uris);
- wifi_cert_pattern->set_client_cert_pattern(pattern);
- wifi_cert_pattern->set_eap_save_credentials(true);
-
- AddStubNetwork(wifi_cert_pattern, PROFILE_USER);
-
WifiNetwork* wifi4 = new WifiNetwork("wifi4");
wifi4->set_name("Fake WiFi4 802.1x");
wifi4->set_strength(50);
@@ -589,7 +567,7 @@ bool NetworkLibraryImplStub::IsCellularAlwaysInRoaming() {
}
void NetworkLibraryImplStub::RequestNetworkScan() {
- // This is triggered by user interaction, so set a network connect delay.
+ // This is triggered by user interaction, so set a network conenct delay.
const int kConnectDelayMs = 4 * 1000;
connect_delay_ms_ = kConnectDelayMs;
SignalNetworkManagerObservers();
diff --git a/chrome/browser/chromeos/cros/network_library_unittest.cc b/chrome/browser/chromeos/cros/network_library_unittest.cc
index ddbe1fd..07e6f82 100644
--- a/chrome/browser/chromeos/cros/network_library_unittest.cc
+++ b/chrome/browser/chromeos/cros/network_library_unittest.cc
@@ -37,9 +37,9 @@ int32 GetPrefixLength(std::string netmask) {
}
// Have to do a stub here because MOCK can't handle closure arguments.
-class StubEnrollmentDelegate : public EnrollmentDelegate {
+class StubEnrollmentHandler : public Network::EnrollmentHandler {
public:
- explicit StubEnrollmentDelegate(OncNetworkParser* parser)
+ explicit StubEnrollmentHandler(OncNetworkParser* parser)
: did_enroll(false), correct_args(false), parser_(parser) {}
void Enroll(const std::vector<std::string>& uri_list,
@@ -66,14 +66,6 @@ class StubEnrollmentDelegate : public EnrollmentDelegate {
OncNetworkParser* parser_;
};
-void WifiNetworkConnectCallback(NetworkLibrary* cros, WifiNetwork* wifi) {
- cros->ConnectToWifiNetwork(wifi);
-}
-
-void VirtualNetworkConnectCallback(NetworkLibrary* cros, VirtualNetwork* vpn) {
- cros->ConnectToVirtualNetwork(vpn);
-}
-
} // namespace
TEST(NetworkLibraryTest, NetmaskToPrefixlen) {
@@ -354,25 +346,23 @@ TEST_F(NetworkLibraryStubTest, NetworkConnectOncWifi) {
EXPECT_EQ(2, parser.GetCertificatesSize());
scoped_ptr<Network> network(parser.ParseNetwork(0));
ASSERT_TRUE(network.get());
- EXPECT_EQ(CLIENT_CERT_TYPE_PATTERN, network->client_cert_type());
- StubEnrollmentDelegate* enrollment_delegate =
- new StubEnrollmentDelegate(&parser);
+ StubEnrollmentHandler* enrollment_handler =
+ new StubEnrollmentHandler(&parser);
- network->SetEnrollmentDelegate(enrollment_delegate);
- EXPECT_FALSE(enrollment_delegate->did_enroll);
- EXPECT_FALSE(enrollment_delegate->correct_args);
+ network->SetEnrollmentHandler(enrollment_handler);
+ EXPECT_FALSE(enrollment_handler->did_enroll);
+ EXPECT_FALSE(enrollment_handler->correct_args);
WifiNetwork* wifi1 = static_cast<WifiNetwork*>(network.get());
ASSERT_NE(static_cast<const WifiNetwork*>(NULL), wifi1);
EXPECT_FALSE(wifi1->connected());
EXPECT_TRUE(cros_->CanConnectToNetwork(wifi1));
EXPECT_FALSE(wifi1->connected());
- wifi1->AttemptConnection(
- base::Bind(&WifiNetworkConnectCallback, cros_, wifi1));
+ cros_->ConnectToWifiNetwork(wifi1);
EXPECT_TRUE(wifi1->connected());
- EXPECT_TRUE(enrollment_delegate->did_enroll);
- EXPECT_TRUE(enrollment_delegate->correct_args);
+ EXPECT_TRUE(enrollment_handler->did_enroll);
+ EXPECT_TRUE(enrollment_handler->correct_args);
}
TEST_F(NetworkLibraryStubTest, NetworkConnectOncVPN) {
@@ -385,25 +375,23 @@ TEST_F(NetworkLibraryStubTest, NetworkConnectOncVPN) {
EXPECT_EQ(2, parser.GetCertificatesSize());
scoped_ptr<Network> network(parser.ParseNetwork(0));
ASSERT_TRUE(network.get());
- EXPECT_EQ(CLIENT_CERT_TYPE_PATTERN, network->client_cert_type());
- StubEnrollmentDelegate* enrollment_delegate =
- new StubEnrollmentDelegate(&parser);
+ StubEnrollmentHandler* enrollment_handler =
+ new StubEnrollmentHandler(&parser);
- network->SetEnrollmentDelegate(enrollment_delegate);
- EXPECT_FALSE(enrollment_delegate->did_enroll);
- EXPECT_FALSE(enrollment_delegate->correct_args);
+ network->SetEnrollmentHandler(enrollment_handler);
+ EXPECT_FALSE(enrollment_handler->did_enroll);
+ EXPECT_FALSE(enrollment_handler->correct_args);
VirtualNetwork* vpn1 = static_cast<VirtualNetwork*>(network.get());
ASSERT_NE(static_cast<const VirtualNetwork*>(NULL), vpn1);
EXPECT_FALSE(vpn1->connected());
EXPECT_TRUE(cros_->CanConnectToNetwork(vpn1));
EXPECT_FALSE(vpn1->connected());
- vpn1->AttemptConnection(
- base::Bind(&VirtualNetworkConnectCallback, cros_, vpn1));
+ cros_->ConnectToVirtualNetwork(vpn1);
EXPECT_TRUE(vpn1->connected());
- EXPECT_TRUE(enrollment_delegate->did_enroll);
- EXPECT_TRUE(enrollment_delegate->correct_args);
+ EXPECT_TRUE(enrollment_handler->did_enroll);
+ EXPECT_TRUE(enrollment_handler->correct_args);
}
TEST_F(NetworkLibraryStubTest, NetworkConnectVPN) {
diff --git a/chrome/browser/chromeos/enrollment_dialog_view.cc b/chrome/browser/chromeos/enrollment_dialog_view.cc
deleted file mode 100644
index 868f08d..0000000
--- a/chrome/browser/chromeos/enrollment_dialog_view.cc
+++ /dev/null
@@ -1,251 +0,0 @@
-// 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.
-
-#include "chrome/browser/chromeos/enrollment_dialog_view.h"
-
-#include "base/bind.h"
-#include "chrome/browser/chromeos/cros/network_library.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/themes/theme_service.h"
-#include "chrome/browser/ui/views/dom_view.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/views/border.h"
-#include "ui/views/controls/label.h"
-#include "ui/views/layout/grid_layout.h"
-#include "ui/views/layout/layout_constants.h"
-#include "ui/views/widget/widget.h"
-
-using views::Border;
-using views::ColumnSet;
-using views::GridLayout;
-using views::Label;
-using views::LayoutManager;
-using views::View;
-
-namespace chromeos {
-
-namespace {
-
-// Default width/height of the dialog.
-const int kDefaultWidth = 640;
-const int kDefaultHeight = 480;
-
-// Border around the DOMView
-const int kDOMBorderWidth = 1;
-
-// TODO(gspencer): Move this into ui/views/layout, perhaps just adding insets
-// to FillLayout.
-class BorderLayout : public LayoutManager {
- public:
- explicit BorderLayout(const gfx::Insets& insets) : insets_(insets) {}
- virtual ~BorderLayout() {}
-
- // Overridden from LayoutManager:
- virtual void Layout(View* host) OVERRIDE {
- if (!host->has_children())
- return;
-
- View* frame_view = host->child_at(0);
- frame_view->SetBounds(insets_.left(),
- insets_.top(),
- host->width() - insets_.right() - insets_.left(),
- host->height() - insets_.bottom() - insets_.top());
- }
-
- virtual gfx::Size GetPreferredSize(View* host) OVERRIDE {
- DCHECK_EQ(1, host->child_count());
- gfx::Size child_size = host->child_at(0)->GetPreferredSize();
- child_size.Enlarge(insets_.left() + insets_.right(),
- insets_.top() + insets_.bottom());
- return child_size;
- }
-
- private:
- gfx::Insets insets_;
- DISALLOW_COPY_AND_ASSIGN(BorderLayout);
-};
-
-// Handler for certificate enrollment. This displays the content from the
-// certificate enrollment URI and listens for a certificate to be added. If a
-// certificate is added, then it invokes the closure to allow the network to
-// continue to connect.
-class DialogEnrollmentDelegate : public EnrollmentDelegate {
- public:
- // |owning_window| is the window that will own the dialog.
- explicit DialogEnrollmentDelegate(gfx::NativeWindow owning_window);
- virtual ~DialogEnrollmentDelegate();
-
- // EnrollmentDelegate overrides
- virtual void Enroll(const std::vector<std::string>& uri_list,
- const base::Closure& connect) OVERRIDE;
-
- private:
- gfx::NativeWindow owning_window_;
-
- DISALLOW_COPY_AND_ASSIGN(DialogEnrollmentDelegate);
-};
-
-DialogEnrollmentDelegate::DialogEnrollmentDelegate(
- gfx::NativeWindow owning_window)
- : owning_window_(owning_window) {}
-
-DialogEnrollmentDelegate::~DialogEnrollmentDelegate() {}
-
-void DialogEnrollmentDelegate::Enroll(const std::vector<std::string>& uri_list,
- const base::Closure& connect) {
- // Keep the closure for later activation if we notice that
- // a certificate has been added.
- for (std::vector<std::string>::const_iterator iter = uri_list.begin();
- iter != uri_list.end(); ++iter) {
- GURL uri(*iter);
- if (uri.IsStandard() || uri.scheme() == "chrome-extension") {
- // If this is a "standard" scheme, like http, ftp, etc., then open that in
- // the enrollment dialog. If this is a chrome extension, then just open
- // that extension in a tab and let it provide any UI that it needs to
- // complete.
- EnrollmentDialogView::ShowDialog(owning_window_, uri, connect);
- return;
- }
- }
- // If we didn't find a scheme we could handle, then don't continue connecting.
- // TODO(gspencer): provide a path to display this failure to the user.
- VLOG(1) << "Couldn't find usable scheme in enrollment URI(s)";
-}
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// EnrollmentDialogView implementation.
-
-EnrollmentDialogView::EnrollmentDialogView(const GURL& target_uri,
- const base::Closure& connect)
- : target_uri_(target_uri),
- connect_(connect),
- added_cert_(false) {
- net::CertDatabase::AddObserver(this);
-}
-
-EnrollmentDialogView::~EnrollmentDialogView() {
- net::CertDatabase::RemoveObserver(this);
-}
-
-// static
-EnrollmentDelegate* EnrollmentDialogView::CreateEnrollmentDelegate(
- gfx::NativeWindow owning_window) {
- return new DialogEnrollmentDelegate(owning_window);
-}
-
-// static
-void EnrollmentDialogView::ShowDialog(gfx::NativeWindow owning_window,
- const GURL& target_uri,
- const base::Closure& connect) {
- EnrollmentDialogView* dialog_view =
- new EnrollmentDialogView(target_uri, connect);
- views::Widget::CreateWindowWithParent(dialog_view, owning_window);
- dialog_view->InitDialog();
- views::Widget* widget = dialog_view->GetWidget();
- DCHECK(widget);
- widget->Show();
-}
-
-void EnrollmentDialogView::Close() {
- GetWidget()->Close();
-}
-
-int EnrollmentDialogView::GetDialogButtons() const {
- return ui::DIALOG_BUTTON_CANCEL;
-}
-
-void EnrollmentDialogView::OnClose() {
- if (added_cert_)
- connect_.Run();
-}
-
-ui::ModalType EnrollmentDialogView::GetModalType() const {
- return ui::MODAL_TYPE_SYSTEM;
-}
-
-string16 EnrollmentDialogView::GetWindowTitle() const {
- return l10n_util::GetStringUTF16(IDS_NETWORK_ENROLLMENT_HANDLER_TITLE);
-}
-
-gfx::Size EnrollmentDialogView::GetPreferredSize() {
- return gfx::Size(kDefaultWidth, kDefaultHeight);
-}
-
-views::View* EnrollmentDialogView::GetContentsView() {
- return this;
-}
-
-void EnrollmentDialogView::OnUserCertAdded(
- const net::X509Certificate* cert) {
- added_cert_ = true;
- Close();
-}
-
-void EnrollmentDialogView::InitDialog() {
- added_cert_ = false;
- // Create the views and layout manager and set them up.
- Label* label = new Label(
- l10n_util::GetStringUTF16(
- IDS_NETWORK_ENROLLMENT_HANDLER_EMBEDDED_ENROLL));
- label->SetFont(
- ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont));
- label->SetHorizontalAlignment(Label::ALIGN_LEFT);
- label->SetMultiLine(true);
- label->SetAllowCharacterBreak(true);
-
- // In order to get a border that shows around the DOMView, we need to embed it
- // into another view because it hosts a native window that fills the view.
- View* dom_border_view = new View();
- dom_border_view->SetLayoutManager(
- new BorderLayout(gfx::Insets(kDOMBorderWidth,
- kDOMBorderWidth,
- kDOMBorderWidth,
- kDOMBorderWidth)));
- SkColor frame_color = ThemeService::GetDefaultColor(
- ThemeService::COLOR_FRAME);
- Border* border = views::Border::CreateSolidBorder(kDOMBorderWidth,
- frame_color);
- dom_border_view->set_border(border);
- DOMView* dom_view = new DOMView();
- dom_view->Init(ProfileManager::GetLastUsedProfile(), NULL);
- dom_border_view->AddChildView(dom_view);
- dom_view->SetVisible(true);
-
- GridLayout* grid_layout = GridLayout::CreatePanel(this);
- SetLayoutManager(grid_layout);
-
- views::ColumnSet* columns = grid_layout->AddColumnSet(0);
- columns->AddColumn(views::GridLayout::FILL, // Horizontal resize.
- views::GridLayout::FILL, // Vertical resize.
- 1, // Resize weight.
- views::GridLayout::USE_PREF, // Size type.
- 0, // Ignored for USE_PREF.
- 0); // Minimum size.
- // Add a column set for aligning the text when it has no icons (such as the
- // help center link).
- columns = grid_layout->AddColumnSet(1);
- columns->AddPaddingColumn(
- 0, views::kUnrelatedControlHorizontalSpacing);
- columns->AddColumn(views::GridLayout::LEADING, // Horizontal leading.
- views::GridLayout::FILL, // Vertical resize.
- 1, // Resize weight.
- views::GridLayout::USE_PREF, // Size type.
- 0, // Ignored for USE_PREF.
- 0); // Minimum size.
-
- grid_layout->StartRow(0, 0);
- grid_layout->AddView(label);
- grid_layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
- grid_layout->StartRow(100.0f, 0);
- grid_layout->AddView(dom_border_view);
- grid_layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
- grid_layout->Layout(this);
- dom_view->LoadURL(target_uri_);
-}
-
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/enrollment_dialog_view.h b/chrome/browser/chromeos/enrollment_dialog_view.h
deleted file mode 100644
index b1549c9..0000000
--- a/chrome/browser/chromeos/enrollment_dialog_view.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// 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_ENROLLMENT_DIALOG_VIEW_H_
-#define CHROME_BROWSER_CHROMEOS_ENROLLMENT_DIALOG_VIEW_H_
-#pragma once
-
-#include "base/callback.h"
-#include "googleurl/src/gurl.h"
-#include "net/base/cert_database.h"
-#include "ui/gfx/native_widget_types.h"
-#include "ui/views/window/dialog_delegate.h"
-
-namespace chromeos {
-
-class EnrollmentDelegate;
-
-// Dialog for certificate enrollment. This displays the content from the
-// certificate enrollment URI.
-class EnrollmentDialogView
- : public views::DialogDelegateView,
- public net::CertDatabase::Observer {
- public:
- virtual ~EnrollmentDialogView();
-
- static EnrollmentDelegate* CreateEnrollmentDelegate(
- gfx::NativeWindow owning_window);
-
- static void ShowDialog(gfx::NativeWindow owning_window,
- const GURL& target_uri,
- const base::Closure& connect);
- void Close();
-
- // views::DialogDelegateView overrides
- virtual int GetDialogButtons() const OVERRIDE;
- virtual void OnClose();
-
- // views::WidgetDelegate overrides
- virtual ui::ModalType GetModalType() const OVERRIDE;
- virtual string16 GetWindowTitle() const OVERRIDE;
-
- // views::View overrides
- virtual gfx::Size GetPreferredSize() OVERRIDE;
-
- // views::Widget overrides
- virtual views::View* GetContentsView() OVERRIDE;
-
- // net::CertDatabase::Observer overrides
- virtual void OnUserCertAdded(const net::X509Certificate* cert) OVERRIDE;
-
- private:
- EnrollmentDialogView(const GURL& target_uri,
- const base::Closure& connect);
- void InitDialog();
-
- GURL target_uri_;
- base::Closure connect_;
- bool added_cert_;
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_ENROLLMENT_DIALOG_VIEW_H_
diff --git a/chrome/browser/chromeos/options/vpn_config_view.cc b/chrome/browser/chromeos/options/vpn_config_view.cc
index af149ba..80317f6 100644
--- a/chrome/browser/chromeos/options/vpn_config_view.cc
+++ b/chrome/browser/chromeos/options/vpn_config_view.cc
@@ -9,7 +9,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/onc_constants.h"
-#include "chrome/browser/chromeos/enrollment_dialog_view.h"
#include "chrome/common/net/x509_certificate_model.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -25,7 +24,6 @@
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
-#include "ui/views/widget/widget.h"
namespace {
@@ -308,9 +306,6 @@ bool VPNConfigView::Login() {
case PROVIDER_TYPE_MAX:
break;
}
- vpn->SetEnrollmentDelegate(
- EnrollmentDialogView::CreateEnrollmentDelegate(
- GetWidget()->GetNativeWindow()));
cros->ConnectToVirtualNetwork(vpn);
}
// Connection failures are responsible for updating the UI, including
diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc
index d6c36bb..64f2010 100644
--- a/chrome/browser/chromeos/options/wifi_config_view.cc
+++ b/chrome/browser/chromeos/options/wifi_config_view.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/cros/onc_constants.h"
-#include "chrome/browser/chromeos/enrollment_dialog_view.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -25,7 +24,6 @@
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
-#include "ui/views/widget/widget.h"
namespace chromeos {
@@ -666,9 +664,6 @@ bool WifiConfigView::Login() {
wifi->SetPassphrase(passphrase);
}
bool share_default = (wifi->profile_type() != PROFILE_USER);
- wifi->SetEnrollmentDelegate(
- EnrollmentDialogView::CreateEnrollmentDelegate(
- GetWidget()->GetNativeWindow()));
cros->ConnectToWifiNetwork(wifi, GetShareNetwork(share_default));
// Connection failures are responsible for updating the UI, including
// reopening dialogs.
diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc
index e60f9ab..b8c8248 100644
--- a/chrome/browser/chromeos/status/network_menu.cc
+++ b/chrome/browser/chromeos/status/network_menu.cc
@@ -13,7 +13,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/choose_mobile_network_dialog.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/chromeos/enrollment_dialog_view.h"
#include "chrome/browser/chromeos/mobile_config.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
#include "chrome/browser/chromeos/sim_dialog_delegate.h"
@@ -344,9 +343,6 @@ void NetworkMenu::ConnectToNetwork(Network* network) {
if (wifi->connecting_or_connected()) {
ShowTabbedNetworkSettings(wifi);
} else {
- wifi->SetEnrollmentDelegate(
- EnrollmentDialogView::CreateEnrollmentDelegate(
- delegate()->GetNativeWindow()));
wifi->AttemptConnection(base::Bind(&NetworkMenu::DoConnect,
weak_pointer_factory_.GetWeakPtr(),
wifi));
@@ -375,9 +371,6 @@ void NetworkMenu::ConnectToNetwork(Network* network) {
if (vpn->connecting_or_connected()) {
ShowTabbedNetworkSettings(vpn);
} else {
- vpn->SetEnrollmentDelegate(
- EnrollmentDialogView::CreateEnrollmentDelegate(
- delegate()->GetNativeWindow()));
vpn->AttemptConnection(base::Bind(&NetworkMenu::DoConnect,
weak_pointer_factory_.GetWeakPtr(),
vpn));
diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
index 4d77bf8..6acd13c 100644
--- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
+++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
@@ -1255,16 +1255,9 @@ void NetInternalsMessageHandler::OnImportONCFile(const ListValue* list) {
}
std::string error;
- chromeos::NetworkLibrary* cros_network =
- chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- cros_network->LoadOncNetworks(onc_blob, passcode,
- chromeos::NetworkUIData::ONC_SOURCE_USER_IMPORT,
- &error);
-
- // Now that we've added the networks, we need to rescan them so they'll be
- // available from the menu more immediately.
- cros_network->RequestNetworkScan();
-
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
+ LoadOncNetworks(onc_blob, passcode,
+ chromeos::NetworkUIData::ONC_SOURCE_USER_IMPORT, &error);
SendJavascriptCommand("receivedONCFileParse",
Value::CreateStringValue(error));
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 198f6d3..c478247 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -516,8 +516,6 @@
'browser/chromeos/dbus/update_engine_client.h',
'browser/chromeos/disks/disk_mount_manager.cc',
'browser/chromeos/disks/disk_mount_manager.h',
- 'browser/chromeos/enrollment_dialog_view.cc',
- 'browser/chromeos/enrollment_dialog_view.h',
'browser/chromeos/enterprise_extension_observer.cc',
'browser/chromeos/enterprise_extension_observer.h',
'browser/chromeos/extensions/bluetooth_event_router.cc',