Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: components/offline_pages/offline_page_client_policy.h

Issue 2364253002: [Offline Pages] Adds new policy bits and reverse lookup. (Closed)
Patch Set: Rename. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/offline_pages/client_policy_controller_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_OFFLINE_PAGE_CLIENT_POLICY_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_CLIENT_POLICY_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_CLIENT_POLICY_H_ 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_CLIENT_POLICY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 LifetimePolicy(LifetimeType init_lifetime_type, size_t init_page_limit) 42 LifetimePolicy(LifetimeType init_lifetime_type, size_t init_page_limit)
43 : lifetime_type(init_lifetime_type), 43 : lifetime_type(init_lifetime_type),
44 expiration_period(base::TimeDelta::FromDays(0)), 44 expiration_period(base::TimeDelta::FromDays(0)),
45 page_limit(init_page_limit){}; 45 page_limit(init_page_limit){};
46 }; 46 };
47 47
48 // The struct describing feature set of the offline pages. 48 // The struct describing feature set of the offline pages.
49 struct FeaturePolicy { 49 struct FeaturePolicy {
50 // Whether pages are shown in download ui. 50 // Whether pages are shown in download ui.
51 bool is_supported_by_download; 51 bool is_supported_by_download;
52 // Whether pages are shown in recent tabs ui.
53 bool is_supported_by_recent_tabs;
54 // Whether pages should only be viewed in the tab they were generated in.
55 bool only_shown_in_original_tab;
52 // Whether pages are removed on user-initiated cache reset. Defaults to true. 56 // Whether pages are removed on user-initiated cache reset. Defaults to true.
53 bool is_removed_on_cache_reset; 57 bool is_removed_on_cache_reset;
54 58
55 FeaturePolicy() 59 FeaturePolicy()
56 : is_supported_by_download(false), is_removed_on_cache_reset(true){}; 60 : is_supported_by_download(false),
61 is_supported_by_recent_tabs(false),
62 only_shown_in_original_tab(false),
63 is_removed_on_cache_reset(true){};
57 }; 64 };
58 65
59 // The struct describing policies for various namespaces (Bookmark, Last-N etc.) 66 // The struct describing policies for various namespaces (Bookmark, Last-N etc.)
60 // used by offline page model. The name_space is supposed to be key, so that 67 // used by offline page model. The name_space is supposed to be key, so that
61 // it's sufficient to compare name_space only when doing comparisons. 68 // it's sufficient to compare name_space only when doing comparisons.
62 struct OfflinePageClientPolicy { 69 struct OfflinePageClientPolicy {
63 // Namespace to which the policy applied. 70 // Namespace to which the policy applied.
64 std::string name_space; 71 std::string name_space;
65 72
66 // Policy to control the lifetime of a page generated by this namespace. 73 // Policy to control the lifetime of a page generated by this namespace.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 policy_.lifetime_policy.expiration_period = expire_period; 118 policy_.lifetime_policy.expiration_period = expire_period;
112 return *this; 119 return *this;
113 } 120 }
114 121
115 OfflinePageClientPolicyBuilder& SetIsSupportedByDownload( 122 OfflinePageClientPolicyBuilder& SetIsSupportedByDownload(
116 const bool is_downloaded) { 123 const bool is_downloaded) {
117 policy_.feature_policy.is_supported_by_download = is_downloaded; 124 policy_.feature_policy.is_supported_by_download = is_downloaded;
118 return *this; 125 return *this;
119 } 126 }
120 127
128 OfflinePageClientPolicyBuilder& SetIsSupportedByRecentTabs(
129 const bool is_recent_tabs) {
130 policy_.feature_policy.is_supported_by_recent_tabs = is_recent_tabs;
131 return *this;
132 }
133
121 OfflinePageClientPolicyBuilder& SetIsRemovedOnCacheReset( 134 OfflinePageClientPolicyBuilder& SetIsRemovedOnCacheReset(
122 const bool removed_on_cache_reset) { 135 const bool removed_on_cache_reset) {
123 policy_.feature_policy.is_removed_on_cache_reset = removed_on_cache_reset; 136 policy_.feature_policy.is_removed_on_cache_reset = removed_on_cache_reset;
124 return *this; 137 return *this;
125 } 138 }
126 139
140 OfflinePageClientPolicyBuilder& SetIsOnlyShownInOriginalTab(
141 const bool only_shown_in_original_tab) {
142 policy_.feature_policy.only_shown_in_original_tab =
143 only_shown_in_original_tab;
144 return *this;
145 }
146
127 private: 147 private:
128 OfflinePageClientPolicy policy_; 148 OfflinePageClientPolicy policy_;
129 149
130 DISALLOW_COPY_AND_ASSIGN(OfflinePageClientPolicyBuilder); 150 DISALLOW_COPY_AND_ASSIGN(OfflinePageClientPolicyBuilder);
131 }; 151 };
132 152
133 } // namespace offline_pages 153 } // namespace offline_pages
134 154
135 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_CLIENT_POLICY_H_ 155 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_CLIENT_POLICY_H_
OLDNEW
« no previous file with comments | « components/offline_pages/client_policy_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698