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

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

Issue 11946028: Record event activity to the extension activity log. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix for ExtensionService being unavailable during unit tests Created 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 18 matching lines...) Expand all
29 class Extension; 29 class Extension;
30 30
31 // A utility for tracing interesting activity for each extension. 31 // A utility for tracing interesting activity for each extension.
32 // It writes to an ActivityDatabase on a separate thread to record the activity. 32 // It writes to an ActivityDatabase on a separate thread to record the activity.
33 class ActivityLog : public ProfileKeyedService, 33 class ActivityLog : public ProfileKeyedService,
34 public TabHelper::ScriptExecutionObserver { 34 public TabHelper::ScriptExecutionObserver {
35 public: 35 public:
36 enum Activity { 36 enum Activity {
37 ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called. 37 ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called.
38 ACTIVITY_EXTENSION_API_BLOCK, // Extension API invocation is blocked. 38 ACTIVITY_EXTENSION_API_BLOCK, // Extension API invocation is blocked.
39 ACTIVITY_CONTENT_SCRIPT // Content script is executing. 39 ACTIVITY_CONTENT_SCRIPT, // Content script is executing.
40 ACTIVITY_EVENT_DISPATCH, // Event sent to listener in extension.
40 }; 41 };
41 42
42 // Observers can listen for activity events. 43 // Observers can listen for activity events.
43 class Observer { 44 class Observer {
44 public: 45 public:
45 virtual void OnExtensionActivity( 46 virtual void OnExtensionActivity(
46 const Extension* extension, 47 const Extension* extension,
47 Activity activity, 48 Activity activity,
48 const std::string& message) = 0; 49 const std::string& message) = 0;
49 }; 50 };
(...skipping 10 matching lines...) Expand all
60 void AddObserver(const Extension* extension, Observer* observer); 61 void AddObserver(const Extension* extension, Observer* observer);
61 void RemoveObserver(const Extension* extension, 62 void RemoveObserver(const Extension* extension,
62 Observer* observer); 63 Observer* observer);
63 64
64 // Check for the existence observer list by extension_id. 65 // Check for the existence observer list by extension_id.
65 bool HasObservers(const Extension* extension) const; 66 bool HasObservers(const Extension* extension) const;
66 67
67 // Log a successful API call made by an extension. 68 // Log a successful API call made by an extension.
68 // This will create an APIAction for storage in the database. 69 // This will create an APIAction for storage in the database.
69 void LogAPIAction(const Extension* extension, 70 void LogAPIAction(const Extension* extension,
70 const std::string& name, // e.g., chrome.tabs.get 71 const std::string& name, // e.g., tabs.get
71 const ListValue* args, // the argument values e.g. 46 72 const ListValue* args, // the argument values e.g. 46
72 const std::string& extra); // any extra logging info 73 const std::string& extra); // any extra logging info
73 74
75 // Log an event notification delivered to an extension.
76 // This will create an APIAction for storage in the database.
77 void LogEventAction(const Extension* extension,
78 const std::string& name, // e.g., tabs.onUpdate
79 const ListValue* args, // arguments to the callback
80 const std::string& extra); // any extra logging info
81
74 // Log a blocked API call made by an extension. 82 // Log a blocked API call made by an extension.
75 // This will create a BlockedAction for storage in the database. 83 // This will create a BlockedAction for storage in the database.
76 void LogBlockedAction(const Extension* extension, 84 void LogBlockedAction(const Extension* extension,
77 const std::string& blocked_call, // eg chrome.tabs.get 85 const std::string& blocked_call, // e.g., tabs.get
78 const ListValue* args, // argument values 86 const ListValue* args, // argument values
79 const char* reason, // why it's blocked 87 const char* reason, // why it's blocked
80 const std::string& extra); // extra logging info 88 const std::string& extra); // extra logging info
81 89
82 // Log an interaction between an extension and a URL. 90 // Log an interaction between an extension and a URL.
83 // This will create a UrlAction for storage in the database. 91 // This will create a UrlAction for storage in the database.
84 // The technical message might be the list of content scripts that have been 92 // The technical message might be the list of content scripts that have been
85 // injected, or the DOM API call; it's what's shown under "More". 93 // injected, or the DOM API call; it's what's shown under "More".
86 void LogUrlAction(const Extension* extension, 94 void LogUrlAction(const Extension* extension,
87 const UrlAction::UrlActionType verb, // eg XHR 95 const UrlAction::UrlActionType verb, // e.g., XHR
88 const GURL& url, // target URL 96 const GURL& url, // target URL
89 const string16& url_title, // title of the URL, 97 const string16& url_title, // title of the URL,
90 // can be empty string 98 // can be empty string
91 const std::string& technical_message, // "More" 99 const std::string& technical_message, // "More"
92 const std::string& extra); // extra logging info 100 const std::string& extra); // extra logging info
93 101
94 // An error has happened; we want to rollback and close the db. 102 // An error has happened; we want to rollback and close the db.
95 // Needs to be public so the error delegate can call it. 103 // Needs to be public so the error delegate can call it.
96 void KillActivityLogDatabase(); 104 void KillActivityLogDatabase();
97 105
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 187
180 virtual bool ServiceRedirectedInIncognito() const OVERRIDE; 188 virtual bool ServiceRedirectedInIncognito() const OVERRIDE;
181 189
182 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); 190 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory);
183 }; 191 };
184 192
185 193
186 } // namespace extensions 194 } // namespace extensions
187 195
188 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ 196 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_
189
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698