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 #ifndef COMPONENTS_OFFLINE_PAGES_CLIENT_POLICY_CONTROLLER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CLIENT_POLICY_CONTROLLER_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_CLIENT_POLICY_CONTROLLER_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CLIENT_POLICY_CONTROLLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 17 matching lines...) Expand all Loading... | |
28 static const OfflinePageClientPolicy MakePolicy( | 28 static const OfflinePageClientPolicy MakePolicy( |
29 const std::string& name_space, | 29 const std::string& name_space, |
30 LifetimePolicy::LifetimeType lifetime_type, | 30 LifetimePolicy::LifetimeType lifetime_type, |
31 const base::TimeDelta& expiration_period, | 31 const base::TimeDelta& expiration_period, |
32 size_t page_limit, | 32 size_t page_limit, |
33 size_t pages_allowed_per_url); | 33 size_t pages_allowed_per_url); |
34 | 34 |
35 // Get the client policy for |name_space|. | 35 // Get the client policy for |name_space|. |
36 const OfflinePageClientPolicy& GetPolicy(const std::string& name_space) const; | 36 const OfflinePageClientPolicy& GetPolicy(const std::string& name_space) const; |
37 | 37 |
38 // Returns a list of all known namespaces. | |
39 std::vector<std::string> GetAllNamespaces() const; | |
40 | |
38 // Returns whether pages for |name_space| should be removed on cache reset. | 41 // Returns whether pages for |name_space| should be removed on cache reset. |
39 bool IsRemovedOnCacheReset(const std::string& name_space) const; | 42 bool IsRemovedOnCacheReset(const std::string& name_space) const; |
40 | 43 |
41 // Returns whether pages for |name_space| are shown in Download UI. | 44 // Returns whether pages for |name_space| are shown in Download UI. |
42 bool IsSupportedByDownload(const std::string& name_space) const; | 45 bool IsSupportedByDownload(const std::string& name_space) const; |
43 const std::vector<std::string>& GetNamespacesSupportedByDownload() const; | 46 const std::vector<std::string>& GetNamespacesSupportedByDownload() const; |
44 | 47 |
45 // Returns whether pages for |name_space| are shown in recent tabs UI, | 48 // Returns whether pages for |name_space| are shown in recent tabs UI, |
46 // currently only available on NTP. | 49 // currently only available on NTP. |
47 bool IsShownAsRecentlyVisitedSite(const std::string& name_space) const; | 50 bool IsShownAsRecentlyVisitedSite(const std::string& name_space) const; |
48 const std::vector<std::string>& GetNamespacesShownAsRecentlyVisitedSite() | 51 const std::vector<std::string>& GetNamespacesShownAsRecentlyVisitedSite() |
49 const; | 52 const; |
50 | 53 |
51 // Returns whether pages for |name_space| should never be shown outside the | 54 // Returns whether pages for |name_space| should never be shown outside the |
52 // tab they were generated in. | 55 // tab they were generated in. |
53 bool IsRestrictedToOriginalTab(const std::string& name_space) const; | 56 bool IsRestrictedToOriginalTab(const std::string& name_space) const; |
54 const std::vector<std::string>& GetNamespacesRestrictedToOriginalTab() const; | 57 const std::vector<std::string>& GetNamespacesRestrictedToOriginalTab() const; |
55 | 58 |
59 void AddPolicyForTest(std::string name_space, | |
fgorski
2016/10/26 18:05:41
why not const ref ?
dewittj
2016/10/27 22:49:17
Done.
In my experience, strings were not required
| |
60 const OfflinePageClientPolicyBuilder& builder); | |
61 | |
56 private: | 62 private: |
57 // The map from name_space to a client policy. Will be generated | 63 // The map from name_space to a client policy. Will be generated |
58 // as pre-defined values for now. | 64 // as pre-defined values for now. |
59 std::map<std::string, OfflinePageClientPolicy> policies_; | 65 std::map<std::string, OfflinePageClientPolicy> policies_; |
60 | 66 |
61 // Memoizing results. | 67 // Memoizing results. |
62 mutable std::unique_ptr<std::vector<std::string>> download_namespace_cache_; | 68 mutable std::unique_ptr<std::vector<std::string>> download_namespace_cache_; |
63 mutable std::unique_ptr<std::vector<std::string>> recent_tab_namespace_cache_; | 69 mutable std::unique_ptr<std::vector<std::string>> recent_tab_namespace_cache_; |
64 mutable std::unique_ptr<std::vector<std::string>> show_in_original_tab_cache_; | 70 mutable std::unique_ptr<std::vector<std::string>> show_in_original_tab_cache_; |
65 | 71 |
66 DISALLOW_COPY_AND_ASSIGN(ClientPolicyController); | 72 DISALLOW_COPY_AND_ASSIGN(ClientPolicyController); |
67 }; | 73 }; |
68 | 74 |
69 } // namespace offline_pages | 75 } // namespace offline_pages |
70 | 76 |
71 #endif // COMPONENTS_OFFLINE_PAGES_CLIENT_POLICY_CONTROLLER_H_ | 77 #endif // COMPONENTS_OFFLINE_PAGES_CLIENT_POLICY_CONTROLLER_H_ |
OLD | NEW |