| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/policy/browser_policy_connector.h" | 11 #include "chrome/browser/policy/browser_policy_connector.h" |
| 12 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 12 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 13 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 13 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 14 #include "chrome/browser/policy/profile_policy_connector.h" | 14 #include "chrome/browser/policy/profile_policy_connector.h" |
| 15 #include "chrome/browser/policy/user_policy_cache.h" | 15 #include "chrome/browser/policy/user_policy_cache.h" |
| 16 #include "chrome/browser/policy/user_policy_identity_strategy.h" | 16 #include "chrome/browser/policy/user_policy_identity_strategy.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/pref_names.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); | 24 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); |
| 24 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); | 25 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); |
| 25 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); | 26 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); |
| 26 | 27 |
| 27 const int64 kServiceInitializationStartupDelay = 2000; | 28 const int64 kServiceInitializationStartupDelay = 2000; |
| 28 | 29 |
| 29 } // namespace | 30 } // namespace |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 66 |
| 66 void ProfilePolicyConnector::ScheduleServiceInitialization( | 67 void ProfilePolicyConnector::ScheduleServiceInitialization( |
| 67 int64 delay_milliseconds) { | 68 int64 delay_milliseconds) { |
| 68 if (cloud_policy_subsystem_.get()) | 69 if (cloud_policy_subsystem_.get()) |
| 69 cloud_policy_subsystem_->ScheduleServiceInitialization(delay_milliseconds); | 70 cloud_policy_subsystem_->ScheduleServiceInitialization(delay_milliseconds); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void ProfilePolicyConnector::Initialize() { | 73 void ProfilePolicyConnector::Initialize() { |
| 73 if (identity_strategy_.get()) | 74 if (identity_strategy_.get()) |
| 74 identity_strategy_->LoadTokenCache(); | 75 identity_strategy_->LoadTokenCache(); |
| 75 if (cloud_policy_subsystem_.get()) | 76 if (cloud_policy_subsystem_.get()) { |
| 76 cloud_policy_subsystem_->Initialize(profile_->GetPrefs(), | 77 cloud_policy_subsystem_->Initialize(prefs::kUserPolicyRefreshRate, |
| 77 kServiceInitializationStartupDelay); | 78 kServiceInitializationStartupDelay); |
| 79 // Temporarily set the subsystem to listen to profile pref service, since |
| 80 // we cannot yet serve user cloud policy to |local_state| and we don't want |
| 81 // the profile reference in the subsystem. |
| 82 profile_pref_registrar_.Init(profile_->GetPrefs()); |
| 83 profile_pref_registrar_.Add(prefs::kUserPolicyRefreshRate, |
| 84 cloud_policy_subsystem_.get()); |
| 85 } |
| 78 } | 86 } |
| 79 | 87 |
| 80 void ProfilePolicyConnector::Shutdown() { | 88 void ProfilePolicyConnector::Shutdown() { |
| 81 if (cloud_policy_subsystem_.get()) | 89 if (cloud_policy_subsystem_.get()) { |
| 90 // Remove the temporary profile observer. |
| 91 profile_pref_registrar_.RemoveAll(); |
| 82 cloud_policy_subsystem_->Shutdown(); | 92 cloud_policy_subsystem_->Shutdown(); |
| 93 } |
| 83 } | 94 } |
| 84 | 95 |
| 85 ConfigurationPolicyProvider* | 96 ConfigurationPolicyProvider* |
| 86 ProfilePolicyConnector::GetManagedCloudProvider() { | 97 ProfilePolicyConnector::GetManagedCloudProvider() { |
| 87 return managed_cloud_provider_.get(); | 98 return managed_cloud_provider_.get(); |
| 88 } | 99 } |
| 89 | 100 |
| 90 ConfigurationPolicyProvider* | 101 ConfigurationPolicyProvider* |
| 91 ProfilePolicyConnector::GetRecommendedCloudProvider() { | 102 ProfilePolicyConnector::GetRecommendedCloudProvider() { |
| 92 return recommended_cloud_provider_.get(); | 103 return recommended_cloud_provider_.get(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, | 165 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, |
| 155 observer_list_, OnProviderGoingAway()); | 166 observer_list_, OnProviderGoingAway()); |
| 156 browser_registrar_.reset(); | 167 browser_registrar_.reset(); |
| 157 profile_registrar_.reset(); | 168 profile_registrar_.reset(); |
| 158 browser_policy_provider_ = NULL; | 169 browser_policy_provider_ = NULL; |
| 159 profile_policy_provider_ = NULL; | 170 profile_policy_provider_ = NULL; |
| 160 } | 171 } |
| 161 } | 172 } |
| 162 | 173 |
| 163 } // namespace policy | 174 } // namespace policy |
| OLD | NEW |