OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_ACTIONS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 // didn't categorize it as such (likely because we didn't recognize it as | 59 // didn't categorize it as such (likely because we didn't recognize it as |
60 // an ad network). If our list is effective, this should be significantly | 60 // an ad network). If our list is effective, this should be significantly |
61 // lower than the non-LIKELY counterparts. | 61 // lower than the non-LIKELY counterparts. |
62 INJECTION_LIKELY_NEW_AD, | 62 INJECTION_LIKELY_NEW_AD, |
63 INJECTION_LIKELY_REPLACED_AD, | 63 INJECTION_LIKELY_REPLACED_AD, |
64 | 64 |
65 // Place any new injection types above this entry. | 65 // Place any new injection types above this entry. |
66 NUM_INJECTION_TYPES | 66 NUM_INJECTION_TYPES |
67 }; | 67 }; |
68 | 68 |
69 // The type of ad which was injected. | |
Mark P
2014/05/27 20:07:46
Please put the standard warning here about not del
Devlin
2014/05/27 20:09:24
Done.
| |
70 enum AdType { | |
71 AD_TYPE_NONE, | |
72 AD_TYPE_IFRAME, | |
73 AD_TYPE_EMBED, | |
74 AD_TYPE_ANCHOR, | |
75 | |
76 // Place any new injection types above this entry. | |
77 NUM_AD_TYPES | |
78 }; | |
79 | |
69 // A useful shorthand for methods that take or return collections of Action | 80 // A useful shorthand for methods that take or return collections of Action |
70 // objects. | 81 // objects. |
71 typedef std::vector<scoped_refptr<Action> > ActionVector; | 82 typedef std::vector<scoped_refptr<Action> > ActionVector; |
72 | 83 |
73 // Creates a new activity log Action object. The extension_id and type | 84 // Creates a new activity log Action object. The extension_id and type |
74 // fields are immutable. All other fields can be filled in with the | 85 // fields are immutable. All other fields can be filled in with the |
75 // accessors/mutators below. | 86 // accessors/mutators below. |
76 Action(const std::string& extension_id, | 87 Action(const std::string& extension_id, |
77 const base::Time& time, | 88 const base::Time& time, |
78 const ActionType action_type, | 89 const ActionType action_type, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 | 170 |
160 // Print an action as a regular string for debugging purposes. | 171 // Print an action as a regular string for debugging purposes. |
161 virtual std::string PrintForDebug() const; | 172 virtual std::string PrintForDebug() const; |
162 | 173 |
163 protected: | 174 protected: |
164 virtual ~Action(); | 175 virtual ~Action(); |
165 | 176 |
166 private: | 177 private: |
167 friend class base::RefCountedThreadSafe<Action>; | 178 friend class base::RefCountedThreadSafe<Action>; |
168 | 179 |
180 // Returns true if a given |url| could be an ad. | |
181 bool UrlCouldBeAd(const GURL& url) const; | |
182 | |
169 // Uploads the URL to RAPPOR (preserving privacy) if this might have been an | 183 // Uploads the URL to RAPPOR (preserving privacy) if this might have been an |
170 // ad injection. | 184 // ad injection. |
171 void MaybeUploadUrl(rappor::RapporService* rappor_service) const; | 185 void MaybeUploadUrl(rappor::RapporService* rappor_service) const; |
172 | 186 |
173 // Checks an action with the appendChild API for ad injection. | |
174 InjectionType CheckAppendChild() const; | |
175 // Checks an action that modified the src of an element for ad injection. | 187 // Checks an action that modified the src of an element for ad injection. |
176 InjectionType CheckSrcModification() const; | 188 InjectionType CheckSrcModification() const; |
189 // Checks an action with the appendChild API for ad injection. | |
190 // |ad_type_out| is populated with the type of ad which was injected, if there | |
191 // was an injection. | |
192 InjectionType CheckAppendChild(AdType* ad_type_out) const; | |
193 // Checks a DOM object (e.g. an appended child) for ad injection. | |
194 // |ad_type_out| is populated with the type of ad which was injected, if there | |
195 // was an injection. | |
196 InjectionType CheckDomObject(const base::DictionaryValue* object, | |
197 AdType* ad_type_out) const; | |
177 | 198 |
178 std::string extension_id_; | 199 std::string extension_id_; |
179 base::Time time_; | 200 base::Time time_; |
180 ActionType action_type_; | 201 ActionType action_type_; |
181 std::string api_name_; | 202 std::string api_name_; |
182 scoped_ptr<base::ListValue> args_; | 203 scoped_ptr<base::ListValue> args_; |
183 GURL page_url_; | 204 GURL page_url_; |
184 std::string page_title_; | 205 std::string page_title_; |
185 bool page_incognito_; | 206 bool page_incognito_; |
186 GURL arg_url_; | 207 GURL arg_url_; |
(...skipping 18 matching lines...) Expand all Loading... | |
205 // comparisons. | 226 // comparisons. |
206 struct ActionComparatorExcludingTimeAndActionId { | 227 struct ActionComparatorExcludingTimeAndActionId { |
207 // Evaluates the comparison lhs < rhs. | 228 // Evaluates the comparison lhs < rhs. |
208 bool operator()(const scoped_refptr<Action>& lhs, | 229 bool operator()(const scoped_refptr<Action>& lhs, |
209 const scoped_refptr<Action>& rhs) const; | 230 const scoped_refptr<Action>& rhs) const; |
210 }; | 231 }; |
211 | 232 |
212 } // namespace extensions | 233 } // namespace extensions |
213 | 234 |
214 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ | 235 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ |
OLD | NEW |