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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/time/time.h" | |
11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chromeos/login/user.h" | 13 #include "chrome/browser/chromeos/login/user.h" |
13 #include "chrome/browser/chromeos/login/user_manager.h" | 14 #include "chrome/browser/chromeos/login/user_manager.h" |
14 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 15 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
15 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" | 16 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
17 #include "chrome/browser/policy/browser_policy_connector.h" | 18 #include "chrome/browser/policy/browser_policy_connector.h" |
18 #include "chrome/browser/policy/cloud/device_management_service.h" | 19 #include "chrome/browser/policy/cloud/device_management_service.h" |
19 #include "chrome/browser/policy/cloud/resource_cache.h" | 20 #include "chrome/browser/policy/cloud/resource_cache.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
35 // File in the above directory for storing legacy user policy dmtokens. | 36 // File in the above directory for storing legacy user policy dmtokens. |
36 const base::FilePath::CharType kToken[] = FILE_PATH_LITERAL("Token"); | 37 const base::FilePath::CharType kToken[] = FILE_PATH_LITERAL("Token"); |
37 // This constant is used to build two different paths. It can be a file inside | 38 // This constant is used to build two different paths. It can be a file inside |
38 // kDeviceManagementDir where legacy user policy data is stored, and it can be | 39 // kDeviceManagementDir where legacy user policy data is stored, and it can be |
39 // a directory inside the profile directory where other resources are stored. | 40 // a directory inside the profile directory where other resources are stored. |
40 const base::FilePath::CharType kPolicy[] = FILE_PATH_LITERAL("Policy"); | 41 const base::FilePath::CharType kPolicy[] = FILE_PATH_LITERAL("Policy"); |
41 // Directory under kPolicy, in the user's profile dir, where external policy | 42 // Directory under kPolicy, in the user's profile dir, where external policy |
42 // resources are stored. | 43 // resources are stored. |
43 const base::FilePath::CharType kResourceDir[] = FILE_PATH_LITERAL("Resources"); | 44 const base::FilePath::CharType kResourceDir[] = FILE_PATH_LITERAL("Resources"); |
44 | 45 |
46 // Timeout in seconds after which to abandon the initial policy fetch and start | |
47 // the session regardless. | |
48 const int kInitialPolicyFetchTimeout = 10; | |
Andrew T Wilson (Slow)
2013/09/06 12:33:45
nit: for time values, I usually like to put the ti
Mattias Nissler (ping if slow)
2013/09/06 13:37:30
Good point, done.
| |
49 | |
45 } // namespace | 50 } // namespace |
46 | 51 |
47 // static | 52 // static |
48 UserCloudPolicyManagerFactoryChromeOS* | 53 UserCloudPolicyManagerFactoryChromeOS* |
49 UserCloudPolicyManagerFactoryChromeOS::GetInstance() { | 54 UserCloudPolicyManagerFactoryChromeOS::GetInstance() { |
50 return Singleton<UserCloudPolicyManagerFactoryChromeOS>::get(); | 55 return Singleton<UserCloudPolicyManagerFactoryChromeOS>::get(); |
51 } | 56 } |
52 | 57 |
53 // static | 58 // static |
54 UserCloudPolicyManagerChromeOS* | 59 UserCloudPolicyManagerChromeOS* |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), | 145 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), |
141 username, policy_key_dir, token_cache_file, policy_cache_file)); | 146 username, policy_key_dir, token_cache_file, policy_cache_file)); |
142 if (force_immediate_load) | 147 if (force_immediate_load) |
143 store->LoadImmediately(); | 148 store->LoadImmediately(); |
144 | 149 |
145 scoped_ptr<ResourceCache> resource_cache; | 150 scoped_ptr<ResourceCache> resource_cache; |
146 if (command_line->HasSwitch(switches::kEnableComponentCloudPolicy)) | 151 if (command_line->HasSwitch(switches::kEnableComponentCloudPolicy)) |
147 resource_cache.reset(new ResourceCache(resource_cache_dir)); | 152 resource_cache.reset(new ResourceCache(resource_cache_dir)); |
148 | 153 |
149 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( | 154 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( |
150 new UserCloudPolicyManagerChromeOS(store.PassAs<CloudPolicyStore>(), | 155 new UserCloudPolicyManagerChromeOS( |
151 resource_cache.Pass(), | 156 store.PassAs<CloudPolicyStore>(), |
152 wait_for_initial_policy)); | 157 resource_cache.Pass(), |
158 wait_for_initial_policy, | |
159 base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeout))); | |
153 manager->Init(); | 160 manager->Init(); |
154 manager->Connect(g_browser_process->local_state(), | 161 manager->Connect(g_browser_process->local_state(), |
155 device_management_service, | 162 device_management_service, |
156 g_browser_process->system_request_context(), | 163 g_browser_process->system_request_context(), |
157 affiliation); | 164 affiliation); |
158 | 165 |
159 DCHECK(managers_.find(profile) == managers_.end()); | 166 DCHECK(managers_.find(profile) == managers_.end()); |
160 managers_[profile] = manager.get(); | 167 managers_[profile] = manager.get(); |
161 return manager.Pass(); | 168 return manager.Pass(); |
162 } | 169 } |
(...skipping 15 matching lines...) Expand all Loading... | |
178 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); | 185 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); |
179 } | 186 } |
180 | 187 |
181 void UserCloudPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( | 188 void UserCloudPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( |
182 content::BrowserContext* context) {} | 189 content::BrowserContext* context) {} |
183 | 190 |
184 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( | 191 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( |
185 content::BrowserContext* context) {} | 192 content::BrowserContext* context) {} |
186 | 193 |
187 } // namespace policy | 194 } // namespace policy |
OLD | NEW |