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

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

Issue 2656713002: Merge to M57: Remove popup overlay from MHTML when requested (Closed)
Patch Set: Created 3 years, 10 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
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_CORE_OFFLINE_PAGE_CLIENT_POLICY_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_CLIENT_POLICY_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_CLIENT_POLICY_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_CLIENT_POLICY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 24 matching lines...) Expand all
35 // A TimeDelta of 0 means no expiration. 35 // A TimeDelta of 0 means no expiration.
36 base::TimeDelta expiration_period; 36 base::TimeDelta expiration_period;
37 37
38 // The maximum number of pages allowed to be saved by the namespace. 38 // The maximum number of pages allowed to be saved by the namespace.
39 // kUnlimitedPages (defined above) means no limit set. 39 // kUnlimitedPages (defined above) means no limit set.
40 size_t page_limit; 40 size_t page_limit;
41 41
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. 52 // Whether pages are shown in recent tabs ui.
53 bool is_supported_by_recent_tabs; 53 bool is_supported_by_recent_tabs;
54 // Whether pages should only be viewed in the tab they were generated in. 54 // Whether pages should only be viewed in the tab they were generated in.
55 bool only_shown_in_original_tab; 55 bool only_shown_in_original_tab;
56 // 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.
57 bool is_removed_on_cache_reset; 57 bool is_removed_on_cache_reset;
58 58
59 FeaturePolicy() 59 FeaturePolicy()
60 : is_supported_by_download(false), 60 : is_supported_by_download(false),
61 is_supported_by_recent_tabs(false), 61 is_supported_by_recent_tabs(false),
62 only_shown_in_original_tab(false), 62 only_shown_in_original_tab(false),
63 is_removed_on_cache_reset(true){}; 63 is_removed_on_cache_reset(true) {}
64 }; 64 };
65 65
66 // The struct describing policies for various namespaces (Bookmark, Last-N etc.) 66 // The struct describing policies for various namespaces (Bookmark, Last-N etc.)
67 // 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
68 // it's sufficient to compare name_space only when doing comparisons. 68 // it's sufficient to compare name_space only when doing comparisons.
69 struct OfflinePageClientPolicy { 69 struct OfflinePageClientPolicy {
70 // Namespace to which the policy applied. 70 // Namespace to which the policy applied.
71 std::string name_space; 71 std::string name_space;
72 72
73 // 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 13 matching lines...) Expand all
87 lifetime_policy(lifetime_policy_val), 87 lifetime_policy(lifetime_policy_val),
88 pages_allowed_per_url(pages_allowed_per_url_val), 88 pages_allowed_per_url(pages_allowed_per_url_val),
89 feature_policy(feature_policy_val){}; 89 feature_policy(feature_policy_val){};
90 90
91 OfflinePageClientPolicy(std::string namespace_val, 91 OfflinePageClientPolicy(std::string namespace_val,
92 LifetimePolicy lifetime_policy_val, 92 LifetimePolicy lifetime_policy_val,
93 size_t pages_allowed_per_url_val) 93 size_t pages_allowed_per_url_val)
94 : OfflinePageClientPolicy(namespace_val, 94 : OfflinePageClientPolicy(namespace_val,
95 lifetime_policy_val, 95 lifetime_policy_val,
96 pages_allowed_per_url_val, 96 pages_allowed_per_url_val,
97 FeaturePolicy()){}; 97 FeaturePolicy()) {}
98 }; 98 };
99 99
100 class OfflinePageClientPolicyBuilder { 100 class OfflinePageClientPolicyBuilder {
101 public: 101 public:
102 OfflinePageClientPolicyBuilder(const std::string& name_space, 102 OfflinePageClientPolicyBuilder(const std::string& name_space,
103 LifetimePolicy::LifetimeType lifetime_type, 103 LifetimePolicy::LifetimeType lifetime_type,
104 size_t page_limit, 104 size_t page_limit,
105 size_t pages_allowed_per_url) 105 size_t pages_allowed_per_url)
106 : policy_( 106 : policy_(
107 OfflinePageClientPolicy(name_space, 107 OfflinePageClientPolicy(name_space,
108 LifetimePolicy(lifetime_type, page_limit), 108 LifetimePolicy(lifetime_type, page_limit),
109 pages_allowed_per_url)){}; 109 pages_allowed_per_url)) {}
110 110
111 ~OfflinePageClientPolicyBuilder() {} 111 ~OfflinePageClientPolicyBuilder() {}
112 112
113 // Calling build does not reset the object inside. 113 // Calling build does not reset the object inside.
114 const OfflinePageClientPolicy Build() const { return policy_; } 114 const OfflinePageClientPolicy Build() const { return policy_; }
115 115
116 OfflinePageClientPolicyBuilder& SetExpirePeriod( 116 OfflinePageClientPolicyBuilder& SetExpirePeriod(
117 const base::TimeDelta& expire_period) { 117 const base::TimeDelta& expire_period) {
118 policy_.lifetime_policy.expiration_period = expire_period; 118 policy_.lifetime_policy.expiration_period = expire_period;
119 return *this; 119 return *this;
(...skipping 26 matching lines...) Expand all
146 146
147 private: 147 private:
148 OfflinePageClientPolicy policy_; 148 OfflinePageClientPolicy policy_;
149 149
150 DISALLOW_COPY_AND_ASSIGN(OfflinePageClientPolicyBuilder); 150 DISALLOW_COPY_AND_ASSIGN(OfflinePageClientPolicyBuilder);
151 }; 151 };
152 152
153 } // namespace offline_pages 153 } // namespace offline_pages
154 154
155 #endif // COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_CLIENT_POLICY_H_ 155 #endif // COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_CLIENT_POLICY_H_
OLDNEW
« no previous file with comments | « components/offline_pages/core/offline_page_archiver.h ('k') | components/offline_pages/core/offline_page_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698