Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 const base::FilePath::CharType kComponentsDir[] = | 57 const base::FilePath::CharType kComponentsDir[] = |
| 58 FILE_PATH_LITERAL("Components"); | 58 FILE_PATH_LITERAL("Components"); |
| 59 | 59 |
| 60 // Directory in which to store external policy data. This is specified relative | 60 // Directory in which to store external policy data. This is specified relative |
| 61 // to kPolicy. | 61 // to kPolicy. |
| 62 const base::FilePath::CharType kPolicyExternalDataDir[] = | 62 const base::FilePath::CharType kPolicyExternalDataDir[] = |
| 63 FILE_PATH_LITERAL("External Data"); | 63 FILE_PATH_LITERAL("External Data"); |
| 64 | 64 |
| 65 // Timeout in seconds after which to abandon the initial policy fetch and start | 65 // Timeout in seconds after which to abandon the initial policy fetch and start |
| 66 // the session regardless. | 66 // the session regardless. |
| 67 const int kInitialPolicyFetchTimeoutSeconds = 10; | 67 const int kInitialPolicyFetchTimeoutSeconds = 60; |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 // static | 71 // static |
| 72 UserCloudPolicyManagerFactoryChromeOS* | 72 UserCloudPolicyManagerFactoryChromeOS* |
| 73 UserCloudPolicyManagerFactoryChromeOS::GetInstance() { | 73 UserCloudPolicyManagerFactoryChromeOS::GetInstance() { |
| 74 return Singleton<UserCloudPolicyManagerFactoryChromeOS>::get(); | 74 return Singleton<UserCloudPolicyManagerFactoryChromeOS>::get(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // static | 77 // static |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 // DeviceLocalAccountPolicyService. | 135 // DeviceLocalAccountPolicyService. |
| 136 const std::string& username = user->email(); | 136 const std::string& username = user->email(); |
| 137 if (user->GetType() != chromeos::User::USER_TYPE_REGULAR || | 137 if (user->GetType() != chromeos::User::USER_TYPE_REGULAR || |
| 138 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { | 138 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { |
| 139 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); | 139 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 policy::BrowserPolicyConnectorChromeOS* connector = | 142 policy::BrowserPolicyConnectorChromeOS* connector = |
| 143 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 143 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 144 UserAffiliation affiliation = connector->GetUserAffiliation(username); | 144 UserAffiliation affiliation = connector->GetUserAffiliation(username); |
| 145 const bool is_managed_user = affiliation == USER_AFFILIATION_MANAGED; | 145 const bool is_first_login = user_manager->IsCurrentUserNew(); |
| 146 const bool is_browser_restart = | 146 const bool is_browser_restart = |
| 147 command_line->HasSwitch(chromeos::switches::kLoginUser) && | 147 command_line->HasSwitch(chromeos::switches::kLoginUser) && |
| 148 !command_line->HasSwitch(chromeos::switches::kLoginPassword); | 148 !command_line->HasSwitch(chromeos::switches::kLoginPassword); |
| 149 const bool wait_for_initial_policy = is_managed_user && !is_browser_restart; | 149 const bool wait_for_initial_policy = is_first_login && !is_browser_restart; |
| 150 DCHECK(!BrowserPolicyConnector::IsNonEnterpriseUser(username)); | |
|
bartfab (slow)
2014/06/16 09:37:27
Nit: Instead of a DCHECK here, better add a commen
Andrew T Wilson (Slow)
2014/06/16 12:34:58
+1 to this. I didn't understand this check either.
| |
| 150 | 151 |
| 151 DeviceManagementService* device_management_service = | 152 DeviceManagementService* device_management_service = |
| 152 connector->device_management_service(); | 153 connector->device_management_service(); |
| 153 if (wait_for_initial_policy) | 154 if (wait_for_initial_policy) |
| 154 device_management_service->ScheduleInitialization(0); | 155 device_management_service->ScheduleInitialization(0); |
| 155 | 156 |
| 156 base::FilePath profile_dir = profile->GetPath(); | 157 base::FilePath profile_dir = profile->GetPath(); |
| 157 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); | 158 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); |
| 158 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); | 159 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); |
| 159 const base::FilePath token_cache_file = legacy_dir.Append(kToken); | 160 const base::FilePath token_cache_file = legacy_dir.Append(kToken); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); | 238 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); |
| 238 } | 239 } |
| 239 | 240 |
| 240 void UserCloudPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( | 241 void UserCloudPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( |
| 241 content::BrowserContext* context) {} | 242 content::BrowserContext* context) {} |
| 242 | 243 |
| 243 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( | 244 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( |
| 244 content::BrowserContext* context) {} | 245 content::BrowserContext* context) {} |
| 245 | 246 |
| 246 } // namespace policy | 247 } // namespace policy |
| OLD | NEW |