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 #include "chrome/common/pref_names.h" |
21 | 21 |
| 22 #if defined(OS_CHROMEOS) |
| 23 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 24 #include "chrome/browser/policy/cros_user_policy_cache.h" |
| 25 #include "chrome/browser/policy/cros_user_policy_identity_strategy.h" |
| 26 #endif |
| 27 |
22 namespace { | 28 namespace { |
23 | 29 |
24 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); | 30 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); |
25 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); | 31 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); |
26 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); | 32 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); |
27 | 33 |
28 const int64 kServiceInitializationStartupDelay = 2000; | 34 const int64 kServiceInitializationStartupDelay = 2000; |
29 | 35 |
30 } // namespace | 36 } // namespace |
31 | 37 |
32 namespace policy { | 38 namespace policy { |
33 | 39 |
34 ProfilePolicyConnector::ProfilePolicyConnector(Profile* profile) | 40 ProfilePolicyConnector::ProfilePolicyConnector(Profile* profile) |
35 : profile_(profile) { | 41 : profile_(profile) { |
36 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 42 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
37 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 43 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
38 FilePath policy_cache_dir(profile_->GetPath()); | 44 FilePath policy_cache_dir(profile_->GetPath()); |
39 policy_cache_dir = policy_cache_dir.Append(kPolicyDir); | 45 policy_cache_dir = policy_cache_dir.Append(kPolicyDir); |
40 | 46 |
| 47 #if defined(OS_CHROMEOS) |
| 48 CrosUserPolicyIdentityStrategy* identity_strategy = |
| 49 new CrosUserPolicyIdentityStrategy(profile_); |
| 50 CloudPolicyCacheBase* policy_cache = |
| 51 new CrosUserPolicyCache(chromeos::CrosLibrary::Get()->GetLoginLibrary(), |
| 52 identity_strategy, |
| 53 policy_cache_dir.Append(kTokenCacheFile)); |
| 54 identity_strategy_.reset(identity_strategy); |
| 55 #else |
41 identity_strategy_.reset(new UserPolicyIdentityStrategy( | 56 identity_strategy_.reset(new UserPolicyIdentityStrategy( |
42 profile_, | 57 profile_, |
43 policy_cache_dir.Append(kTokenCacheFile))); | 58 policy_cache_dir.Append(kTokenCacheFile))); |
44 cloud_policy_subsystem_.reset(new CloudPolicySubsystem( | 59 CloudPolicyCacheBase* policy_cache = |
45 identity_strategy_.get(), | 60 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile)) |
46 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile)))); | 61 #endif |
| 62 cloud_policy_subsystem_.reset( |
| 63 new CloudPolicySubsystem(identity_strategy_.get(), policy_cache)); |
47 | 64 |
48 BrowserPolicyConnector* browser_connector = | 65 BrowserPolicyConnector* browser_connector = |
49 g_browser_process->browser_policy_connector(); | 66 g_browser_process->browser_policy_connector(); |
50 | 67 |
51 managed_cloud_provider_.reset(new MergingPolicyProvider( | 68 managed_cloud_provider_.reset(new MergingPolicyProvider( |
52 browser_connector->GetManagedCloudProvider(), | 69 browser_connector->GetManagedCloudProvider(), |
53 cloud_policy_subsystem_->GetManagedPolicyProvider())); | 70 cloud_policy_subsystem_->GetManagedPolicyProvider())); |
54 recommended_cloud_provider_.reset(new MergingPolicyProvider( | 71 recommended_cloud_provider_.reset(new MergingPolicyProvider( |
55 browser_connector->GetRecommendedCloudProvider(), | 72 browser_connector->GetRecommendedCloudProvider(), |
56 cloud_policy_subsystem_->GetRecommendedPolicyProvider())); | 73 cloud_policy_subsystem_->GetRecommendedPolicyProvider())); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, | 183 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, |
167 observer_list_, OnProviderGoingAway()); | 184 observer_list_, OnProviderGoingAway()); |
168 browser_registrar_.reset(); | 185 browser_registrar_.reset(); |
169 profile_registrar_.reset(); | 186 profile_registrar_.reset(); |
170 browser_policy_provider_ = NULL; | 187 browser_policy_provider_ = NULL; |
171 profile_policy_provider_ = NULL; | 188 profile_policy_provider_ = NULL; |
172 } | 189 } |
173 } | 190 } |
174 | 191 |
175 } // namespace policy | 192 } // namespace policy |
OLD | NEW |