| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/offline_pages/client_policy_controller.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "base/time/time.h" |
| 10 |
| 11 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; |
| 12 |
| 13 namespace offline_pages { |
| 14 |
| 15 namespace { |
| 16 OfflinePageClientPolicy TranslateToPolicy( |
| 17 std::string name_space, |
| 18 LifetimeType lifetime_type, |
| 19 base::TimeDelta expire_period, |
| 20 int64_t page_limit) { |
| 21 return {name_space, {lifetime_type, expire_period, page_limit}}; |
| 22 } |
| 23 } |
| 24 |
| 25 ClientPolicyController& ClientPolicyController::GetInstance() { |
| 26 static ClientPolicyController instance; |
| 27 return instance; |
| 28 } |
| 29 |
| 30 OfflinePageClientPolicy ClientPolicyController::GetPolicy( |
| 31 std::string name_space) { |
| 32 const auto& iter = policies_.find(name_space); |
| 33 if (iter != policies_.end()) { |
| 34 return iter->second; |
| 35 } |
| 36 // Fallback when the namespace isn't defined. |
| 37 return kDefaultClientPolicy; |
| 38 } |
| 39 |
| 40 ClientPolicyController::ClientPolicyController() { |
| 41 policies_.clear(); |
| 42 // TODO(romax) Make here somehow more clever. |
| 43 policies_.insert(std::make_pair("bookmark", |
| 44 TranslateToPolicy("bookmark", LifetimeType::TEMPORARY, |
| 45 base::TimeDelta::FromDays(7), kUnlimitedPage))); |
| 46 policies_.insert(std::make_pair("last_n", |
| 47 TranslateToPolicy("last_n", LifetimeType::TEMPORARY, |
| 48 base::TimeDelta::FromDays(2), 20))); |
| 49 } |
| 50 |
| 51 ClientPolicyController::~ClientPolicyController() { |
| 52 } |
| 53 |
| 54 } // namespace offline_pages |
| OLD | NEW |