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/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "chrome/browser/chromeos/cros/cros_library.h" | 51 #include "chrome/browser/chromeos/cros/cros_library.h" |
52 #include "chrome/browser/chromeos/login/user_manager.h" | 52 #include "chrome/browser/chromeos/login/user_manager.h" |
53 #include "chrome/browser/chromeos/policy/app_pack_updater.h" | 53 #include "chrome/browser/chromeos/policy/app_pack_updater.h" |
54 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 54 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
55 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 55 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
56 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" | 56 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" |
57 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 57 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
58 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 58 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
59 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 59 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
60 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" | 60 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" |
| 61 #include "chrome/browser/chromeos/policy/network_configuration_updater2.h" |
61 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 62 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
62 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" | 63 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
63 #include "chrome/browser/chromeos/settings/cros_settings.h" | 64 #include "chrome/browser/chromeos/settings/cros_settings.h" |
64 #include "chrome/browser/chromeos/settings/cros_settings_provider.h" | 65 #include "chrome/browser/chromeos/settings/cros_settings_provider.h" |
65 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 66 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
66 #include "chrome/browser/chromeos/system/statistics_provider.h" | 67 #include "chrome/browser/chromeos/system/statistics_provider.h" |
67 #include "chrome/browser/chromeos/system/timezone_settings.h" | 68 #include "chrome/browser/chromeos/system/timezone_settings.h" |
68 #include "chrome/browser/policy/cloud/resource_cache.h" | 69 #include "chrome/browser/policy/cloud/resource_cache.h" |
| 70 #include "chromeos/chromeos_switches.h" |
69 #include "chromeos/dbus/cryptohome_client.h" | 71 #include "chromeos/dbus/cryptohome_client.h" |
70 #include "chromeos/dbus/dbus_thread_manager.h" | 72 #include "chromeos/dbus/dbus_thread_manager.h" |
71 #else | 73 #else |
72 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" | 74 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" |
73 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 75 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
74 #endif | 76 #endif |
75 | 77 |
76 using content::BrowserThread; | 78 using content::BrowserThread; |
77 | 79 |
78 namespace policy { | 80 namespace policy { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // initialized (unit tests). | 299 // initialized (unit tests). |
298 if (device_management_service_) | 300 if (device_management_service_) |
299 device_management_service_->ScheduleInitialization(delay_milliseconds); | 301 device_management_service_->ScheduleInitialization(delay_milliseconds); |
300 } | 302 } |
301 | 303 |
302 #if defined(OS_CHROMEOS) | 304 #if defined(OS_CHROMEOS) |
303 void BrowserPolicyConnector::InitializeUserPolicy( | 305 void BrowserPolicyConnector::InitializeUserPolicy( |
304 const std::string& user_name, | 306 const std::string& user_name, |
305 bool is_public_account, | 307 bool is_public_account, |
306 bool wait_for_policy_fetch) { | 308 bool wait_for_policy_fetch) { |
| 309 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 310 |
307 // If the user is managed then importing certificates from ONC policy is | 311 // If the user is managed then importing certificates from ONC policy is |
308 // allowed, otherwise it's not. Update this flag once the user has signed in, | 312 // allowed, otherwise it's not. Update this flag once the user has signed in, |
309 // and before user policy is loaded. | 313 // and before user policy is loaded. |
310 GetNetworkConfigurationUpdater()->set_allow_trusted_certificates_from_policy( | 314 if (!command_line->HasSwitch( |
311 GetUserAffiliation(user_name) == USER_AFFILIATION_MANAGED); | 315 chromeos::switches::kUseNewNetworkConfigurationHandlers)) { |
| 316 GetNetworkConfigurationUpdater()-> |
| 317 set_allow_trusted_certificates_from_policy( |
| 318 GetUserAffiliation(user_name) == USER_AFFILIATION_MANAGED); |
| 319 } |
312 | 320 |
313 // Re-initializing user policy is disallowed for two reasons: | 321 // Re-initializing user policy is disallowed for two reasons: |
314 // (a) Existing profiles may hold pointers to |user_cloud_policy_manager_|. | 322 // (a) Existing profiles may hold pointers to |user_cloud_policy_manager_|. |
315 // (b) Implementing UserCloudPolicyManager::IsInitializationComplete() | 323 // (b) Implementing UserCloudPolicyManager::IsInitializationComplete() |
316 // correctly is impossible for re-initialization. | 324 // correctly is impossible for re-initialization. |
317 CHECK(!user_cloud_policy_manager_); | 325 CHECK(!user_cloud_policy_manager_); |
318 | 326 |
319 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
320 | |
321 base::FilePath profile_dir; | 327 base::FilePath profile_dir; |
322 CHECK(PathService::Get(chrome::DIR_USER_DATA, &profile_dir)); | 328 CHECK(PathService::Get(chrome::DIR_USER_DATA, &profile_dir)); |
323 profile_dir = profile_dir.Append( | 329 profile_dir = profile_dir.Append( |
324 command_line->GetSwitchValuePath(switches::kLoginProfile)); | 330 command_line->GetSwitchValuePath(switches::kLoginProfile)); |
325 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); | 331 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); |
326 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); | 332 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); |
327 const base::FilePath token_cache_file = legacy_dir.Append(kToken); | 333 const base::FilePath token_cache_file = legacy_dir.Append(kToken); |
328 const base::FilePath resource_cache_dir = | 334 const base::FilePath resource_cache_dir = |
329 profile_dir.Append(kPolicy).Append(kResourceDir); | 335 profile_dir.Append(kPolicy).Append(kResourceDir); |
330 base::FilePath policy_key_dir; | 336 base::FilePath policy_key_dir; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 NetworkConfigurationUpdater* | 402 NetworkConfigurationUpdater* |
397 BrowserPolicyConnector::GetNetworkConfigurationUpdater() { | 403 BrowserPolicyConnector::GetNetworkConfigurationUpdater() { |
398 if (!network_configuration_updater_) { | 404 if (!network_configuration_updater_) { |
399 network_configuration_updater_.reset(new NetworkConfigurationUpdater( | 405 network_configuration_updater_.reset(new NetworkConfigurationUpdater( |
400 GetPolicyService(), | 406 GetPolicyService(), |
401 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); | 407 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); |
402 } | 408 } |
403 return network_configuration_updater_.get(); | 409 return network_configuration_updater_.get(); |
404 } | 410 } |
405 | 411 |
| 412 NetworkConfigurationUpdater2* |
| 413 BrowserPolicyConnector::GetNetworkConfigurationUpdater2() { |
| 414 if (!network_configuration_updater2_) { |
| 415 network_configuration_updater2_.reset(new NetworkConfigurationUpdater2( |
| 416 GetPolicyService())); |
| 417 } |
| 418 return network_configuration_updater2_.get(); |
| 419 } |
| 420 |
406 net::CertTrustAnchorProvider* | 421 net::CertTrustAnchorProvider* |
407 BrowserPolicyConnector::GetCertTrustAnchorProvider() { | 422 BrowserPolicyConnector::GetCertTrustAnchorProvider() { |
408 return GetNetworkConfigurationUpdater()->GetCertTrustAnchorProvider(); | 423 return GetNetworkConfigurationUpdater()->GetCertTrustAnchorProvider(); |
409 } | 424 } |
410 #endif | 425 #endif |
411 | 426 |
412 void BrowserPolicyConnector::SetDeviceManagementServiceForTesting( | 427 void BrowserPolicyConnector::SetDeviceManagementServiceForTesting( |
413 scoped_ptr<DeviceManagementService> service) { | 428 scoped_ptr<DeviceManagementService> service) { |
414 device_management_service_ = service.Pass(); | 429 device_management_service_ = service.Pass(); |
415 } | 430 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 return new AsyncPolicyProvider(loader.Pass()); | 596 return new AsyncPolicyProvider(loader.Pass()); |
582 } else { | 597 } else { |
583 return NULL; | 598 return NULL; |
584 } | 599 } |
585 #else | 600 #else |
586 return NULL; | 601 return NULL; |
587 #endif | 602 #endif |
588 } | 603 } |
589 | 604 |
590 } // namespace policy | 605 } // namespace policy |
OLD | NEW |