| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cloud/user_policy_signin_service_base.h" | 5 #include "chrome/browser/policy/cloud/user_policy_signin_service_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 base::Bind( | 122 base::Bind( |
| 123 &UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager, | 123 &UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager, |
| 124 weak_factory_.GetWeakPtr())); | 124 weak_factory_.GetWeakPtr())); |
| 125 } else { | 125 } else { |
| 126 DVLOG(1) << "Error fetching policy: " << client->status(); | 126 DVLOG(1) << "Error fetching policy: " << client->status(); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 void UserPolicySigninServiceBase::Shutdown() { | 131 void UserPolicySigninServiceBase::Shutdown() { |
| 132 PrepareForUserCloudPolicyManagerShutdown(); |
| 133 } |
| 134 |
| 135 void UserPolicySigninServiceBase::PrepareForUserCloudPolicyManagerShutdown() { |
| 132 UserCloudPolicyManager* manager = GetManager(); | 136 UserCloudPolicyManager* manager = GetManager(); |
| 133 if (manager && manager->core()->client()) | 137 if (manager && manager->core()->client()) |
| 134 manager->core()->client()->RemoveObserver(this); | 138 manager->core()->client()->RemoveObserver(this); |
| 135 if (manager && manager->core()->service()) | 139 if (manager && manager->core()->service()) |
| 136 manager->core()->service()->RemoveObserver(this); | 140 manager->core()->service()->RemoveObserver(this); |
| 137 } | 141 } |
| 138 | 142 |
| 139 // static | 143 // static |
| 140 bool UserPolicySigninServiceBase::ShouldForceLoadPolicy() { | 144 bool UserPolicySigninServiceBase::ShouldForceLoadPolicy() { |
| 141 return CommandLine::ForCurrentProcess()->HasSwitch( | 145 return CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 manager->Connect(g_browser_process->local_state(), client.Pass()); | 227 manager->Connect(g_browser_process->local_state(), client.Pass()); |
| 224 DCHECK(manager->core()->service()); | 228 DCHECK(manager->core()->service()); |
| 225 | 229 |
| 226 // Observe the client to detect errors fetching policy. | 230 // Observe the client to detect errors fetching policy. |
| 227 manager->core()->client()->AddObserver(this); | 231 manager->core()->client()->AddObserver(this); |
| 228 // Observe the service to determine when it's initialized. | 232 // Observe the service to determine when it's initialized. |
| 229 manager->core()->service()->AddObserver(this); | 233 manager->core()->service()->AddObserver(this); |
| 230 } | 234 } |
| 231 | 235 |
| 232 void UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager() { | 236 void UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager() { |
| 233 Shutdown(); | 237 PrepareForUserCloudPolicyManagerShutdown(); |
| 234 UserCloudPolicyManager* manager = GetManager(); | 238 UserCloudPolicyManager* manager = GetManager(); |
| 235 if (manager) | 239 if (manager) |
| 236 manager->DisconnectAndRemovePolicy(); | 240 manager->DisconnectAndRemovePolicy(); |
| 237 } | 241 } |
| 238 | 242 |
| 239 UserCloudPolicyManager* UserPolicySigninServiceBase::GetManager() { | 243 UserCloudPolicyManager* UserPolicySigninServiceBase::GetManager() { |
| 240 return UserCloudPolicyManagerFactory::GetForProfile(profile_); | 244 return UserCloudPolicyManagerFactory::GetForProfile(profile_); |
| 241 } | 245 } |
| 242 | 246 |
| 243 } // namespace policy | 247 } // namespace policy |
| OLD | NEW |