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 "chrome/browser/policy/cloud_policy_subsystem.h" | 5 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "chrome/browser/policy/cloud_policy_cache.h" | 11 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
12 #include "chrome/browser/policy/cloud_policy_controller.h" | 12 #include "chrome/browser/policy/cloud_policy_controller.h" |
13 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" | 13 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" |
14 #include "chrome/browser/policy/configuration_policy_provider.h" | 14 #include "chrome/browser/policy/configuration_policy_provider.h" |
15 #include "chrome/browser/policy/device_management_service.h" | 15 #include "chrome/browser/policy/device_management_service.h" |
16 #include "chrome/browser/policy/device_token_fetcher.h" | 16 #include "chrome/browser/policy/device_token_fetcher.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "content/common/notification_details.h" | 18 #include "content/common/notification_details.h" |
19 #include "content/common/notification_source.h" | 19 #include "content/common/notification_source.h" |
20 #include "content/common/notification_type.h" | 20 #include "content/common/notification_type.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Refresh rate sanity interval bounds. | 24 // Refresh rate sanity interval bounds. |
25 const int64 kPolicyRefreshRateMinMs = 30 * 60 * 1000; // 30 minutes | 25 const int64 kPolicyRefreshRateMinMs = 30 * 60 * 1000; // 30 minutes |
26 const int64 kPolicyRefreshRateMaxMs = 24 * 60 * 60 * 1000; // 1 day | 26 const int64 kPolicyRefreshRateMaxMs = 24 * 60 * 60 * 1000; // 1 day |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 namespace policy { | 30 namespace policy { |
31 | 31 |
32 CloudPolicySubsystem::CloudPolicySubsystem( | 32 CloudPolicySubsystem::CloudPolicySubsystem( |
33 const FilePath& policy_cache_file, | 33 CloudPolicyIdentityStrategy* identity_strategy, |
34 CloudPolicyIdentityStrategy* identity_strategy) | 34 CloudPolicyCacheBase* policy_cache) |
35 : prefs_(NULL) { | 35 : prefs_(NULL) { |
36 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 36 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
37 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 37 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
38 device_management_service_.reset(new DeviceManagementService( | 38 device_management_service_.reset(new DeviceManagementService( |
39 command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl))); | 39 command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl))); |
40 cloud_policy_cache_.reset(new CloudPolicyCache(policy_cache_file)); | 40 cloud_policy_cache_.reset(policy_cache); |
41 cloud_policy_cache_->LoadFromFile(); | 41 cloud_policy_cache_->Load(); |
42 | 42 |
43 device_token_fetcher_.reset( | 43 device_token_fetcher_.reset( |
44 new DeviceTokenFetcher(device_management_service_.get(), | 44 new DeviceTokenFetcher(device_management_service_.get(), |
45 cloud_policy_cache_.get())); | 45 cloud_policy_cache_.get())); |
46 | 46 |
47 cloud_policy_controller_.reset( | 47 cloud_policy_controller_.reset( |
48 new CloudPolicyController(cloud_policy_cache_.get(), | 48 new CloudPolicyController(cloud_policy_cache_.get(), |
49 device_management_service_->CreateBackend(), | 49 device_management_service_->CreateBackend(), |
50 device_token_fetcher_.get(), | 50 device_token_fetcher_.get(), |
51 identity_strategy)); | 51 identity_strategy)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 policy_refresh_rate_.GetPrefName() == | 115 policy_refresh_rate_.GetPrefName() == |
116 *(Details<std::string>(details).ptr()) && | 116 *(Details<std::string>(details).ptr()) && |
117 prefs_ == Source<PrefService>(source).ptr()) { | 117 prefs_ == Source<PrefService>(source).ptr()) { |
118 UpdatePolicyRefreshRate(); | 118 UpdatePolicyRefreshRate(); |
119 } else { | 119 } else { |
120 NOTREACHED(); | 120 NOTREACHED(); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 } // namespace policy | 124 } // namespace policy |
OLD | NEW |