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/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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include "base/utf_string_conversions.h" | 49 #include "base/utf_string_conversions.h" |
| 50 #include "chrome/browser/chromeos/cros/cros_library.h" | 50 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 51 #include "chrome/browser/chromeos/login/user_manager.h" | 51 #include "chrome/browser/chromeos/login/user_manager.h" |
| 52 #include "chrome/browser/chromeos/settings/cros_settings.h" | 52 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 53 #include "chrome/browser/chromeos/settings/cros_settings_provider.h" | 53 #include "chrome/browser/chromeos/settings/cros_settings_provider.h" |
| 54 #include "chrome/browser/chromeos/system/statistics_provider.h" | 54 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 55 #include "chrome/browser/chromeos/system/timezone_settings.h" | 55 #include "chrome/browser/chromeos/system/timezone_settings.h" |
| 56 #include "chrome/browser/policy/app_pack_updater.h" | 56 #include "chrome/browser/policy/app_pack_updater.h" |
| 57 #include "chrome/browser/policy/cros_user_policy_cache.h" | 57 #include "chrome/browser/policy/cros_user_policy_cache.h" |
| 58 #include "chrome/browser/policy/device_policy_cache.h" | 58 #include "chrome/browser/policy/device_policy_cache.h" |
| 59 #include "chrome/browser/policy/network_configuration_updater.h" | |
| 59 #include "chromeos/dbus/dbus_thread_manager.h" | 60 #include "chromeos/dbus/dbus_thread_manager.h" |
| 60 #endif | 61 #endif |
| 61 | 62 |
| 62 using content::BrowserThread; | 63 using content::BrowserThread; |
| 63 | 64 |
| 64 namespace policy { | 65 namespace policy { |
| 65 | 66 |
| 66 namespace { | 67 namespace { |
| 67 | 68 |
| 68 // Subdirectory in the user's profile for storing user policies. | 69 // Subdirectory in the user's profile for storing user policies. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 scoped_ptr<UserCloudPolicyManager> | 172 scoped_ptr<UserCloudPolicyManager> |
| 172 BrowserPolicyConnector::CreateCloudPolicyManager(Profile* profile) { | 173 BrowserPolicyConnector::CreateCloudPolicyManager(Profile* profile) { |
| 173 scoped_ptr<UserCloudPolicyManager> manager; | 174 scoped_ptr<UserCloudPolicyManager> manager; |
| 174 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 175 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 175 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { | 176 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { |
| 176 bool wait_for_policy_fetch = false; | 177 bool wait_for_policy_fetch = false; |
| 177 #if defined(OS_CHROMEOS) | 178 #if defined(OS_CHROMEOS) |
| 178 // TODO(mnissler): Revisit once Chrome OS gains multi-profiles support. | 179 // TODO(mnissler): Revisit once Chrome OS gains multi-profiles support. |
| 179 // Don't wait for a policy fetch if there's no logged in user. | 180 // Don't wait for a policy fetch if there's no logged in user. |
| 180 if (chromeos::UserManager::Get()->IsUserLoggedIn()) { | 181 if (chromeos::UserManager::Get()->IsUserLoggedIn()) { |
| 182 std::string email = | |
| 183 chromeos::UserManager::Get()->GetLoggedInUser().email(); | |
| 181 wait_for_policy_fetch = | 184 wait_for_policy_fetch = |
| 182 g_browser_process->browser_policy_connector()->GetUserAffiliation( | 185 GetUserAffiliation(email) == USER_AFFILIATION_MANAGED; |
|
Mattias Nissler (ping if slow)
2012/09/05 11:19:05
Ah, I guess I should have refrained from publishin
| |
| 183 chromeos::UserManager::Get()->GetLoggedInUser().email()) == | |
| 184 policy::USER_AFFILIATION_MANAGED; | |
| 185 } | 186 } |
| 186 #else | 187 #else |
| 187 // On desktop, there's no way to figure out if a user is logged in yet | 188 // On desktop, there's no way to figure out if a user is logged in yet |
| 188 // because prefs are not yet initialized. So we do not block waiting for | 189 // because prefs are not yet initialized. So we do not block waiting for |
| 189 // the policy fetch to happen (because that would inhibit startup for | 190 // the policy fetch to happen (because that would inhibit startup for |
| 190 // non-signed-in users) and instead rely on the fact that a signed-in | 191 // non-signed-in users) and instead rely on the fact that a signed-in |
| 191 // profile will already have policy downloaded. If no policy is available | 192 // profile will already have policy downloaded. If no policy is available |
| 192 // (due to a previous fetch failing), the normal policy refresh mechanism | 193 // (due to a previous fetch failing), the normal policy refresh mechanism |
| 193 // will cause it to get downloaded eventually. | 194 // will cause it to get downloaded eventually. |
| 194 #endif | 195 #endif |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 if (device_cloud_policy_subsystem_.get()) { | 340 if (device_cloud_policy_subsystem_.get()) { |
| 340 device_cloud_policy_subsystem_-> | 341 device_cloud_policy_subsystem_-> |
| 341 ScheduleServiceInitialization(delay_milliseconds); | 342 ScheduleServiceInitialization(delay_milliseconds); |
| 342 } | 343 } |
| 343 #endif | 344 #endif |
| 344 } | 345 } |
| 345 | 346 |
| 346 void BrowserPolicyConnector::InitializeUserPolicy( | 347 void BrowserPolicyConnector::InitializeUserPolicy( |
| 347 const std::string& user_name, | 348 const std::string& user_name, |
| 348 bool wait_for_policy_fetch) { | 349 bool wait_for_policy_fetch) { |
| 350 #if defined(OS_CHROMEOS) | |
| 351 // If the user is managed then importing certificates from ONC policy is | |
| 352 // allowed, otherwise it's not. Update this flag once the user has signed in, | |
| 353 // and before user policy is loaded. | |
| 354 GetNetworkConfigurationUpdater()->set_allow_web_trust( | |
| 355 GetUserAffiliation(user_name) == USER_AFFILIATION_MANAGED); | |
| 356 #endif | |
| 357 | |
| 349 // Throw away the old backend. | 358 // Throw away the old backend. |
| 350 user_cloud_policy_subsystem_.reset(); | 359 user_cloud_policy_subsystem_.reset(); |
| 351 user_policy_token_cache_.reset(); | 360 user_policy_token_cache_.reset(); |
| 352 user_data_store_.reset(); | 361 user_data_store_.reset(); |
| 353 token_service_ = NULL; | 362 token_service_ = NULL; |
| 354 registrar_.RemoveAll(); | 363 registrar_.RemoveAll(); |
| 355 | 364 |
| 356 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 365 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 357 | 366 |
| 358 int64 startup_delay = | 367 int64 startup_delay = |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 g_browser_process->system_request_context(); | 487 g_browser_process->system_request_context(); |
| 479 if (request_context) | 488 if (request_context) |
| 480 app_pack_updater_.reset(new AppPackUpdater(request_context, this)); | 489 app_pack_updater_.reset(new AppPackUpdater(request_context, this)); |
| 481 } | 490 } |
| 482 return app_pack_updater_.get(); | 491 return app_pack_updater_.get(); |
| 483 #else | 492 #else |
| 484 return NULL; | 493 return NULL; |
| 485 #endif | 494 #endif |
| 486 } | 495 } |
| 487 | 496 |
| 497 NetworkConfigurationUpdater* | |
| 498 BrowserPolicyConnector::GetNetworkConfigurationUpdater() { | |
| 499 #if defined(OS_CHROMEOS) | |
| 500 if (!network_configuration_updater_.get()) { | |
| 501 network_configuration_updater_.reset(new NetworkConfigurationUpdater( | |
| 502 g_browser_process->policy_service(), | |
| 503 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); | |
| 504 } | |
| 505 return network_configuration_updater_.get(); | |
| 506 #else | |
| 507 return NULL; | |
| 508 #endif | |
| 509 } | |
| 510 | |
| 488 // static | 511 // static |
| 489 void BrowserPolicyConnector::SetPolicyProviderForTesting( | 512 void BrowserPolicyConnector::SetPolicyProviderForTesting( |
| 490 ConfigurationPolicyProvider* provider) { | 513 ConfigurationPolicyProvider* provider) { |
| 491 DCHECK(!g_testing_provider); | 514 DCHECK(!g_testing_provider); |
| 492 g_testing_provider = provider; | 515 g_testing_provider = provider; |
| 493 } | 516 } |
| 494 | 517 |
| 495 // static | 518 // static |
| 496 std::string BrowserPolicyConnector::GetDeviceManagementUrl() { | 519 std::string BrowserPolicyConnector::GetDeviceManagementUrl() { |
| 497 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 520 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 return new AsyncPolicyProvider(loader.Pass()); | 663 return new AsyncPolicyProvider(loader.Pass()); |
| 641 } else { | 664 } else { |
| 642 return NULL; | 665 return NULL; |
| 643 } | 666 } |
| 644 #else | 667 #else |
| 645 return NULL; | 668 return NULL; |
| 646 #endif | 669 #endif |
| 647 } | 670 } |
| 648 | 671 |
| 649 } // namespace policy | 672 } // namespace policy |
| OLD | NEW |