Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 5 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" | |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "chrome/browser/ui/browser_navigator.h" | 13 #include "chrome/browser/ui/browser_navigator.h" |
| 14 #include "chromeos/network/client_cert_util.h" | |
| 15 #include "chromeos/network/managed_network_configuration_handler.h" | |
| 13 #include "chromeos/network/network_event_log.h" | 16 #include "chromeos/network/network_event_log.h" |
| 14 #include "chromeos/network/network_state.h" | 17 #include "chromeos/network/network_state.h" |
| 15 #include "chromeos/network/network_state_handler.h" | 18 #include "chromeos/network/network_state_handler.h" |
| 16 #include "content/public/common/page_transition_types.h" | 19 #include "content/public/common/page_transition_types.h" |
| 17 #include "extensions/browser/extension_host.h" | 20 #include "extensions/browser/extension_host.h" |
| 18 #include "extensions/common/constants.h" | 21 #include "extensions/common/constants.h" |
| 19 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 22 #include "ui/views/layout/grid_layout.h" | 25 #include "ui/views/layout/grid_layout.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 namespace enrollment { | 263 namespace enrollment { |
| 261 | 264 |
| 262 bool CreateDialog(const std::string& service_path, | 265 bool CreateDialog(const std::string& service_path, |
| 263 gfx::NativeWindow owning_window) { | 266 gfx::NativeWindow owning_window) { |
| 264 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> | 267 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> |
| 265 GetNetworkState(service_path); | 268 GetNetworkState(service_path); |
| 266 if (!network) { | 269 if (!network) { |
| 267 NET_LOG_ERROR("Enrolling Unknown network", service_path); | 270 NET_LOG_ERROR("Enrolling Unknown network", service_path); |
| 268 return false; | 271 return false; |
| 269 } | 272 } |
| 273 Browser* browser = chrome::FindBrowserWithWindow(owning_window); | |
| 274 Profile* profile = | |
| 275 browser ? browser->profile() : ProfileManager::GetPrimaryUserProfile(); | |
| 276 std::string username_hash = ProfileHelper::GetUserIdHashFromProfile(profile); | |
| 277 | |
| 278 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | |
| 279 const base::DictionaryValue* policy = | |
| 280 NetworkHandler::Get() | |
| 281 ->managed_network_configuration_handler() | |
| 282 ->FindPolicyByGUID(username_hash, network->guid(), &onc_source); | |
| 283 | |
| 270 // We skip certificate patterns for device policy ONC so that an unmanaged | 284 // We skip certificate patterns for device policy ONC so that an unmanaged |
| 271 // user can't get to the place where a cert is presented for them | 285 // user can't get to the place where a cert is presented for them |
| 272 // involuntarily. | 286 // involuntarily. |
| 273 if (network->ui_data().onc_source() == onc::ONC_SOURCE_DEVICE_POLICY) | 287 if (!policy || onc_source == onc::ONC_SOURCE_DEVICE_POLICY) |
| 274 return false; | 288 return false; |
| 275 | 289 |
| 276 const CertificatePattern& certificate_pattern = | 290 client_cert::ClientCertConfig cert_config; |
| 277 network->ui_data().certificate_pattern(); | 291 OncToClientCertConfig(*policy, &cert_config); |
| 278 if (certificate_pattern.Empty()) { | 292 |
| 279 NET_LOG_EVENT("No certificate pattern found", service_path); | 293 if (cert_config.client_cert_type != onc::client_cert::kPattern) |
| 280 return false; | 294 return false; |
| 281 } | 295 |
| 296 if (cert_config.pattern.Empty()) | |
| 297 NET_LOG_ERROR("Certificate pattern is empty", service_path); | |
| 282 | 298 |
| 283 NET_LOG_USER("Enrolling", service_path); | 299 NET_LOG_USER("Enrolling", service_path); |
| 284 | 300 |
| 285 Browser* browser = chrome::FindBrowserWithWindow(owning_window); | |
| 286 Profile* profile = browser ? browser->profile() : | |
| 287 ProfileManager::GetPrimaryUserProfile(); | |
| 288 DialogEnrollmentDelegate* enrollment = | 301 DialogEnrollmentDelegate* enrollment = |
| 289 new DialogEnrollmentDelegate(owning_window, network->name(), profile); | 302 new DialogEnrollmentDelegate(owning_window, network->name(), profile); |
| 290 return enrollment->Enroll(certificate_pattern.enrollment_uri_list(), | 303 return enrollment->Enroll(cert_config.pattern.enrollment_uri_list(), |
|
stevenjb
2014/07/07 19:34:05
Is this valid (i.e. just an empty list) if cert_co
pneubeck (no reviews)
2014/07/09 07:51:26
Done.
Moved the check from the Enroll function to
| |
| 291 base::Bind(&EnrollmentComplete, service_path)); | 304 base::Bind(&EnrollmentComplete, service_path)); |
| 292 } | 305 } |
| 293 | 306 |
| 294 } // namespace enrollment | 307 } // namespace enrollment |
| 295 | 308 |
| 296 } // namespace chromeos | 309 } // namespace chromeos |
| OLD | NEW |