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

Side by Side Diff: chrome/browser/extensions/activity_log/activity_actions.h

Issue 292313006: Improve activity log ad metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 (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 27 matching lines...) Expand all
38 ACTION_API_CALL = 0, 38 ACTION_API_CALL = 0,
39 ACTION_API_EVENT = 1, 39 ACTION_API_EVENT = 1,
40 UNUSED_ACTION_API_BLOCKED = 2, // Not in use, but reserved for future. 40 UNUSED_ACTION_API_BLOCKED = 2, // Not in use, but reserved for future.
41 ACTION_CONTENT_SCRIPT = 3, 41 ACTION_CONTENT_SCRIPT = 3,
42 ACTION_DOM_ACCESS = 4, 42 ACTION_DOM_ACCESS = 4,
43 ACTION_DOM_EVENT = 5, 43 ACTION_DOM_EVENT = 5,
44 ACTION_WEB_REQUEST = 6, 44 ACTION_WEB_REQUEST = 6,
45 ACTION_ANY = 1001, // Used for lookups of unspecified type. 45 ACTION_ANY = 1001, // Used for lookups of unspecified type.
46 }; 46 };
47 47
48 // The type of ad injection an action performed. 48 // The type of ad injection an action performed. Do not delete or reorder
49 // these metrics, as they are used in histogramming.
49 enum InjectionType { 50 enum InjectionType {
50 // No ad injection occurred. 51 // No ad injection occurred.
51 NO_AD_INJECTION = 0, 52 NO_AD_INJECTION = 0,
52 // A new ad was injected. 53 // A new ad was injected.
53 INJECTION_NEW_AD, 54 INJECTION_NEW_AD,
54 // An ad was removed. 55 // An ad was removed.
55 INJECTION_REMOVED_AD, 56 INJECTION_REMOVED_AD,
56 // An ad was replaced. 57 // An ad was replaced.
57 INJECTION_REPLACED_AD, 58 INJECTION_REPLACED_AD,
58 // Something occurred which heuristically looks like an ad injection, but we 59 // Something occurred which heuristically looks like an ad injection, but we
59 // didn't categorize it as such (likely because we didn't recognize it as 60 // 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 61 // an ad network). If our list is effective, this should be significantly
61 // lower than the non-LIKELY counterparts. 62 // lower than the non-LIKELY counterparts.
62 INJECTION_LIKELY_NEW_AD, 63 INJECTION_LIKELY_NEW_AD,
63 INJECTION_LIKELY_REPLACED_AD, 64 INJECTION_LIKELY_REPLACED_AD,
64 65
65 // Place any new injection types above this entry. 66 // Place any new injection types above this entry.
66 NUM_INJECTION_TYPES 67 NUM_INJECTION_TYPES
67 }; 68 };
68 69
70 // The type of ad which was injected.
71 enum AdType {
72 AD_TYPE_NONE,
73 AD_TYPE_IFRAME,
74 AD_TYPE_EMBED,
75 AD_TYPE_ANCHOR,
76
77 // Place any new injection types above this entry.
78 NUM_AD_TYPES
79 };
80
69 // A useful shorthand for methods that take or return collections of Action 81 // A useful shorthand for methods that take or return collections of Action
70 // objects. 82 // objects.
71 typedef std::vector<scoped_refptr<Action> > ActionVector; 83 typedef std::vector<scoped_refptr<Action> > ActionVector;
72 84
73 // Creates a new activity log Action object. The extension_id and type 85 // 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 86 // fields are immutable. All other fields can be filled in with the
75 // accessors/mutators below. 87 // accessors/mutators below.
76 Action(const std::string& extension_id, 88 Action(const std::string& extension_id,
77 const base::Time& time, 89 const base::Time& time,
78 const ActionType action_type, 90 const ActionType action_type,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 171
160 // Print an action as a regular string for debugging purposes. 172 // Print an action as a regular string for debugging purposes.
161 virtual std::string PrintForDebug() const; 173 virtual std::string PrintForDebug() const;
162 174
163 protected: 175 protected:
164 virtual ~Action(); 176 virtual ~Action();
165 177
166 private: 178 private:
167 friend class base::RefCountedThreadSafe<Action>; 179 friend class base::RefCountedThreadSafe<Action>;
168 180
181 // Returns true if a given |url| could be an ad.
182 bool UrlCouldBeAd(const GURL& url) const;
183
169 // Uploads the URL to RAPPOR (preserving privacy) if this might have been an 184 // Uploads the URL to RAPPOR (preserving privacy) if this might have been an
170 // ad injection. 185 // ad injection.
171 void MaybeUploadUrl(rappor::RapporService* rappor_service) const; 186 void MaybeUploadUrl(rappor::RapporService* rappor_service) const;
172 187
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. 188 // Checks an action that modified the src of an element for ad injection.
176 InjectionType CheckSrcModification() const; 189 InjectionType CheckSrcModification() const;
190 // Checks an action with the appendChild API for ad injection.
191 // |ad_type_out| is populated with the type of ad which was injected, if there
192 // was an injection.
193 InjectionType CheckAppendChild(AdType* ad_type_out) const;
194 // Checks a DOM object (e.g. an appended child) for ad injection.
195 // |ad_type_out| is populated with the type of ad which was injected, if there
196 // was an injection.
197 InjectionType CheckDomObject(const base::DictionaryValue* object,
198 AdType* ad_type_out) const;
177 199
178 std::string extension_id_; 200 std::string extension_id_;
179 base::Time time_; 201 base::Time time_;
180 ActionType action_type_; 202 ActionType action_type_;
181 std::string api_name_; 203 std::string api_name_;
182 scoped_ptr<base::ListValue> args_; 204 scoped_ptr<base::ListValue> args_;
183 GURL page_url_; 205 GURL page_url_;
184 std::string page_title_; 206 std::string page_title_;
185 bool page_incognito_; 207 bool page_incognito_;
186 GURL arg_url_; 208 GURL arg_url_;
(...skipping 18 matching lines...) Expand all
205 // comparisons. 227 // comparisons.
206 struct ActionComparatorExcludingTimeAndActionId { 228 struct ActionComparatorExcludingTimeAndActionId {
207 // Evaluates the comparison lhs < rhs. 229 // Evaluates the comparison lhs < rhs.
208 bool operator()(const scoped_refptr<Action>& lhs, 230 bool operator()(const scoped_refptr<Action>& lhs,
209 const scoped_refptr<Action>& rhs) const; 231 const scoped_refptr<Action>& rhs) const;
210 }; 232 };
211 233
212 } // namespace extensions 234 } // namespace extensions
213 235
214 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ 236 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/active_script_controller.cc ('k') | chrome/browser/extensions/activity_log/activity_actions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698