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/policy/browser_policy_connector.h" | 5 #include "chrome/browser/policy/browser_policy_connector.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 | 215 |
216 DeviceMode BrowserPolicyConnector::GetDeviceMode() { | 216 DeviceMode BrowserPolicyConnector::GetDeviceMode() { |
217 return install_attributes_.get() ? install_attributes_->GetMode() | 217 return install_attributes_.get() ? install_attributes_->GetMode() |
218 : DEVICE_MODE_NOT_SET; | 218 : DEVICE_MODE_NOT_SET; |
219 } | 219 } |
220 #endif | 220 #endif |
221 | 221 |
222 void BrowserPolicyConnector::ScheduleServiceInitialization( | 222 void BrowserPolicyConnector::ScheduleServiceInitialization( |
223 int64 delay_milliseconds) { | 223 int64 delay_milliseconds) { |
224 device_management_service_->ScheduleInitialization(delay_milliseconds); | 224 // Skip device initialization if the BrowserPolicyConnector was never |
| 225 // initialized (unit tests). |
| 226 if (device_management_service_.get()) |
| 227 device_management_service_->ScheduleInitialization(delay_milliseconds); |
225 } | 228 } |
226 | 229 |
227 #if defined(OS_CHROMEOS) | 230 #if defined(OS_CHROMEOS) |
228 void BrowserPolicyConnector::InitializeUserPolicy( | 231 void BrowserPolicyConnector::InitializeUserPolicy( |
229 const std::string& user_name, | 232 const std::string& user_name, |
230 bool is_public_account, | 233 bool is_public_account, |
231 bool wait_for_policy_fetch) { | 234 bool wait_for_policy_fetch) { |
232 // If the user is managed then importing certificates from ONC policy is | 235 // If the user is managed then importing certificates from ONC policy is |
233 // allowed, otherwise it's not. Update this flag once the user has signed in, | 236 // allowed, otherwise it's not. Update this flag once the user has signed in, |
234 // and before user policy is loaded. | 237 // and before user policy is loaded. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 status = U_ZERO_ERROR; | 365 status = U_ZERO_ERROR; |
363 UBool match = matcher.matches(status); | 366 UBool match = matcher.matches(status); |
364 DCHECK(U_SUCCESS(status)); | 367 DCHECK(U_SUCCESS(status)); |
365 return !!match; // !! == convert from UBool to bool | 368 return !!match; // !! == convert from UBool to bool |
366 } | 369 } |
367 | 370 |
368 } // namespace | 371 } // namespace |
369 | 372 |
370 // static | 373 // static |
371 bool BrowserPolicyConnector::IsNonEnterpriseUser(const std::string& username) { | 374 bool BrowserPolicyConnector::IsNonEnterpriseUser(const std::string& username) { |
372 if (username.empty()) { | 375 if (username.empty() || username.find('@') == std::string::npos) { |
373 // This means incognito user in case of ChromiumOS and | 376 // An empty username means incognito user in case of ChromiumOS and |
374 // no logged-in user in case of Chromium (SigninService). | 377 // no logged-in user in case of Chromium (SigninService). Many tests use |
| 378 // nonsense email addresses (e.g. 'test') so treat those as non-enterprise |
| 379 // users. |
375 return true; | 380 return true; |
376 } | 381 } |
377 | 382 |
378 // Exclude many of the larger public email providers as we know these users | 383 // Exclude many of the larger public email providers as we know these users |
379 // are not from hosted enterprise domains. | 384 // are not from hosted enterprise domains. |
380 static const wchar_t* kNonManagedDomainPatterns[] = { | 385 static const wchar_t* kNonManagedDomainPatterns[] = { |
381 L"aol\\.com", | 386 L"aol\\.com", |
382 L"googlemail\\.com", | 387 L"googlemail\\.com", |
383 L"gmail\\.com", | 388 L"gmail\\.com", |
384 L"hotmail(\\.co|\\.com|)\\.[^.]+", // hotmail.com, hotmail.it, hotmail.co.uk | 389 L"hotmail(\\.co|\\.com|)\\.[^.]+", // hotmail.com, hotmail.it, hotmail.co.uk |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 return new AsyncPolicyProvider(loader.Pass()); | 525 return new AsyncPolicyProvider(loader.Pass()); |
521 } else { | 526 } else { |
522 return NULL; | 527 return NULL; |
523 } | 528 } |
524 #else | 529 #else |
525 return NULL; | 530 return NULL; |
526 #endif | 531 #endif |
527 } | 532 } |
528 | 533 |
529 } // namespace policy | 534 } // namespace policy |
OLD | NEW |