Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/policy/browser_policy_connector.cc

Issue 12676017: Adding policy support to the new network configuration stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed clang errors. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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_updater_impl.h"
62 #include "chrome/browser/chromeos/policy/network_configuration_updater_impl_cros .h"
61 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" 63 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
62 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" 64 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h"
63 #include "chrome/browser/chromeos/settings/cros_settings.h" 65 #include "chrome/browser/chromeos/settings/cros_settings.h"
64 #include "chrome/browser/chromeos/settings/cros_settings_provider.h" 66 #include "chrome/browser/chromeos/settings/cros_settings_provider.h"
65 #include "chrome/browser/chromeos/settings/device_settings_service.h" 67 #include "chrome/browser/chromeos/settings/device_settings_service.h"
66 #include "chrome/browser/chromeos/system/statistics_provider.h" 68 #include "chrome/browser/chromeos/system/statistics_provider.h"
67 #include "chrome/browser/chromeos/system/timezone_settings.h" 69 #include "chrome/browser/chromeos/system/timezone_settings.h"
68 #include "chrome/browser/policy/cloud/resource_cache.h" 70 #include "chrome/browser/policy/cloud/resource_cache.h"
69 #include "chromeos/chromeos_switches.h" 71 #include "chromeos/chromeos_switches.h"
70 #include "chromeos/dbus/cryptohome_client.h" 72 #include "chromeos/dbus/cryptohome_client.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // initialized (unit tests). 300 // initialized (unit tests).
299 if (device_management_service_) 301 if (device_management_service_)
300 device_management_service_->ScheduleInitialization(delay_milliseconds); 302 device_management_service_->ScheduleInitialization(delay_milliseconds);
301 } 303 }
302 304
303 #if defined(OS_CHROMEOS) 305 #if defined(OS_CHROMEOS)
304 void BrowserPolicyConnector::InitializeUserPolicy( 306 void BrowserPolicyConnector::InitializeUserPolicy(
305 const std::string& user_name, 307 const std::string& user_name,
306 bool is_public_account, 308 bool is_public_account,
307 bool wait_for_policy_fetch) { 309 bool wait_for_policy_fetch) {
310 CommandLine* command_line = CommandLine::ForCurrentProcess();
311
308 // If the user is managed then importing certificates from ONC policy is 312 // If the user is managed then importing certificates from ONC policy is
309 // allowed, otherwise it's not. Update this flag once the user has signed in, 313 // allowed, otherwise it's not. Update this flag once the user has signed in,
310 // and before user policy is loaded. 314 // and before user policy is loaded.
311 GetNetworkConfigurationUpdater()->set_allow_trusted_certificates_from_policy( 315 if (!command_line->HasSwitch(
312 GetUserAffiliation(user_name) == USER_AFFILIATION_MANAGED); 316 chromeos::switches::kUseNewNetworkConfigurationHandlers)) {
317 GetNetworkConfigurationUpdater()->
318 set_allow_trusted_certificates_from_policy(
319 GetUserAffiliation(user_name) == USER_AFFILIATION_MANAGED);
320 }
313 321
314 // Re-initializing user policy is disallowed for two reasons: 322 // Re-initializing user policy is disallowed for two reasons:
315 // (a) Existing profiles may hold pointers to |user_cloud_policy_manager_|. 323 // (a) Existing profiles may hold pointers to |user_cloud_policy_manager_|.
316 // (b) Implementing UserCloudPolicyManager::IsInitializationComplete() 324 // (b) Implementing UserCloudPolicyManager::IsInitializationComplete()
317 // correctly is impossible for re-initialization. 325 // correctly is impossible for re-initialization.
318 CHECK(!user_cloud_policy_manager_); 326 CHECK(!user_cloud_policy_manager_);
319 327
320 CommandLine* command_line = CommandLine::ForCurrentProcess();
321
322 base::FilePath profile_dir; 328 base::FilePath profile_dir;
323 CHECK(PathService::Get(chrome::DIR_USER_DATA, &profile_dir)); 329 CHECK(PathService::Get(chrome::DIR_USER_DATA, &profile_dir));
324 profile_dir = profile_dir.Append( 330 profile_dir = profile_dir.Append(
325 command_line->GetSwitchValuePath(chromeos::switches::kLoginProfile)); 331 command_line->GetSwitchValuePath(chromeos::switches::kLoginProfile));
326 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); 332 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir);
327 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); 333 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy);
328 const base::FilePath token_cache_file = legacy_dir.Append(kToken); 334 const base::FilePath token_cache_file = legacy_dir.Append(kToken);
329 const base::FilePath resource_cache_dir = 335 const base::FilePath resource_cache_dir =
330 profile_dir.Append(kPolicy).Append(kResourceDir); 336 profile_dir.Append(kPolicy).Append(kResourceDir);
331 base::FilePath policy_key_dir; 337 base::FilePath policy_key_dir;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (!app_pack_updater_ && request_context_) { 396 if (!app_pack_updater_ && request_context_) {
391 app_pack_updater_.reset( 397 app_pack_updater_.reset(
392 new AppPackUpdater(request_context_, install_attributes_.get())); 398 new AppPackUpdater(request_context_, install_attributes_.get()));
393 } 399 }
394 return app_pack_updater_.get(); 400 return app_pack_updater_.get();
395 } 401 }
396 402
397 NetworkConfigurationUpdater* 403 NetworkConfigurationUpdater*
398 BrowserPolicyConnector::GetNetworkConfigurationUpdater() { 404 BrowserPolicyConnector::GetNetworkConfigurationUpdater() {
399 if (!network_configuration_updater_) { 405 if (!network_configuration_updater_) {
400 network_configuration_updater_.reset(new NetworkConfigurationUpdater( 406 CommandLine* command_line = CommandLine::ForCurrentProcess();
401 GetPolicyService(), 407 if (command_line->HasSwitch(
402 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); 408 chromeos::switches::kUseNewNetworkConfigurationHandlers)) {
409 network_configuration_updater_.reset(
410 new NetworkConfigurationUpdaterImpl(GetPolicyService()));
411 } else {
412 network_configuration_updater_.reset(
413 new NetworkConfigurationUpdaterImplCros(
414 GetPolicyService(),
415 chromeos::CrosLibrary::Get()->GetNetworkLibrary()));
416 }
403 } 417 }
404 return network_configuration_updater_.get(); 418 return network_configuration_updater_.get();
405 } 419 }
406 420
407 net::CertTrustAnchorProvider* 421 net::CertTrustAnchorProvider*
408 BrowserPolicyConnector::GetCertTrustAnchorProvider() { 422 BrowserPolicyConnector::GetCertTrustAnchorProvider() {
409 return GetNetworkConfigurationUpdater()->GetCertTrustAnchorProvider(); 423 return GetNetworkConfigurationUpdater()->GetCertTrustAnchorProvider();
410 } 424 }
411 #endif 425 #endif
412 426
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 return new AsyncPolicyProvider(loader.Pass()); 596 return new AsyncPolicyProvider(loader.Pass());
583 } else { 597 } else {
584 return NULL; 598 return NULL;
585 } 599 }
586 #else 600 #else
587 return NULL; 601 return NULL;
588 #endif 602 #endif
589 } 603 }
590 604
591 } // namespace policy 605 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698