| 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/user_policy_signin_service.h" | 5 #include "chrome/browser/policy/user_policy_signin_service.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" |
| 9 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/policy/browser_policy_connector.h" | 13 #include "chrome/browser/policy/browser_policy_connector.h" |
| 13 #include "chrome/browser/policy/cloud_policy_client.h" | 14 #include "chrome/browser/policy/cloud_policy_client.h" |
| 14 #include "chrome/browser/policy/cloud_policy_service.h" | 15 #include "chrome/browser/policy/cloud_policy_service.h" |
| 15 #include "chrome/browser/policy/user_cloud_policy_manager.h" | 16 #include "chrome/browser/policy/user_cloud_policy_manager.h" |
| 16 #include "chrome/browser/policy/user_cloud_policy_manager_factory.h" | 17 #include "chrome/browser/policy/user_cloud_policy_manager_factory.h" |
| 17 #include "chrome/browser/policy/user_info_fetcher.h" | 18 #include "chrome/browser/policy/user_info_fetcher.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/signin/signin_manager.h" | 21 #include "chrome/browser/signin/signin_manager.h" |
| 20 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
| 21 #include "chrome/browser/signin/token_service.h" | 23 #include "chrome/browser/signin/token_service.h" |
| 22 #include "chrome/browser/signin/token_service_factory.h" | 24 #include "chrome/browser/signin/token_service_factory.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 25 #include "content/public/browser/notification_details.h" | 27 #include "content/public/browser/notification_details.h" |
| 26 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
| 27 #include "google_apis/gaia/gaia_constants.h" | 29 #include "google_apis/gaia/gaia_constants.h" |
| 28 #include "google_apis/gaia/gaia_urls.h" | 30 #include "google_apis/gaia/gaia_urls.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 212 |
| 211 void CloudPolicyClientRegistrationHelper::OnClientError( | 213 void CloudPolicyClientRegistrationHelper::OnClientError( |
| 212 policy::CloudPolicyClient* client) { | 214 policy::CloudPolicyClient* client) { |
| 213 DCHECK_EQ(client, client_); | 215 DCHECK_EQ(client, client_); |
| 214 RequestCompleted(); | 216 RequestCompleted(); |
| 215 } | 217 } |
| 216 | 218 |
| 217 UserPolicySigninService::UserPolicySigninService( | 219 UserPolicySigninService::UserPolicySigninService( |
| 218 Profile* profile) | 220 Profile* profile) |
| 219 : profile_(profile) { | 221 : profile_(profile) { |
| 220 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableCloudPolicyOnSignin)) | 222 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 223 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableCloudPolicyOnSignin) || |
| 224 ProfileManager::IsImportProcess(*cmd_line)) { |
| 221 return; | 225 return; |
| 226 } |
| 222 | 227 |
| 223 // Initialize/shutdown the UserCloudPolicyManager when the user signs out. | 228 // Initialize/shutdown the UserCloudPolicyManager when the user signs out. |
| 224 registrar_.Add(this, | 229 registrar_.Add(this, |
| 225 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, | 230 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
| 226 content::Source<Profile>(profile)); | 231 content::Source<Profile>(profile)); |
| 227 | 232 |
| 228 // Listen for an OAuth token to become available so we can register a client | 233 // Listen for an OAuth token to become available so we can register a client |
| 229 // if for some reason the client is not already registered (for example, if | 234 // if for some reason the client is not already registered (for example, if |
| 230 // the policy load failed during initial signin). | 235 // the policy load failed during initial signin). |
| 231 registrar_.Add(this, | 236 registrar_.Add(this, |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 // before UserCloudPolicyManager shuts down the CloudPolicyClient. | 523 // before UserCloudPolicyManager shuts down the CloudPolicyClient. |
| 519 registration_helper_.reset(); | 524 registration_helper_.reset(); |
| 520 StopObserving(); | 525 StopObserving(); |
| 521 } | 526 } |
| 522 | 527 |
| 523 UserCloudPolicyManager* UserPolicySigninService::GetManager() { | 528 UserCloudPolicyManager* UserPolicySigninService::GetManager() { |
| 524 return UserCloudPolicyManagerFactory::GetForProfile(profile_); | 529 return UserCloudPolicyManagerFactory::GetForProfile(profile_); |
| 525 } | 530 } |
| 526 | 531 |
| 527 } // namespace policy | 532 } // namespace policy |
| OLD | NEW |