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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 const OfflinePageClientPolicy& ClientPolicyController::GetPolicy( | 78 const OfflinePageClientPolicy& ClientPolicyController::GetPolicy( |
79 const std::string& name_space) const { | 79 const std::string& name_space) const { |
80 const auto& iter = policies_.find(name_space); | 80 const auto& iter = policies_.find(name_space); |
81 if (iter != policies_.end()) | 81 if (iter != policies_.end()) |
82 return iter->second; | 82 return iter->second; |
83 // Fallback when the namespace isn't defined. | 83 // Fallback when the namespace isn't defined. |
84 return policies_.at(kDefaultNamespace); | 84 return policies_.at(kDefaultNamespace); |
85 } | 85 } |
86 | 86 |
| 87 std::vector<std::string> ClientPolicyController::GetAllNamespaces() const { |
| 88 std::vector<std::string> result; |
| 89 for (const auto& policy_item : policies_) |
| 90 result.emplace_back(policy_item.first); |
| 91 |
| 92 return result; |
| 93 } |
| 94 |
87 bool ClientPolicyController::IsRemovedOnCacheReset( | 95 bool ClientPolicyController::IsRemovedOnCacheReset( |
88 const std::string& name_space) const { | 96 const std::string& name_space) const { |
89 return GetPolicy(name_space).feature_policy.is_removed_on_cache_reset; | 97 return GetPolicy(name_space).feature_policy.is_removed_on_cache_reset; |
90 } | 98 } |
91 | 99 |
92 bool ClientPolicyController::IsSupportedByDownload( | 100 bool ClientPolicyController::IsSupportedByDownload( |
93 const std::string& name_space) const { | 101 const std::string& name_space) const { |
94 return GetPolicy(name_space).feature_policy.is_supported_by_download; | 102 return GetPolicy(name_space).feature_policy.is_supported_by_download; |
95 } | 103 } |
96 | 104 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 146 |
139 show_in_original_tab_cache_ = base::MakeUnique<std::vector<std::string>>(); | 147 show_in_original_tab_cache_ = base::MakeUnique<std::vector<std::string>>(); |
140 for (const auto& policy_item : policies_) { | 148 for (const auto& policy_item : policies_) { |
141 if (policy_item.second.feature_policy.only_shown_in_original_tab) | 149 if (policy_item.second.feature_policy.only_shown_in_original_tab) |
142 show_in_original_tab_cache_->emplace_back(policy_item.first); | 150 show_in_original_tab_cache_->emplace_back(policy_item.first); |
143 } | 151 } |
144 | 152 |
145 return *show_in_original_tab_cache_; | 153 return *show_in_original_tab_cache_; |
146 } | 154 } |
147 | 155 |
| 156 void ClientPolicyController::AddPolicyForTest( |
| 157 const std::string& name_space, |
| 158 const OfflinePageClientPolicyBuilder& builder) { |
| 159 policies_.insert(std::make_pair(name_space, builder.Build())); |
| 160 } |
| 161 |
148 } // namespace offline_pages | 162 } // namespace offline_pages |
OLD | NEW |