OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <set> | 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "chrome/browser/extensions/activity_log/activity_actions.h" | 17 #include "chrome/browser/extensions/activity_log/activity_actions.h" |
17 #include "chrome/browser/extensions/activity_log/activity_database.h" | 18 #include "chrome/browser/extensions/activity_log/activity_database.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 98 |
98 // For unit testing only. | 99 // For unit testing only. |
99 void SetClockForTesting(scoped_ptr<base::Clock> clock); | 100 void SetClockForTesting(scoped_ptr<base::Clock> clock); |
100 | 101 |
101 // A collection of methods that are useful for implementing policies. These | 102 // A collection of methods that are useful for implementing policies. These |
102 // are all static methods; the ActivityLogPolicy::Util class cannot be | 103 // are all static methods; the ActivityLogPolicy::Util class cannot be |
103 // instantiated. This is nested within ActivityLogPolicy to make calling | 104 // instantiated. This is nested within ActivityLogPolicy to make calling |
104 // these methods more convenient from within a policy, but they are public. | 105 // these methods more convenient from within a policy, but they are public. |
105 class Util { | 106 class Util { |
106 public: | 107 public: |
| 108 // A collection of API calls, used to specify whitelists for argument |
| 109 // filtering. |
| 110 typedef std::set<std::pair<Action::ActionType, std::string> > ApiSet; |
| 111 |
107 // Serialize a Value as a JSON string. Returns an empty string if value is | 112 // Serialize a Value as a JSON string. Returns an empty string if value is |
108 // null. | 113 // null. |
109 static std::string Serialize(const base::Value* value); | 114 static std::string Serialize(const base::Value* value); |
110 | 115 |
111 // Removes potentially privacy-sensitive data that should not be logged. | 116 // Removes potentially privacy-sensitive data that should not be logged. |
112 // This should generally be called on an Action before logging, unless | 117 // This should generally be called on an Action before logging, unless |
113 // debugging flags are enabled. Modifies the Action object in place; if | 118 // debugging flags are enabled. Modifies the Action object in place; if |
114 // the action might be shared with other users, it is up to the caller to | 119 // the action might be shared with other users, it is up to the caller to |
115 // call ->Clone() first. | 120 // call ->Clone() first. |
116 static void StripPrivacySensitiveFields(scoped_refptr<Action> action); | 121 static void StripPrivacySensitiveFields(scoped_refptr<Action> action); |
117 | 122 |
118 // Strip arguments from most API actions, preserving actions only for a | 123 // Strip arguments from most API actions, preserving actions only for a |
119 // whitelisted set. Modifies the Action object in-place. | 124 // whitelisted set. Modifies the Action object in-place. |
120 static void StripArguments(const std::set<std::string>& api_whitelist, | 125 static void StripArguments(const ApiSet& api_whitelist, |
121 scoped_refptr<Action> action); | 126 scoped_refptr<Action> action); |
122 | 127 |
123 // Given a base day (timestamp at local midnight), computes the timestamp | 128 // Given a base day (timestamp at local midnight), computes the timestamp |
124 // at midnight the given number of days before or after. | 129 // at midnight the given number of days before or after. |
125 static base::Time AddDays(const base::Time& base_date, int days); | 130 static base::Time AddDays(const base::Time& base_date, int days); |
126 | 131 |
127 // Compute the time bounds that should be used for a database query to | 132 // Compute the time bounds that should be used for a database query to |
128 // cover a time range days_ago days in the past, relative to the specified | 133 // cover a time range days_ago days in the past, relative to the specified |
129 // time. | 134 // time. |
130 static void ComputeDatabaseTimeBounds(const base::Time& now, | 135 static void ComputeDatabaseTimeBounds(const base::Time& now, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 217 |
213 private: | 218 private: |
214 // See the comments for the ActivityDatabase class for a discussion of how | 219 // See the comments for the ActivityDatabase class for a discussion of how |
215 // database cleanup runs. | 220 // database cleanup runs. |
216 ActivityDatabase* db_; | 221 ActivityDatabase* db_; |
217 }; | 222 }; |
218 | 223 |
219 } // namespace extensions | 224 } // namespace extensions |
220 | 225 |
221 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 226 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
OLD | NEW |