OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/offline_pages/client_policy_controller.h" | 5 #include "components/offline_pages/client_policy_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "components/offline_pages/client_namespace_constants.h" |
10 | 11 |
11 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; | 12 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; |
12 | 13 |
13 namespace offline_pages { | 14 namespace offline_pages { |
14 | 15 |
15 namespace { | |
16 // TODO(romax): These should be moved to a centralized file. | |
17 // Any changes to these well-known namespaces should also be reflected in | |
18 // OfflinePagesNamespace (histograms.xml) for consistency. | |
19 const char kBookmarkNamespace[] = "bookmark"; | |
20 const char kLastNNamespace[] = "last_n"; | |
21 } // namespace | |
22 | |
23 ClientPolicyController::ClientPolicyController() { | 16 ClientPolicyController::ClientPolicyController() { |
24 policies_.clear(); | 17 policies_.clear(); |
25 // Manually defining client policies for bookmark and last_n. | 18 // Manually defining client policies for bookmark and last_n. |
26 policies_.insert(std::make_pair( | 19 policies_.insert(std::make_pair( |
27 kBookmarkNamespace, | 20 kBookmarkNamespace, |
28 MakePolicy(kBookmarkNamespace, LifetimeType::TEMPORARY, | 21 MakePolicy(kBookmarkNamespace, LifetimeType::TEMPORARY, |
29 base::TimeDelta::FromDays(7), kUnlimitedPages))); | 22 base::TimeDelta::FromDays(7), kUnlimitedPages))); |
30 policies_.insert(std::make_pair( | 23 policies_.insert(std::make_pair( |
31 kLastNNamespace, MakePolicy(kLastNNamespace, LifetimeType::TEMPORARY, | 24 kLastNNamespace, MakePolicy(kLastNNamespace, LifetimeType::TEMPORARY, |
32 base::TimeDelta::FromDays(2), 20))); | 25 base::TimeDelta::FromDays(2), 20))); |
(...skipping 19 matching lines...) Expand all Loading... |
52 const OfflinePageClientPolicy& ClientPolicyController::GetPolicy( | 45 const OfflinePageClientPolicy& ClientPolicyController::GetPolicy( |
53 const std::string& name_space) const { | 46 const std::string& name_space) const { |
54 const auto& iter = policies_.find(name_space); | 47 const auto& iter = policies_.find(name_space); |
55 if (iter != policies_.end()) | 48 if (iter != policies_.end()) |
56 return iter->second; | 49 return iter->second; |
57 // Fallback when the namespace isn't defined. | 50 // Fallback when the namespace isn't defined. |
58 return policies_.at(kDefaultNamespace); | 51 return policies_.at(kDefaultNamespace); |
59 } | 52 } |
60 | 53 |
61 } // namespace offline_pages | 54 } // namespace offline_pages |
OLD | NEW |