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

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: Addressed remaining comments of Steven. 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"
71 #include "chromeos/chromeos_switches.h"
69 #include "chromeos/dbus/cryptohome_client.h" 72 #include "chromeos/dbus/cryptohome_client.h"
70 #include "chromeos/dbus/dbus_thread_manager.h" 73 #include "chromeos/dbus/dbus_thread_manager.h"
71 #else 74 #else
72 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" 75 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h"
73 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" 76 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
74 #endif 77 #endif
75 78
76 using content::BrowserThread; 79 using content::BrowserThread;
77 80
78 namespace policy { 81 namespace policy {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // initialized (unit tests). 300 // initialized (unit tests).
298 if (device_management_service_) 301 if (device_management_service_)
299 device_management_service_->ScheduleInitialization(delay_milliseconds); 302 device_management_service_->ScheduleInitialization(delay_milliseconds);
300 } 303 }
301 304
302 #if defined(OS_CHROMEOS) 305 #if defined(OS_CHROMEOS)
303 void BrowserPolicyConnector::InitializeUserPolicy( 306 void BrowserPolicyConnector::InitializeUserPolicy(
304 const std::string& user_name, 307 const std::string& user_name,
305 bool is_public_account, 308 bool is_public_account,
306 bool wait_for_policy_fetch) { 309 bool wait_for_policy_fetch) {
310 CommandLine* command_line = CommandLine::ForCurrentProcess();
311
307 // 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
308 // 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,
309 // and before user policy is loaded. 314 // and before user policy is loaded.
310 GetNetworkConfigurationUpdater()->set_allow_trusted_certificates_from_policy( 315 if (!command_line->HasSwitch(
311 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 }
312 321
313 // Re-initializing user policy is disallowed for two reasons: 322 // Re-initializing user policy is disallowed for two reasons:
314 // (a) Existing profiles may hold pointers to |user_cloud_policy_manager_|. 323 // (a) Existing profiles may hold pointers to |user_cloud_policy_manager_|.
315 // (b) Implementing UserCloudPolicyManager::IsInitializationComplete() 324 // (b) Implementing UserCloudPolicyManager::IsInitializationComplete()
316 // correctly is impossible for re-initialization. 325 // correctly is impossible for re-initialization.
317 CHECK(!user_cloud_policy_manager_); 326 CHECK(!user_cloud_policy_manager_);
318 327
319 CommandLine* command_line = CommandLine::ForCurrentProcess();
320
321 base::FilePath profile_dir; 328 base::FilePath profile_dir;
322 CHECK(PathService::Get(chrome::DIR_USER_DATA, &profile_dir)); 329 CHECK(PathService::Get(chrome::DIR_USER_DATA, &profile_dir));
323 profile_dir = profile_dir.Append( 330 profile_dir = profile_dir.Append(
324 command_line->GetSwitchValuePath(switches::kLoginProfile)); 331 command_line->GetSwitchValuePath(switches::kLoginProfile));
325 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); 332 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir);
326 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); 333 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy);
327 const base::FilePath token_cache_file = legacy_dir.Append(kToken); 334 const base::FilePath token_cache_file = legacy_dir.Append(kToken);
328 const base::FilePath resource_cache_dir = 335 const base::FilePath resource_cache_dir =
329 profile_dir.Append(kPolicy).Append(kResourceDir); 336 profile_dir.Append(kPolicy).Append(kResourceDir);
330 base::FilePath policy_key_dir; 337 base::FilePath policy_key_dir;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (!app_pack_updater_ && request_context_) { 396 if (!app_pack_updater_ && request_context_) {
390 app_pack_updater_.reset( 397 app_pack_updater_.reset(
391 new AppPackUpdater(request_context_, install_attributes_.get())); 398 new AppPackUpdater(request_context_, install_attributes_.get()));
392 } 399 }
393 return app_pack_updater_.get(); 400 return app_pack_updater_.get();
394 } 401 }
395 402
396 NetworkConfigurationUpdater* 403 NetworkConfigurationUpdater*
397 BrowserPolicyConnector::GetNetworkConfigurationUpdater() { 404 BrowserPolicyConnector::GetNetworkConfigurationUpdater() {
398 if (!network_configuration_updater_) { 405 if (!network_configuration_updater_) {
399 network_configuration_updater_.reset(new NetworkConfigurationUpdater( 406 CommandLine* command_line = CommandLine::ForCurrentProcess();
400 GetPolicyService(), 407 if (command_line->HasSwitch(
401 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); 408 chromeos::switches::kUseNewNetworkConfigurationHandlers)) {
409 network_configuration_updater_.reset(new NetworkConfigurationUpdaterImpl(
pastarmovj 2013/04/16 11:31:18 nit: I think it will be more easily readable if yo
pneubeck (no reviews) 2013/04/16 14:56:28 Done.
410 GetPolicyService()));
411 } else {
412 network_configuration_updater_.reset(
413 new NetworkConfigurationUpdaterImplCros(
414 GetPolicyService(),
415 chromeos::CrosLibrary::Get()->GetNetworkLibrary()));
416 }
402 } 417 }
403 return network_configuration_updater_.get(); 418 return network_configuration_updater_.get();
404 } 419 }
405 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
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698